Deploying Your Blazor Application to Azure
Tags: blazor, azure, visualstudio, dotnet
Published: 2020-01-03 04:47:58

_This article is part of series by [Ondrej Polesny](https://dev.to/ondrabus_94) and myself. To catch-up, check out the previous [articles](#other-articles)._

>You've created an amazing, interactive web application using the latest feature of ASP.NET, Blazor, but now what? How do you get it out there to show the world all your hard work? Where do you host it? How do you get it there?

In this article, we'll show you how to deploy your Blazor application to Microsoft's cloud computing service, Azure. We'll also be using Visual Studio 2019 to publish/deploy the application. Visual Studio provides the ability to deploy your application to a folder, IIS, Azure, or other destinations, within the integrated development environment (IDE) reducing the steps it takes to get your application in front of your audience.

#Setting up the environment

Before we can deploy our application, we need to create and configure the environment to hold and serve the application. We'll be using services that fall under the free tier account usage within Azure. To see a list of everything available on the free tier account, go [here](https://azure.microsoft.com/en-us/free/).

##Creating a web application in Azure

Log in to the Azure [portal](https://portal.azure.com).

While in the portal, click on the "+"  symbol on the menu on the left.
![Click on the plus](https://thepracticaldev.s3.amazonaws.com/i/389yci2nz6mh10bnodkq.png)
In the Marketplace, search for "Web App",
![Search for "Web App"](https://thepracticaldev.s3.amazonaws.com/i/8x7dz4m2s7vk4vejj959.png)
and click "Create".
![Click "Create"](https://thepracticaldev.s3.amazonaws.com/i/ztlg2a7z6mozlat6fwzx.png)
On the "Basics" tab, ensure the subscription you wish to use is selected. We'll create a new resource group to contain our app service. A resource group is a collection of resources that share the same lifecycle, permissions and policies. Then provide an instance name for our application. 
![Create web app basics tab](https://thepracticaldev.s3.amazonaws.com/i/nwodszj0od5q3tlr8qxv.png)
Scroll down the page, changing  "Operating System" to "Windows" and "Runtime Stack"to ."NET Core 3.0 (Current)". While .NET Core 3.1 (LTS) was released on December 3, 2019, at the time of this writing, web applications running under Windows on Azure do not currently support the latest version of .NET Core out of the box. Fear not, we can still run the latest version of .NET Core with a little extra configuration. We'll configure this later on in the article.

Leave the remaining options set to their defaults. 

_Note: .NET Core 3.1 (LTS) is available out of the box for Linux operating systems on Azure._
![Create web app basics tab scrolled down](https://thepracticaldev.s3.amazonaws.com/i/0zimttp4lb1w5kalz6ey.png)
Now click "Review + create"

Validate all the options are correct and click "Create". This kicks off the automation process within Azure which creates the web app environment within the selected regional datacenter. This process may take a few minutes depending on the current load within the datacenter.

Once the deployment is complete, click on "Go to resource" to navigate to the newly created resource.
![Deployment completed screen](https://thepracticaldev.s3.amazonaws.com/i/27qdbp2bt3exodn09i9q.png)
##Configuring .NET Core 3.1 (LTS) Support

With our web application created, we can now configure support for .NET Core 3.1 (LTS). While in the web application, navigate to the "Extensions" tab and click "Add" to open the  add extension window. 
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/tgxbmshpbhc66i6a2i5d.png)
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/aszh8fmchjimronmzwsh.png)
Click on "Choose Extension" and select "ASP.NET Core 3.1 (x64) Runtime". 
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/6l09uehblfkja5ql3d0l.png)
Click on "Legal Terms" and click "OK" to accept the terms. 
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/7et2yuumfpv06m0iqar8.png)
Now click on "OK" under the "Add Extension" window.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/pwc3p9cjibgv8kkr4rkc.png)
With the extension now added to our web application, we can run applications requiring .NET Core 3.1 without having to wait for Azure to support it. This same process can also be used when wanting to test new features only available within preview versions of .NET Core, like Blazor Web Assembly.

We have 1 more step to complete before we can publish our Blazor application to Azure: update the configuration to x64. We must do this because we installed the x64 extension for .NET Core 3.1.

Navigate to "Configuration" in the left menu, select the "General" tab and update the "Platform" to "64 bit".
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/ek58x4b749by2dk85stw.png)
##Deploying the Blazor application

With our Azure environment created and configure, we're now ready to deploy the Blazor application to it. The application we're deploying can be downloaded/cloned from here. We'll also grab one other file from our Azure web application service, the publish profile. 

Navigate to "Overview" on the left hand menu and click "Get publish profile".
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/z7w95ks6ncyh9pkq1d7i.png)
The publish profile contains all the information Visual Studio needs (FTP location, credentials) to deploy our application to Azure.

Now, open the Blazor application cloned in the previous step in Visual Studio 2019. Right-click the project "awesome-blazor-app" and click "Publish".
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/xsdsz5882jbtru72finn.png)
Click "Import Profile..." and navigate to the location where you downloaded the publish profile from Azure a couple of steps ago. Select settings file and click import.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/qdz8bicahed8eullipo4.png)
With the publish profile imported, click on "Publish".  This kicks off the Visual Studio publish process, which will build the application in release mode and upon a successful build, will FTP the files to the Azure web application service we created earlier and launch our site in your default browser.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/k5fang8rwsehfeqfb03o.png)
#Summary

In this article, we learned how to create a web application environment within Azure to support a Blazor application and how to publish a Blazor application from Visual Studio to our Azure web application environment. We also learned how to use extensions in Azure to extend support for .NET Core 3.1 (LTS) to our web application. This is great, but it's not very maintainable, especially in a team environment. We'll fix this in an upcoming article where we automate the entire build and release process, removing bottlenecks and deployment silos. 

**Other articles in the series:** <a name="other-articles"></a>
* [#1 What is this Blazor everyone's talking about?](https://dev.to/onyxprime/what-is-this-blazor-everyone-s-talking-about-25mf/)
* [#2 How to Build an Interactive SPA with Blazor](https://dev.to/ondrabus_94/how-to-build-an-interactive-spa-with-blazor-4k8n)
* #3 Extending Interactive Blazor Site with Spatial Functions
* #4 Deploying your Blazor application to Azure
* #5 Automating the build and deploy of your Blazor application to Azure