|
| 1 | +## How to deploy this sample to Azure |
| 2 | + |
| 3 | +This tutorial has one WebApp and some chapters have a Web API project. To deploy them to Azure Web Sites, you'll need to perform these steps for **each** project: |
| 4 | + |
| 5 | +- create an Azure Web Site with a unique name |
| 6 | +- publish the Web App / Web APIs to the web site, and |
| 7 | +- update its client(s) to call the web site instead of IIS Express. |
| 8 | + |
| 9 | +### Create and publish the `WebApp-OpenIDConnect-DotNet-code-v2` to an Azure Web Site |
| 10 | + |
| 11 | +1. Sign in to the [Azure portal](https://portal.azure.com). |
| 12 | +1. Click `Create a resource` in the top left-hand corner, select **Web** --> **Web App**, and give your web site a name, for example, `WebApp-OpenIDConnect-DotNet-code-v2-contoso.azurewebsites.net`. |
| 13 | +1. Thereafter select the `Subscription`, `Resource Group`, `App service plan and Location`. `OS` will be **Windows** and `Publish` will be **Code**. |
| 14 | +1. Click `Create` and wait for the App Service to be created. |
| 15 | +1. Once you get the `Deployment succeeded` notification, then click on `Go to resource` to navigate to the newly created App service. |
| 16 | + |
| 17 | +### If your project uses **SQL Server**, please follow these steps |
| 18 | + |
| 19 | +1. The following steps provide instructions to create a Sql database that the sample needs. If you already have a Sql Server and database present and a connection string available, skip the steps till we ask you to provide the connections string in the `Application Settings`. |
| 20 | +1. Click `Create a resource` in the top left-hand corner again, select **Databases** --> **SQL Database**, to create a new database. Follow the `Quickstart tutorial` if needed. |
| 21 | +1. You can name the Sql server and database whatever you want to. |
| 22 | +1. Select or create a database server, and enter server login credentials. Carefully note down the username and password for the Sql server as you'll need it when constructing your Sql connection string later. |
| 23 | +1. Wait for the `Deployment succeeded` notification, then click on `Go to resource` to navigate to the newly created database's manage screen. |
| 24 | +1. Click on **Connection Strings** on left menu and copy the **ADO.NET (SQL authentication)** connection string. Populate **User ID={your_username};Password={your_password};** with values your provided during database creation.Copy this connection string. |
| 25 | +1. Click on **Application settings** in the left menu of the App service and add the copied Sql connection string in the **Connection strings** section as `DefaultConnection`. |
| 26 | +1. Choose `SQLAzure` in the **Type** dropdown. **Save** the setting. |
| 27 | + |
| 28 | +### Update the redirect URLs |
| 29 | + |
| 30 | +1. Navigate back to to the [Azure portal](https://portal.azure.com). |
| 31 | +In the left-hand navigation pane, select the **Azure Active Directory** service, and then select **App registrations**. |
| 32 | +1. In the resultant screen, select the `WebApp-OpenIDConnect-DotNet-code-v2` application. |
| 33 | +1. In the **Authentication** tab: |
| 34 | + - In the **Redirect URIs** section, select **Web** in the combo-box and add the following redirect URIs. |
| 35 | + - `https://WebApp-OpenIDConnect-DotNet-code-v2-contoso.azurewebsites.net` |
| 36 | + - `https://WebApp-OpenIDConnect-DotNet-code-v2-contoso.azurewebsites.net/signin-oidc` |
| 37 | + - In the **Advanced settings** section set **Logout URL** to `https://WebApp-OpenIDConnect-DotNet-code-v2-contoso.azurewebsites.net/signout-oidc` |
| 38 | +1. In the **Branding** tab: |
| 39 | + - Update the **Home page URL** to the address of your app service, for example `https://WebApp-OpenIDConnect-DotNet-code-v2-contoso.azurewebsites.net`. |
| 40 | + - Save the configuration. |
| 41 | +1. If your application calls a web api, make sure to apply the necessary changes on the project `appsettings.json`, so it calls the published API URL instead of `localhost`. |
| 42 | + |
| 43 | +### Publishing the sample |
| 44 | + |
| 45 | +1. From the **Overview** tab of the App Service, download the publish profile by clicking the **Get publish profile** link and save it. Other deployment mechanisms, such as from source control, can also be used. |
| 46 | +1. Switch to Visual Studio and go to the WebApp-OpenIDConnect-DotNet-code-v2 project. Right click on the project in the Solution Explorer and select **Publish**. Click **Import Profile** on the bottom bar, and import the publish profile that you downloaded earlier. |
| 47 | +1. Click on **Configure** and in the `Connection tab`, update the Destination URL so that it is a `https` in the home page url, for example [https://WebApp-OpenIDConnect-DotNet-code-v2-contoso.azurewebsites.net](https://WebApp-OpenIDConnect-DotNet-code-v2-contoso.azurewebsites.net). Click **Next**. |
| 48 | +1. On the Settings tab, make sure `Enable Organizational Authentication` is NOT selected. Click **Save**. Click on **Publish** on the main screen. |
| 49 | +1. Visual Studio will publish the project and automatically open a browser to the URL of the project. If you see the default web page of the project, the publication was successful. |
| 50 | + |
| 51 | +## Key Vault and Managed Service Identity (MSI) |
| 52 | + |
| 53 | +Secure key management is essential to protect data in the cloud. Use [Azure Key Vault](https://azure.microsoft.com/en-ca/services/key-vault/) to encrypt keys and small secrets like passwords that use keys stored in hardware security modules (HSMs). |
| 54 | + |
| 55 | +You can follow [this sample](https://github.com/Azure-Samples/app-service-msi-keyvault-dotnet) as a guide on how to use Azure KeyVault from App Service with Managed Service Identity (MSI). |
| 56 | + |
| 57 | +## Community Help and Support |
| 58 | + |
| 59 | +Use [Stack Overflow](http://stackoverflow.com/questions/tagged/msal) to get support from the community. |
| 60 | +Ask your questions on Stack Overflow first and browse existing issues to see if someone has asked your question before. |
| 61 | +Make sure that your questions or comments are tagged with [`azure-active-directory`] [`msal`] [`dotnet`]. |
| 62 | + |
| 63 | +If you find a bug in the sample, please raise the issue on [GitHub Issues](../../issues). |
| 64 | + |
| 65 | +To provide a recommendation, visit the following [User Voice page](https://feedback.azure.com/forums/169401-azure-active-directory). |
| 66 | + |
| 67 | +## More information |
| 68 | + |
| 69 | +For more information, see MSAL.NET's conceptual documentation: |
| 70 | + |
| 71 | +- [MSAL.NET's conceptual documentation](https://aka.ms/msal-net) |
| 72 | +- [National Clouds](https://docs.microsoft.com/en-us/azure/active-directory/develop/authentication-national-cloud#app-registration-endpoints) |
0 commit comments