Deploy On Azure

Posted onby

Azure DevOps Services | Azure DevOps Server 2020 | Azure DevOps Server 2019 | TFS 2018

Microsoft Azure Tutorial.

Microsoft Azure Advanced. Microsoft Azure Useful Resources. Selected Reading. In this chapter, we will discuss different ways of deploying an application on Windows Azure. When we say application, it can be a web application or a mobile application.

Use Azure Pipelines to automatically deploy your web app to Azure App Service on every successful build. Azure Pipelines lets you build, test, and deploy with continuous integration (CI) and continuous delivery (CD) using Azure DevOps.

YAML pipelines are defined using a YAML file in your repository. A step is the smallest building block of a pipeline and can be a script or task (pre-packaged script). Learn about the key concepts and components that make up a pipeline.

You'll use the Azure Web App task to deploy to Azure App Service in your pipeline. For more complicated scenarios such as needing to use XML parameters in your deploy, you can use the Azure App Service Deploy task.

To learn how to deploy to an Azure Web App for Linux Containers, see Deploy an Azure Web App Container.


  • Earlier web apps were called websites, but now everywhere they are referred as web applications.

Make sure you have the following items:

  • We will be discussing how to deploy applications from Visual Studio and management portal in the chapter ‘Websites’.

  • To get started with the PowerShell, refer to ‘PowerShell’ chapter in the tutorial. In order to deploy a website from PowerShell you will need the deployment package.

  • You can get this from your website developers or you if you are into web deployment you would know about creating a deployment package.

Create an Azure App Service in the Azure portal

Create an Azure App Service on Linux or Windows with Azure Cloud Shell. To get started:

  1. In the following sections, first you will learn how to create a deployment package in Visual Studio and then using PowerShell cmdlets, you will deploy the package on Azure.
  2. Step 1 − Go to your website in Visual Studio. Step 2 − Right-click on the name of the application in the solution explorer.

For more information, see Overview of Azure Cloud Shell.

Select ‘Publish’. Step 3 − Create a new profile by selecting ‘New Profile’ from the dropdown.

Build your app with Azure Pipelines

Useful Video Courses

Step 4 − On the next screen, choose ‘Web Deploy Package’ in Publish Method. Step 5 − Choose a path to store the deployment package. Enter the name of site and click Next.

Step 6 − On the next screen, leave the defaults on and select ‘publish’.

After it’s done, inside the folder in your chosen location, you will find a zip file which is what you need during deployment.

Deploy Website using Deployment Package

Step 1 − Enter the following cmdlets to create a website.

  • Replace the highlighted part.
  • This command is going to create a website in free subscription.

Deploying a Web App from PowerShell

  1. You can change the subscription after the website is created.

  2. If cmdlet is successful, you will see all the information as shown in the above image.

  3. You can see the URL of your website as in this example it is

  4. Step 2 − You can visit the URL to make sure everything has gone right.

  5. Once the website is created in Azure, you just need to copy your website’s code.

  6. Create the zip folder (deployment package) in your local computer. Step 1 − Enter the following cmdlets to deploy your website.

  7. Here in above commandlet, the name of the website just created is given and the path of the zip file on the computer.

  8. Step 2 − Go to your website’s URL. You can see the website as shown in the following image. 16 Lectures 11.5 hours .

Create a Website in Azure using PowerShell

  1. SHIVPRASAD KOIRALA. 33 Lectures 3 hours .

  2. Abhishek And Pukhraj. 33 Lectures 5.5 hours . Abhishek And Pukhraj. 40 Lectures 6.5 hours . 15 Lectures 2 hours .

  3. Harshit Srivastava, Pranjal Srivastava. 18 Lectures 1.5 hours . Pranjal Srivastava, Harshit Srivastava. Kudu endpoints: Kudu is the open-source developer productivity tool that runs as a separate process in Windows App Service, and as a second container in Linux App Service.

    • Kudu handles continuous deployments and provides HTTP endpoints for deployment, such as zipdeploy.
    • FTP and WebDeploy: Using your site or user credentials, you can upload files via FTP or WebDeploy.
    • These mechanisms do not go through Kudu. Build and tag the image. As part of the build pipeline, tag the image with the git commit ID, timestamp, or other identifiable information.

It’s best not to use the default “latest” tag. Otherwise, it’s difficult to trace back what code is currently deployed, which makes debugging far more difficult. Push the tagged image. Once the image is built and tagged, the pipeline pushes the image to our container registry.

Now you're ready to read through the rest of this topic to learn some of the more common changes that people make to customize an Azure Web App deployment.

