Octopus Deploy with Azure Germany



At HQLabs, we have been using a Continuous Integration process for more than a year now and it has become an integral part of our development and release process. We are using Atlassian Bamboo as our build server and Octopus Deploy for deployment, where we have environments set up for our Azure-hosted systems as well as on-premise installations of our customers.

Since Azure Germany has special API endpoints that differ from the global ones, App Service (Web App) deployment with Octopus is not possible out-of-the-box yet. However, the deployment part of Octopus, Calamari, already allows to specify custom endpoints and therefore deploy Azure Web Apps hosted in Germany (or any other non-global Azure region).

Here is what you need to do to automate deployments to an Azure Web App in Germany with Octopus Deploy:

1. Create a Service Principal in Azure

Follow the steps in the Octopus docs on creating a Service Principal in Azure and adding an Account to Octopus. Those are the same in Azure Germany as in any Azure region. You don’t need to use PowerShell, these steps are possible in the Azure Portal already. When you’re done, your Account in Octopus should look like this:

Azure Germany Octopus Account


Normally, Octopus would validate the credentials, which fails in Azure Germany due to the different endpoints. But you can save the Account even without validation.

2. Add the Azure Germany endpoints to your Octopus Project

Now you need to add the Azure Germany specific API endpoints to your deployment project so that Calamari knows where to deploy to. These are the API endpoints for Germany:

Octopus.Action.Azure.ActiveDirectoryEndPoint: https://login.microsoftonline.de
Octopus.Action.Azure.Environment: AzureGermanCloud
Octopus.Action.Azure.ServiceManagementEndPoint: https://management.microsoftazure.de/

Make sure to type them exactly as specified since the final slash makes a difference when authenticating with the Azure API!

Also, you need to specify the Azure Account that your project should use, the one you specified in step 1. The value is azureserviceprincipal- followed by the name of the Account where you need to replace spaces with dashes. And finally, you need to tell Octopus which Web App you want to deploy to, which can depend on the environment that you’re deploying to. In the following example, we have several deployment slots of a Web App, staging and develop, as well as the production slot. Which variable is used depends on the Octopus environment selected during deployment.

Octopus Azure Germany Variables

3. Add an Azure Web App deployment step

In your deployment project under process, create a new deployment step and select “Deploy an Azure Web App“. You can follow the instructions in the Octopus docs here since they are similar. The only difference is the Account, which you can’t select from the dropdown menu. Instead, select “Use a custom expression” and enter the variable #{AzureAccount} that points to the Account created in step 1. Octopus will take the value from the variables automatically during deploy.

Octopus New Deployment Step

Next, let Octopus know which Azure Resource Group your Web App is located in and use the #{AzureWebApp} variable as the Azure Web App name in the deployment step. All other settings are optional and you can adjust them to your liking.

And example deployment step looks like this:

Octopus Sample Deployment Step

4. Build and update Calamari

Calamari is the deployment executable developed and used by Octopus Deploy. It is open source on GitHub. The current release version of Calamari does not support deployment to Azure Germany yet, but a branch contains the enhancement I published recently. You can easily build Calamari from the source and use it instead of the shipped Calamari until the next version ships with Octopus Deploy.

Trust me, it is really easy!

  1. To do so, clone the project in the enh-azureWebNonGlobal branch first.
  2. I also had to comment out the Unit Tests “DotNetCoreTest” in line 131 of the build.cake file in the root folder.
  3. Next, run the build scriptbuild.cmd” from the command prompt and wait for the Calamari package to be created in the “built-packages” folder (Calamari.0.0.0.nupkg and Calamari.Azure.0.0.0.nupkg).
  4. Copy the file to your Octopus server into the directory “C:\Program Files\Octopus Deploy\Octopus\customCalamari“.
  5. Stop Octopus server.
  6. Open a command prompt in the Octopus install directory and execute the following command: “Octopus.Server.exe configure –customBundledPackageDirectory “C:\Program Files\Octopus Deploy\Octopus\customCalamari” –nologo –console“. This tells Octopus Deploy to use your custom Calamari package for deploy instead of the built-in one. The GitHub readme contains more details about setting and reverting custom Calamari.
  7. Restart Octopus server.

5. Deploy and enjoy

Now you should be able to deploy to an Azure Web App in Germany. Even though it is currently a little hacky, it works perfectly for us.

Try it out and let me know if it worked for you or if you are experiencing any problems.


Get Angularity updates



Schreibe einen Kommentar!

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