Deploying a protected ASP.NET Core web API and calls the API from Desktop application
In this guide, we will deploy our project component, TodoListService to Azure App Services.
Table of Content
- Table of Content
- Known Issues
- More information
- Code of Conduct
- Visual Studio 2019 or the .NET Core SDK and VS Code.
- An Azure subscription. This sample uses Azure App Services.
- We recommend Azure Tools for VS Code Extension for interacting with Azure services directly within VS Code.
We will deploy our web API on Azure App Services.
Publish the Web API
There are two ways to publish the app:
- Publish using Visual Studio
- Publish using Visual Studio Code
Publish using Visual Studio
Follow the instructions at Publish a Web app to Azure App Service using Visual Studio.
Publish using Visual Studio Code
Using a command line interface such as VS Code integrated terminal, follow the documentation Publish an ASP.NET Core app to Azure with Visual Studio Code.
Configure the Web API
On the App Services portal, click on the Configuration blade and set the stack property to .NET Core.
Disabling Azure AD authentication
Still on the App Services portal, click on the Authentication/Authorization blade. There, make sure that the App Services Authentication is switched off (and nothing else is checked), as we are using our own authentication logic.
- Open the
- Find the key
todo:TodoListBaseAddressand replace the existing value with the Resource Uri that you've just obtained in deploying TodoListService on App Service (e.g. https://my-web-api.azurewebsites.net/).
- Re-build and run your client application.
Here we discuss some of the more important aspects of deploying multi-tenant application suites.
- In case you receive the
HTTP Error 500.30 - ANCM In-Process Start Failureerror for your Web API on Azure App Services, try adding this line to
TodoListService/TodoListService.csprojand re-deploy your project:
<PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework> <UserSecretsId>aspnet-TodoListService-BA938C29-8BAB-4664-A688-8FD54049C1C3</UserSecretsId> <WebProject_DirectoryAccessLevelKey>1</WebProject_DirectoryAccessLevelKey> <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel> // Add this line </PropertyGroup>
[!NOTE] Did the sample not work for you as expected? Did you encounter issues trying this sample? Then please reach out to us using the GitHub Issues page.
- Quickstart: Create an ASP.NET Core web app in Azure
- Tutorial: Authenticate and authorize users end-to-end in Azure App Service
- Authentication and authorization in Azure App Service and Azure Functions
- Configure your App Service or Azure Functions app to use Azure AD login