This post is about how to deploy an ASP.NET Core web application in Azure Virtual machines. This is part of series where we will be discussing about setting up web server, configuring custom domains, creating and installing SSL certificate in web server and finally configuring CI / CD pipelines to deploy our application to Azure VM from Azure DevOps. In this blog post we will be exploring about creating a Virtual Machine in Azure, how to configure IIS web server and deploy an ASP.NET Core application to the virtual machine.
We will be using Azure CLI to create and configure the server.
- First we need to login to Azure account using Azure CLI. We can use the
az logincommand to access out Azure account.
- Once logged, we can execute the following command to create a resource group -
az group create --name webserver-us --location centralus
- Next we can create the Azure virtual machine with the command -
az vm create --resource-group webserver-us --name dotnetthoughts --image Win2022AzureEditionCore --public-ip-sku Basic --admin-username azurewebuser. If we execute this command, it will prompt for the admin password. Or we can use
--admin-passwordparameter to accept the admin password. This might take some time.
- After the VM is created, we can use the following command to install IIS web server on the virtual machine -
az vm run-command invoke --resource-group webserver-us --name dotnetthoughts --command-id RunPowerShellScript --scripts "Install-WindowsFeature -name Web-Server -IncludeManagementTools".
- And we need to enable port 80 - for IIS web server. We can do this with the following command -
az vm open-port --port 80 --resource-group webserver-us --name dotnetthoughts.
- Now we created and configured web server. To browse we can get the IP address with the following command -
az vm list-ip-addresses --resource-group webserver-us --name dotnetthoughts --output table
- And we can copy the
PublicIPAddressescolumn and paste it on the browser - which will show the IIS default page, like this.
In the next post we will be configuring a custom domain for the Azure virtual machine.