Use the Azure Web App task

If you plan to publish your cloud service from Azure DevOps, use Quick Create, and then set up Azure DevOps publishing from the Azure Quickstart or the dashboard.

Create a Deployment Package

For more information, see Continuous Delivery to Azure by Using Azure DevOps, or see help for the Quick Start page. Service DefinitionThe cloud service definition file (.csdef) defines the service model, including the number of roles.

  • Service ConfigurationThe cloud service configuration file (.cscfg) provides configuration settings for the cloud service and individual roles, including the number of role instances.
  • Service PackageThe service package (.cspkg) contains the application code and configurations and the service definition file.
  • If you want to deploy a cloud service that uses Transport Layer Security (TLS), previously known as Secure Sockets Layer (SSL), for data encryption, configure your application for TLS.

If you want to configure Remote Desktop connections to role instances, configure the roles for Remote Desktop. If you want to configure verbose monitoring for your cloud service, enable Azure Diagnostics for the cloud service.

Minimal monitoring (the default monitoring level) uses performance counters gathered from the host operating systems for role instances (virtual machines).

Deploy a .NET app

Verbose monitoring gathers additional metrics based on performance data within the role instances to enable closer analysis of issues that occur during application processing.

  • To find out how to enable Azure Diagnostics, see Enabling diagnostics in Azure.
  • If you haven't installed the Azure SDK, click Install Azure SDK to open the Azure Downloads page, and then download the SDK for the language in which you prefer to develop your code.
  • (You'll have an opportunity to do this later.).
  • If any role instances require a certificate, create the certificates. Cloud services require a .pfx file with a private key.

Deploy a JavaScript Node.js app

You can upload the certificates to Azure as you create and deploy the cloud service. Log in to the Azure portal. Click Create a resource > Compute, and then scroll down to and click Cloud Service. In the new Cloud Service pane, enter a value for the DNS name.

  • Create a new Resource Group or select an existing one.
  • Select a Location. This opens the Upload a package pane.
  • Fill in the required fields. If any of your roles contain a single instance, ensure Deploy even if one or more roles contain a single instance is selected.
  • Make sure that Start deployment is selected. Click OK which will close the Upload a package pane. If you do not have any certificates to add, click Create. Select Certificates, and on the Add certificates pane, select the TLS/SSL certificate .pfx file, and then provide the Password for the certificate,.

Click Attach certificate, and then click OK on the Add certificates pane.

Use a service connection

To deploy to Azure App Service, you'll need to use an Azure Resource Manager service connection. The Azure service connection stores the credentials to connect from Azure Pipelines or Azure DevOps Server to Azure.

Learn more about Azure Resource Manager service connections. If your service connection is not working as expected, see Troubleshooting service connections.

Learn how to configure release pipelines that continuously build, test, and deploy your applications. This learning path is part of a series. You can choose the topics you're most interested in or progress through each of them.

Deploy to a virtual application

Choose and implement an appropriate deployment pattern to smoothly roll out new features to your users. Extend pipelines to add support for different deployment targets, such as Azure Functions.

  • Automate Docker and multi-container Kubernetes deployments with Azure Pipelines.

Deploy to a slot

You can configure the Azure Web App to have multiple slots. Slots allow you to safely deploy your app and test it before making it available to your customers.

The following example shows how to deploy to a staging slot, and then swap to a production slot:

  • azureSubscription: your Azure subscription.
  • appType: (optional) Use webAppLinux to deploy to a Web App on Linux.
  • appName: the name of your existing app service.
  • deployToSlotOrASE: Boolean. Deploy to an existing deployment slot or Azure App Service Environment.
  • resourceGroupName: Name of the resource group. Required if deployToSlotOrASE is true.
  • slotName: Name of the slot, defaults to production. Required if deployToSlotOrASE is true.
  • SourceSlot: Slot sent to production when SwapWithProduction is true.
  • SwapWithProduction: Boolean. Swap the traffic of source slot with production.

Deploy to multiple web apps

You can use jobs in your YAML file to set up a pipeline of deployments.By using jobs, you can control the order of deployment to multiple web apps.

Configuration changes

For most language stacks, app settings and connection strings can be set as environment variables at runtime.App settings can also be resolved from Key Vault using Key Vault references.

For ASP.NET and ASP.NET Core developers, setting app settings in App Service are like setting them in in Web.config.You might want to apply a specific configuration for your web app target before deploying to it.This is useful when you deploy the same build to multiple web apps in a pipeline.For example, if your Web.config file contains a connection string named connectionString,you can change its value before deploying to each web app. You can do this either by applyinga Web.config transformation or by substituting variables in your Web.config file.

Azure App Service Deploy task allows users to modify configuration settings in configuration files (*.config files) inside web packages and XML parameters files (parameters.xml), based on the stage name specified.


File transforms and variable substitution are also supported by the separate File Transform task for use in Azure Pipelines.You can use the File Transform task to apply file transformations and variable substitutions on any configuration and parameters files.

The following snippet shows an example of variable substitution:

Deploying conditionally

You can choose to deploy only certain builds to your Azure Web App.

To do this in YAML, you can use one of these techniques:

  • Isolate the deployment steps into a separate job, and add a condition to that job.
  • Add a condition to the step.

The following example shows how to use step conditions to deploy only builds that originate from the main branch:

To learn more about conditions, see Specify conditions.

(Classic) Deploy with a release pipeline

You can use a release pipeline to pick up the artifacts published by your build and then deploy them to your Azure web site.

  1. Do one of the following to start creating a release pipeline:

    • If you've just completed a CI build, choose the link (for example, Build 20170815.1)to open the build summary. Then choose Release to start a new release pipeline that's automatically linked to the build pipeline.

    • Open the Releases tab in Azure Pipelines, open the + drop-downin the list of release pipelines, and choose Create release pipeline.

  2. The easiest way to create a release pipeline is to use a template. If you are deploying a Node.js app, select the Deploy Node.js App to Azure App Service template.Otherwise, select the Azure App Service Deployment template. Then choose Apply.


    The only difference between these templates is that Node.js template configures the task to generate a web.config file containing a parameter that starts the iisnode service.

  3. If you created your new release pipeline from a build summary, check that the build pipeline and artifactis shown in the Artifacts section on the Pipeline tab. If you created a new release pipeline fromthe Releases tab, choose the + Add link and select your build artifact.

  4. Choose the Continuous deployment icon in the Artifacts section, check that thecontinuous deployment trigger is enabled, and add a filter to include the main branch.


    Continuous deployment is not enabled by default when you create a new release pipeline from the Releases tab.

  5. Open the Tasks tab and, with Stage 1 selected, configure the task property variables as follows:

    • Azure Subscription: Select a connection from the list under Available Azure Service Connections or create a more restricted permissions connection to your Azure subscription.If you are using Azure Pipelines and if you see an Authorize button next to the input, click on it to authorize Azure Pipelines to connect to your Azure subscription. If you are using TFS or if you do not seethe desired Azure subscription in the list of subscriptions, see Azure Resource Manager service connection to manually set up the connection.

    • App Service Name: Select the name of the web app from your subscription.


    Some settings for the tasks may have been automatically defined asstage variableswhen you created a release pipeline from a template.These settings cannot be modified in the task settings; instead you mustselect the parent stage item in order to edit these settings.

  6. Save the release pipeline.

Create a release to deploy your app

You're now ready to create a release, which means to run the release pipeline with the artifacts produced by a specific build. This will result in deploying the build:

  1. Choose + Release and select Create a release.

  2. In the Create a new release panel, check that the artifact version you want to use is selected and choose Create.

  3. Choose the release link in the information bar message. For example: "Release Release-1 has been created".

  4. In the pipeline view, choose the status link in the stages of the pipeline to see the logs and agent output.

  5. After the release is complete, navigate to your site running in Azure using the Web App URL http://{web_app_name}, and verify its contents.

Deploy to an Azure Government cloud or to Azure Stack

Create a suitable service connection:

Deployment mechanisms

The preceding examples rely on the built-in Azure Web App task,which provides simplified integration with Azure.

If you use a Windows agent, this task uses Web Deploy technology to interact with the Azure Web App.Web Deploy provides several convenient deployment options, such as renaming locked files and excluding files from the App_Data folder during deployment.

If you use the Linux agent, the task relies on the Kudu REST APIs.

One thing worth checking before deploying is the Azure App Service access restrictions list. This list can include IP addresses or Azure Virtual Network subnets. When there are one or more entries, there is then an implicit "deny all" that exists at the end of the list. To modify the access restriction rules to your app, see Adding and editing access restriction rules in Azure portal.You can also modify/restrict access to your source control management (scm) site.

The Azure App Service Manage task is another task that's useful for deployment.You can use this task to start, stop, or restart the web app before or after deployment.You can also use this task to swap slots, install site extensions, or enable monitoring of the web app.

You can use the File Transform task to apply file transformations and variable substitutions on any configuration and parameters files.

If the built-in tasks don't meet your needs, you can use other methods to script your deployment.View the YAML snippets in each of the following tasks for some examples: