Download Microsoft Azure Cloud Service Package files

Jared Johnson, 10 November 2014

With an existing Cloud Service in Microsoft Azure there may be times where you want to take a backup of the current Service or to deploy a copy to another Azure subscription, but you do not have access to the original package used to create the Service. Luckily there is a way to retrieve the package using the Service Management REST API.

The call used to download the package is the Get Package endpoint. When called it will download the deployment package into the provided Azure storage container. This is called using a POST request, using this URL structure:

https://management.core.windows.net/<subscription-id>/services/hostedservices/<cloudservice-name>/deployments/<deployment-name>/package

In this call we have 4 parameters that we need to include in the URL, they are subscription ID, the name of the cloudservice, the deployment name and the URI of the storage container.

The first 3 parameters can all be found on the dashboard tab of the Cloud Service. Subscription ID and the deployment name are both found in the quick glance section, while the deployment name is found at the top of the page.

Download Microsoft Azure Cloud Service Package files

The container URI can be found from the Containers tab of a Storage account, in the URL column. If there is no container for the account one must be created for the package to be downloaded into.

Download Microsoft Azure Cloud Service Package files

The Container URI is added to the end of the URL as a query string, with all the parameters inputted the URL now looks like this:

https://management.core.windows.net/s0000000-u000-b000-i000-d00000000000/services/hostedservices/fakewebsite/deployments/d0000000-e000-p000-l000-y00000000000/package?containerUri=https://fakestorage.blob.core.windows.net/fakecontainer

Also needed for this request are 2 request headers. These are: x-ms-version, with a version number of 2012-03-01 or higher, and ContentLength which must be set to 0.

For this example I am going to make this request using Fiddler, the URL and request headers are added as shown. When executed if this is successful a 202 response will be returned.

Download Microsoft Azure Cloud Service Package files

Now if we open our container, we can see the package files have now appeared. We can then use the URL’s provided to download the package.

Download Microsoft Azure Cloud Service Package files