How to Publish ASP.NET Core 3.0 Web Apps/APIs in Azure's Linux App Service
Get your application up and running with Azure's Linux App Service.
Join the DZone community and get the full member experience.Join For Free
Create a new App Service Plan. If you have already created then skip this step. An app service is like one container or a VM machine. In a single Azure app service, you can host N number of web apps. Based on load, you can split your apps to separate app services if required.
To create a new app service, you'll first need to set a resource group name; if you already have created it, you can use the same or else can create new. Next, fill the app service name, select Linux as your OS, select a pricing plan based on your needs, and hit create.
Note: Selecting Linux is not necessary. You can use Windows also. But, if Linux supports it why not use it. Linux App services are cheaper than Windows-based app services.
Once the app service plan is created, you'll need to create an App Service. You can search and select app service. App service is nothing but your web app/API. Create a new app under your app service plan. Select run time .Net Core 2.2. At present, .NET Core 3.3 is not listed Azure team is rolling out. But there is a workaround by which you can change to 3.0 that is explained below.
You may also like: Everything You Need to Know to Get Started With Azure Console.
Note: Select the same app service name created in the previous step; otherwise, you will end up creating a new app service plan and will be charged. It will appear in the list once you select a region.
After filling in these details, a next screen will be shown. Review and create your app service.
In a few minutes, the app will be deployed. Click on Go to resource, and you will be redirected to your newly created app.
In your app service, select Configuration tab -> General settings.
Change Version to .Net Core 3.0, which was not available in the previous step and save it.
Next, enable security by going to TLS/SSL Settings — Binding
Set HTTPS only — ON and save it.
Next, go to Configuration -> Application Settings.
Add some setting as shown below
WEBSITE_DYNAMIC_CACHE — 0
WEBSITE_LOCAL_CACHE_OPTION- Never (For staging enable this else app will be cached and will not refresh on publishing)
WEBSITE_WEBDEPLOY_USE_SCM — false (Set false else you will not able to use VS to publish directly)
Next, download the publish profile. Now, that the configuration for Azure is done, we can publish directly from Visual Studio. This process is explained below.
Open your web app in Visual Studio — 2019. Select Build → Publish.
Next, the Publish screen will open. Click on import and browse the publish file that we downloaded in the second to last step.
On importing the file, two settings will be generated: one for web deploy and other for FTP. You can select Web deploy. Finally, click Publish, and the site will be published to Azure.
Before publishing, click on edit and check the option, Remove additional files at the destination. Otherwise, the default Azure site will show up in Azure.
Go to Azure and restart the app service. Sometimes, it won't auto-refresh on publishing, so we need to manually restart.
Next, click on the Site URL. Now, the site is hosted.
Note: You can also configure FTP for publishing, Custom domain can also be mapped in case you don't need default Azure site URL. Firewall can be configured, and logging can be enabled. Azure also provides application insights, performance testing, etc.
Azure also supports Staging and Production slots in the higher plan using that you can first publish in staging slot and can swap to production slot after testing within seconds with almost no downtime.
There is a traffic manager inbuilt using which Azure can load balance your site.
Detailed reference can refer here:
Pricing — https://azure.microsoft.com/en-in/pricing/details/app-service/windows/.
Documentation — https://docs.microsoft.com/en-us/azure/app-service/.
Published at DZone with permission of Bharat Dwarkani. See the original article here.
Opinions expressed by DZone contributors are their own.