Summary: In this post I'll create an Azure VM with Visual Studio Community installed, and use that to generate a sample .Net Core application so we can test builds and deployments with Azure DevOps.
Date: Around 2021
Refactor: 21 February 2025: Checked links and formatting.
Note: Bastion is expensive, disable and recreate the Bastion service every time you need it.
From the links below download and install Edge Chromium (optional) and Visual Studio Community. During the installation of Visual Studio make sure to install the “ASP.NET and web development” workload. After the installation, Visual Studio starts, and asks to sign in, which you can also skip.
Note that during the installation you have plenty of time, so continue with the configuration of Azure DevOps and repository below
In your Azure DevOps Organization create a new project:
https://getshiftingcom@dev.azure.com/getshiftingcom/az400/_git/DotNetCoreSampleApp
In the newly installed Visual Studio, click “Create a new project”
Once the project is created, go to Git and click Create Git Repository
Note that you might have to commit the new files to the repository before they get pushed to azure devops.
Now the files are in Azure DevOps we can create a build. From the repository you can directly click “Set up build”. This will already setup the build to use the repository from where you are, so you can start with configuring the pipeline immediately. Select the ASP.NET Core pipeline, which will automatically create a YAML pipeline
# ASP.NET Core (.NET Framework) # Build and test ASP.NET Core projects targeting the full .NET Framework. # Add steps that publish symbols, save build artifacts, and more: # https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core trigger: - master pool: vmImage: 'windows-latest' variables: solution: '**/*.sln' buildPlatform: 'Any CPU' buildConfiguration: 'Release' steps: - task: NuGetToolInstaller@1 - task: NuGetCommand@2 inputs: restoreSolution: '$(solution)' - task: VSBuild@1 inputs: solution: '$(solution)' msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"' platform: '$(buildPlatform)' configuration: '$(buildConfiguration)' - task: PublishBuildArtifacts@1 inputs: PathtoPublish: '$(Build.ArtifactStagingDirectory)' ArtifactName: 'drop' publishLocation: 'Container'
To deploy the web app we need to have an Azure Web App.
Note that if you'd go to the Web App website, in this case, https://az400.azurewebsites.net/ , you'll now see the default deployment page telling you to upload you code.
Now that we have a successful build and an Azure Web App we can deploy the web application to Azure. In Azure DevOps, go to Releases and click “New Pipeline”
Once the release is finished you can go to the url of the web app, https://az400.azurewebsites.net/ , and see your .net web application running.
Resources: