In this post, I’m going to explain how to create a pipeline and a release in Azure DevOps that releases into AppServices. This is quite important step to go forward a digital transformation in your company to improve and optimize the developer’s process.
In the pipeline
Azure DevOps builds the solution (projects and tests) and create an artifact
. Then, with the release
, it publishes the artifact
into to a AppService in Azure. Now I show step by step how to create both.
Table of contents
Pipeline
First, you have to create a New pipeline and then select where your code is. If you select one of the elements in the list, Azure DevOps will create an YAML
file. This wizard is not suitable for me; then I want to “Use the classic editor
”
![Azure DevOps - Where is your code?](https://i0.wp.com/puresourcecode.com/wp-content/uploads/2020/10/image-14.png?resize=640%2C465&ssl=1)
After this choice, I have to select my repository. My repository is in Azure Repos Git
and then some fields are already prepopulated.
![Azure DevOps - Select your repository](https://i0.wp.com/puresourcecode.com/wp-content/uploads/2020/10/image-15.png?resize=640%2C393&ssl=1)
In this step I have to select:
- Team project
- Repository
- Default branch for manual and scheduled builds
If you want to implement Git Flow branches for your deployment, please read the post I created about it.
![Azure DevOps - Choose a template](https://i0.wp.com/puresourcecode.com/wp-content/uploads/2020/10/image-16.png?resize=640%2C393&ssl=1)
Then, I have to choose a template: I search and add ASP.NET Core
. Now, I have to add 4 steps before publishing the artifact.
dotnet restore
Restore the Nuget packages for the solution. In the Path to project(s)
I explicitly say what project I want to build.
**/MyProject.csproj
**/MyProject.Tests.csproj
![Pipeline - dotnet restore](https://i0.wp.com/puresourcecode.com/wp-content/uploads/2020/10/image-7.png?resize=640%2C579&ssl=1)
dotnet test
Run the tests for the solution, if there are exists.
![Pipeline - dotnet test](https://i0.wp.com/puresourcecode.com/wp-content/uploads/2020/10/image-8.png?resize=640%2C579&ssl=1)
dotnet build
This step is building all projects. Add in Path to project(s)
:
**/*.csproj
![Pipeline - dotnet build](https://i0.wp.com/puresourcecode.com/wp-content/uploads/2020/10/image-9.png?resize=640%2C579&ssl=1)
dotnet publish
Publish the compiled project(s) in a zip file in a particular directory, so, I can read it later. For that, add in Arguments
this text:
-o $(Build.ArtifactStagingDirectory)
![Pipeline - dotnet publish](https://i0.wp.com/puresourcecode.com/wp-content/uploads/2020/10/image-10.png?resize=640%2C579&ssl=1)
Publish Artifact: drop
Finally, I publish the artifact from a specific directory in Path to publish
:
$(Build.ArtifactStagingDirectory)
Also, check:
- Publish web projects
- Zip published projects
![Pipeline - Publish Artifact: drop](https://i0.wp.com/puresourcecode.com/wp-content/uploads/2020/10/image-11.png?resize=640%2C579&ssl=1)
Release
The release takes the artifact and publish it in an Azure AppService
. First, select from where it has to take the artifact and remember to enable the continuous deployment.
![Release - Artifacts](https://i0.wp.com/puresourcecode.com/wp-content/uploads/2020/10/image-12.png?resize=640%2C579&ssl=1)
![Azure DevOps Release - Enable Continuous deployment](https://i0.wp.com/puresourcecode.com/wp-content/uploads/2020/10/image-17.png?resize=640%2C393&ssl=1)
![Release - Tasks](https://i0.wp.com/puresourcecode.com/wp-content/uploads/2020/10/image-13.png?resize=640%2C579&ssl=1)
Change the Package or folder
in $(System.DefaultWorkingDirectory)/*/.zip
Conclusion
So, in this short post I explained how to create a process in Azure DevOps to release AppServices.
2 thoughts on “Azure DevOps releases AppServices”