Publish .Net Core Web API to Azure (App Service) - Express Guide

Required Azure Services
- App Service (https://azure.microsoft.com/en-us/pricing/details/app-service/linux/) - Have a Free tier

Create Azure App Service (Web App)
1. Login to your Azure portal.
2. Search for 'App Services' and select it
3. From the App Services window click on 'Add'
- This will redirect you to create Azure Web App page
4. Select your Azure Subscription and Resource group (Create new one if you don't have any)
5. Give instance name, select Publish mode as Code
6. Select your Runtime Stack (.Net or .Net Core version which supports your application).
7.You can select either Windows or Linux as Operating System. I used Linux because I'm hosting a .net Core Web API with Entity Framework Core.
NOTE: If your app is .Net standard application you have to select Windows.
8. Select Region as you like.
9. Select App Service Plan.
- Create new App Service plan if you like or you can keep the auto generated name.
- Select Sku (Stock Keeping Unit) and size. There is a free plan that you can use. To select that, click on 'Change size' and and from the Spec Picker window select Dev/Test category.
Then select F1 and click on Apply.


10. When you done with the settings click on 'Review & Create'
- Then it will redirect to Summary page. If everything looks good, click on Create.
- Then it will start creating your Web App and this will take some time to complete.

Get Publish Profile
1. Log in to Azure portal
2. Go to your App Service
3. From the overview section click on 'Get publish profile' to download the publishing profile

Publish Application
1. Open your solution in Visual Studio (I'm using VS 2019) and build your solution.
2. Right click on the API project and select Publish
3. Click on Import Profile
- Select the downloaded profile file from your downloaded location and click 'Open'


4. Click on Publish

Test your application 
1. Go to Azure portal
2. Open your App Service
3. From the overview section, copy the URL
4. Use it with your api endpoint to test it out using browser or postman
Ex: {Your-URL-in-Azure}/weatherforecast
NOTE: It will take some time to get your app up and running. So when you check the app with your endpoint, sometimes it might not come. So please wait some time and check it again.

Comments

Popular posts from this blog

Deploy Angular 8 app to Azure with Azure DevOps

Apache ActiveMQ 5 with .Net Core 3.1 and C#

Firebase with.Net Core and C#