Deploy .NET Core 2.2 applications with Bitbucket Pipelines to Azure App Services

Simple and quick example on how to deploy a .NET Core application with Bitbucket Pipelines to Azure App Services.

Create a deployment user

Select the Cloud Shell button on the top-right menu bar in the Azure portal.

Open Azure Cloud Shell

Azure Cloud Shell requires an Azure file share. If you don’t have one you will be asked to create one in the next step.

Create Azure file share

This can take a while. After the successful creation of the Azure file share we are able to use the Azure Cloud Shell.

Azure Cloud Shell

Create a new deployment user with <username> and <password>

az webapp deployment user set --user-name <username> --password '<password>'

Get GIT Deployment Repository

Go Advanced Tools in your Azure Service App:

App Service Advanced Tools

Then click on Source control Info to see your GIT Repository URL.

Git Source Control Info

The Azure App Service GIT URL, the Deployment Username and Password will be used to deploy from Bitbucket Pipelines to Azure App Service.

Configure Bitbucket Pipelines for Azure Git Deployments

Go to the Repository Settings and store the Deployment Username and Password as Repository variables in the Pipelines Section.

Credentials in Bitbucket Repository Variables

Using git push to Azure App Service in bitbucket-pipelines.yml:

image: microsoft/dotnet:sdk

    - step:
          - dotnetcore
          - export SOLUTION_NAME=<SolutionName>
          - dotnet restore $SOLUTION_NAME
          - dotnet build $SOLUTION_NAME
          - git push --force https://${DEPLOYMENT_USERNAME}:${DEPLOYMENT_PASSWORD}@<azure-app-service-git-repository> HEAD:refs/heads/master

Leave a Reply

Your email address will not be published. Required fields are marked *