July 25, 2023 by Anuraj
Azure IAAS DevOps
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 configuring CI/CD pipelines to deploy the application from Github to Azure VM.
For configuring CI/CD, I will be using GitHub actions.
First we need to create a GitHub action, I choose the .NET template. And removed the testing step - which will restore the nuget packages and build the application. Here is the code.
Also I changed the build agent from Ubuntu to Windows since we are deploying to IIS. Next I added one more step which will deploy the publish output to IIS using Web Deploy.
The IIS web deploy step requires five parameters.
- website-name - Name of the virtual machine DNS name or if custom domain configured, use that.
- msdeploy-service-url - This is the URL which will help Web Deploy app to deploy the changes to the VM. We configured it earlier in the blog post - Deploy a website with Azure virtual machines - Deploying ASP.NET Core application.
- msdeploy-username - Azure VM username.
- msdeploy-password - Azure VM password.
- source-path - Even though the property name is source path, we need to give the path of the Publish folder, we can give it like this -
And I am reading all the properties except
source-path properties from Github action secrets. And here is the updated action file.
Once it is triggered it will build and deploy the application to Azure VM. We can use similar steps in Azure DevOps as well.
Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub