Azure Web App Deployment

This page documents deployments using the next major version dpl v2 which currently is in a beta release phase. Please see our blog post for details. The current default version is dpl v1. Check dpl v1 documentation here.

Travis CI can automatically deploy your Azure Web App after a successful build.

For a minimal configuration, add the following to your .travis.yml:

deploy:
  provider: azure_web_apps
  username: <username>
  password: <encrypted password>
  site: <site>
  edge: true # opt in to dpl v2

Status #

Support for deployments to Azure Web Apps is in alpha. Please see Maturity Levels for details.

Known options #

Use the following options to further configure the deployment.

username Web App Deployment Username — required, type: string
password Web App Deployment Password — required, secret, type: string
site Web App name (e.g. myapp in myapp.azurewebsites.net) — required, type: string
slot Slot name (if your app uses staging deployment) — type: string
verbose Print deployment output from Azure. Warning: If authentication fails, Git prints credentials in clear text. Correct credentials remain hidden. — type: boolean

Shared options #

cleanup Clean up build artifacts from the Git working directory before the deployment — type: boolean
run Commands to execute after the deployment finished successfully — type: string or array of strings

Environment variables #

All options can be given as environment variables if prefixed with AZURE_WA_.

For example, password can be given as AZURE_WA_PASSWORD=<password>.

Securing secrets #

Secret option values should be given as either encrypted strings in your build configuration (.travis.yml file) or environment variables in your repository settings.

Environment variables can be set on the settings page of your repository, or using travis env set:

travis env set AZURE_WA_PASSWORD <password>

In order to encrypt option values when adding them to your .travis.yml file use travis encrypt:

travis encrypt <password>

Or use --add to directly add it to your .travis.yml file. Note that this command has to be run in your repository’s root directory:

travis encrypt --add deploy.password <password>

Fetching Deployment Progress and Logs #

The Azure Web App provider can print Azure’s deployment progress to your Travis log using the verbose option.

However, Git will print your password if the authentication fails (it will not if you provide a correct user/password combination).

deploy:
  provider: azure_web_apps
  # ⋮
  verbose: true

Note on .gitignore #

As this deployment strategy relies on Git, be mindful that the deployment will honor .gitignore.

If your .gitignore file matches something that your build creates, use before_deploy to change its content.

Deploying to slots #

You might need to deploy multiple branches to different slots. You can set multiple providers to deploy to specific slots. The following configuration would deploy the master branch to the myapp-staging slot and the develop branch to the myapp-develop slot. In order to use slots you’ll need to set up staging environments for web apps in Azure App Service.

deploy:
- provider: azure_web_apps
  # ⋮
  slot: myapp-staging
  on:
    branch: master
- provider: azure_web_apps
  # ⋮
  slot: myapp-dev
  on:
    branch: dev

Pull Requests #

Note that pull request builds skip the deployment step altogether.

See also #