Deploying Cloud Services with TeamCity and Octopus Deploy

What are we doing?

  1. You’re using Azure Cloud Services and you have a service setup. This can be done via powershell or the portal. You don’t need to have deployed into it, but it needs to be waiting for you.
  2. You are using TeamCity.
  3. You are using Octopus Deploy.
  4. You’re using NUnit for your tests. This is the step I’ll show here but you can insert your own test runner steps. (You are unit testing this, right?)

Setting the project up

<?xml version="1.0"?>
<package xmlns=""> <metadata>
<id>[Package ID]</id>
<description>Cloud Service Package</description>
<file src="..\bin\Release\app.publish\*.*" target="" />


  1. Setup a project.
  2. Add a build configuration for this deployment.
  3. Attach your repository settings and any triggers you want.
  1. I set my “targets” to “rebuild”.
  2. I set my “configuration” to “release”. This is your transforms.
  3. Finally I set “command line parameters” to “/p:TargetProfile=Cloud /p:Configuration=Release”. Similar to configuration but it also passes the cloud service target.
  4. I stare longingly at the octopack option that would make this so much simpler.
  1. I set my “targets” to “publish” as we want to publish the service.
  2. I set the “command line parameters” to “/t:Publish /p:TargetProfile=Cloud /p:Configuration=Release /p:PublishDir=bin\Release\app.publish\”
  3. Again, I stare longingly at the octopack option that would make this so much simpler.
  1. Specify your nuspec file. This is the one we created earlier in the deployment folder.
  2. Give it a version number. We do something clever with automatic versioning but you can put your version variable in here until I get around to writing that process up!
  3. Set your output folder. This is going to depend on how your going to publish the nuget file. I set mine to “Build/packages” because I’ve set “Artifact paths” to “Build/packages/** =>” in General Settings. If you have nuget enabled for TeamCity then this will put your packages in that feed.
  4. Finally in “Properties” I set “Configuration=Release”.


  1. Select your machine roles. For Azure deploys I just install a tentacle on the same machine as the server and give it a role named “Azure”.
  2. Select your package. You need to have configured the feed inside octopus. If you have it’ll give you some help by listing the different packages.
  3. “Subscription id” is pretty self explanatory, you get this from your Azure subscription portal.
  4. “Cloud service” is the name of your cloud service you created in the portal earlier.
  5. “Storage account” this is where octopus is going to upload your nuget package before deploying it into the cloud service.
  6. Follow the instructions for adding the certificate if this is your first time.
  7. Finally you get to configure the slot you want to deploy into. Here I’ve just got “production” at the moment.
  8. Instance count is interesting, you can choose wether to ignore the scaling configuration in your project if Azure has already scaled your service further. This make most sense for deploying over the top of a service, you wouldn’t want to be under heavy load and have the service kill lots of instances.
  9. Select your environment and save.

Back to TeamCity

  1. The project name you noted down when creating it in octopus to “Project”.
  2. Your release number to “Release number”, this is probably similar to your build number before.
  3. Your environment name depending where your deploying. Mine is “production”.
  4. You can pass extra command line parameters. I send my package number as I don’t always just want the latest: “ — packageversion %Major.Minor.Build%.%build.number%”.




Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ben Gale

Ben Gale

More from Medium

Creating a Linux Virtual Machine Compute Engine in Google Cloud Platform

IAC with Google Cloud Functions

Elegy to Cloud Monitoring

Connect 2 VPC using Route-based VPN in GCP