💀 The code in this lab is NOT meant to be used for production environments. It is a simple example with no error handling, no custom workflows, and is for learning purposes only.
In this lab, you will deploy a landing page and eventually integrate it with your Partner Center SaaS Offer.
For this lab, you will need the following.
- An Azure account and access to the Azure portal
- Visual Studio 2022 (any version)
- Git (optional)
Note: It is possible to complete this using Visual Studio Code, but the instructions are tailored for Visual Studio 2022.
There are three projects in the solution you'll be working with. You will deal with them one at a time over the course of the labs. In this lab, we will start with the landing page project.
- You will need to clone this repository to complete the hands-on-labs. To clone, click the Code button found at the top of this page or click Clone here to download a zip to your local machine
-
Using Visual Studio 2022, open the following solution file on your machine. Take care to choose the begin folder.
**\\saas\\lab-code\begin\SaaSLabsBegin.sln
-
Build the solution. You should get no build errors.
In this exercise, you will create an app registration in the Azure portal. It will be single-tenant and used to connect to the SaaS API.
- Log in to the Azure portal.
- In the top-of-center command window in the portal, type "app reg" and select the item "App registrations" that appears. You will see a list of current application registrations.
- At the top of the page, click the + New registration link. You are taken to the Register an application page.
- For the purposes of this lab, use
saas-workshop-single-tenant
as the name of this app registration. - At the bottom of the page, click the Register button.
Now you will add a secret to the app registration. Make sure to copy and paste the secret value somewhere you can access it later.
- Click into the
saas-workshop-single-tenant
application registration. - In the left-hand menu, find the Manage menu and click the Certificates and secrets link.
- Create a new client secret.
- Give it a description.
- Choose an expiration date. The 6-month default should be fine.
- Copy the Value of the secret and paste it somewhere you can easily access it later.
In this exercise, you will create a multi-tenant app registration in the Azure portal to authenticate users coming to your landing page.
- Create an app registration. For the purposes of this lab, use
saas-workshop-multi-tenant
as the name of this app registration. - Under Supported account types, select the option: Accounts in any organizational directory (Any Azure AD directory - Multitenant).
- At the bottom of the page, click the Register button.
-
In the left-hand menu under the Overview menu item, click the Quickstart link.
-
Find the Web application section and click the Start button.
-
Click ASP.NET Core.
-
On the resulting Quickstart page, click the Make this change for me button.
-
Under the Configuring your application registration, click the Make updates button.
-
In the left-hand menu under the Manage section, click the Authentication link.
Here you can see that two URLS have been added to the Redirect URIs section for you. These allow running your code in debug mode using the default debugger ports. You will add your actual landing page URLs here later.
- Create a client secret for this app registration.
- Copy the Value of the secret and paste it somewhere you can easily access it later.
The appsettings.json
file in the LandingPage project must be filled out before publishing the application. That's what you'll do in this section.
All changes in this section occur under the AzureAD
section of the appsettings.json
file.
- In the Landing Page project, open the
appsettings.json
file. - In the Azure portal, click the Azure Active Directory button in the left-hand menu.
- On the overview page in the Basic information section, find the Primary domain and use it to replace
DOMAIN_NAME
inappsettings.json
. - In the left-hand menu under the Manage menu, click the App registrations link.
- Click the
saas-workshop-multi-tenant
app registration. - In the
appsetting.json
file, replaceCLIENT_ID
with the Application (client) ID from this screen. - Replace
CLIENT_SECRET
with the client secret you noted earlier for thesaas-workshop-multi-tenant
app registration.
All changes in this section occur under the MarketplaceAPI
section of the appsettings.json
file.
- Go back to the list of App registrations.
- Click the
saas-workshop-single-tenant
app registration. - In the
appsetting.json
file, replaceCLIENT_ID
with the Application (client) ID from this screen. - In the
appsetting.json
file, replaceTENANT_ID
with the Directory (tenant) ID from this screen. - In the
appsetting.json
file, replaceCLIENT_SECRET
with the client secret value you stored earlier.
Congratulations, your LandingPage project is ready to publish!
First you must create a publish profile file that will hold the information about your project to publish. Also, you must create an App Service Plan to host your website.
-
In the Solution Explorer of Visual Studio, right click the
LandingPage
project and select Publish. -
The Publish dialog appears.
-
Select Azure as your publish target and click the Next button.
-
Select Azure App Service (Windows) and click the Next button.
You are now on the App Service tab. You may now need to sign in to Visual Studio with your Azure credentials.
-
Choose the correct subscription from the list of subscriptions.
-
To the far right of the words App Service Instances, click the green + (plus) button to create an App Service. The App Service dialog opens.
-
Name the App Service
SaaSWorkshopLandingPage
with a number on the end to make it unique. -
Choose
saas-workshop
for the resource group. -
Create a new Hosting Plan and name it
SaaSWorkshopAppServicePlan
. -
Click the Create button at the bottom of the screen.
After clicking the Create button at the bottom of the page it may take a moment for the Hosting Plan and App Service to be created.
-
After the App Service is created, you will be back at the Publish dialog. Select your new App Service instance and click the Next button.
-
For Publish type, select Publish (generate pubxmlfile).
-
Click the Finish button at the bottom of the dialog.
You now have a publish profile that can be used to publish your application.
Near the top-right of the Publish dialog click the Publish button. This deploys your application. You can watch the publish process in the Output window at the bottom of the screen.
The page will launch, but shows an error message. You aren't quite done configuring your landing page application.
-
In the command bar at the top of the Azure portal, search for and select App Services.
-
Click on the App Service you just created, SaaSWorkshopLandingPage.
-
On the overview screen in Visual Studio, the URL for the site should be in the Hosting section. Copy it into your paste buffer.
-
In the command bar at the top of the Azure portal, search for and select App registrations.
-
Click on the
saas-workshop-multi-tenant
app registration. -
In the left-hand menu click the Authentication link.
-
In the Web > Redirect URIs section, click Add URI and paste in your Landing Page URL.
-
Paste it in again on another line, this time adding a suffix of
/signin-oidc
so that your URI looks something like this.https://*.azurewebsites.net/signin-oidc
Click the Save button at the top of the screen.
- Using the App Service URL to you created,
https://<prefix>.azurewebsites.net
, browse to that web page. - Authenticate when prompted.
- You should see a message that reads, "Token URL parameter cannot be empty."
This is good! You are seeing this message because you aren't coming to the landing page through the Azure portal and no marketplace purchase token is being passed. To finish your configuration, we need to configure Partner Center to be aware of the landing page.
Congratulation! You have finished this lab.