Creating and publishing Blazor Hosted to Azure — .Net Framework 5
All code is available at https://github.com/gislig/BlazorAzure free of charge.
First, we need to create a Blazor server, I will do this in the command line in the terminal on MacBook. You need to be in a directory where your project will be located, when you are there then you can do the following command:
dotnet new blazorwasm --hosted -o BlazorAzure
Now you have created the Blazor hosted, that will include client, server and shared. You can open it in Visual Studio Code or Visual Studio for Mac. Now to test this you will need to enter the BlazorAzure/Server directory and from there you can run the following command:
dotnet watch run
Now the watch command allows you to change the website without restarting the server. When the server is started, you can then view the webpage.
Now you have created the application you can deploy to Azure, with that you need an Azure tenant and a subscription that you can use to run the application. You can do this with the following stepls:
- Create an App Service
- Create a Resource Group
- Create a pricing Tier
There are few ways to deploy to Azure and I am going to show you the simplest way. I opened Visual Studio and from there I select the server and click on publish to azure
When that is done you have the website up and running. As you can see in the following video that the website url is the url of the Azure. Now you can start developing and deploying your solutions.
Thank you for reading this simple documentation on how to deploy to azure.