New Deployment Based On Existing Classic Cloud Service

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Tech Community.

Background: 

 

For some scenarios, customer application source code / package are not available any more for some reason, but another deployment is needed. This is customer responsibility to manage application source code and apply new deployment, but customer cannot apply new deployment without source code. For such situation, we could try below approach as additional help. This blog will wrap up all information needed for you to get the deployment package of an existing cloud service(classic) and then use the deployment package for another Cloud Service(classic) deployment. 

 

Contents: 

  • Step One: Generate a Management Certificate. 
  • Step Two: create a classic storage account. 
  • Step Three: Use the Invoke-RestMethod PowerShell command to call the Get Package API. 

 

 

Step One: Generate a Management Certificate. 

 

 

First of all, we need to have a Management Certificate of our Cloud Service(classic), as the thumbprint of the Management Certificate will be used to call the rest API. 

Usually, Management Certificate allows specific users who authenticates with them to manage the subscription they are associated with, by calling the management API. It’s a different cert with the service certificateYou can check this document for details about the certificates: https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-certs-create#what-are-management-certificates 

 

1. Navigate to the subscription and check your management certificate. 

hailey_ding_0-1635331589631.png

 

 

2. (Optional) Please notice that you would have to be a Co-administrator on the subscription to perform any operations under Management Certificates. You can check your permission here: 

hailey_ding_1-1635331589581.png

 

 

 

If you don’t have the permission to browse or upload the management certs, you can contact your subscription admin and then be added as a co-admin of the subscription. 

 

3. Generate a self-signed certificate using PowerShell: https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-certs-create#powershell  

 

Once you’ve generated the self-signed cert, please make sure you’ve exported the file as a .cert format. Also please make sure that you’ve installed the cert on your local machine. 

My example down below: 

hailey_ding_2-1635331589638.png

 

 4. Upload the cert to your management certificate: https://docs.microsoft.com/en-us/previous-versions/azure/azure-api-management-certs 

hailey_ding_3-1635331589640.png

 

Once you’ve upload the certificate, you would be able to find it in the management certificates list and you can copy the thumbprint to use in the following steps. 

 

 

Step Two: create a classic storage account. 

 

Secondly, we need to have a classic storage account to store the generated package files. Please also make sure that the classic storage account is in the same subscription with your Cloud Service(classic). 

 

1. Navigate to the storage account creation page, then under instance details, click the legacy storage account type. 

hailey_ding_4-1635331589444.png

 

 2. At the page popup, under the instance details, choose classic deployment model. 

hailey_ding_5-1635331589586.png

 

3. Now, you would be at the create classic storage account page, fill out the information and click on create. 

hailey_ding_6-1635331589590.png

 

 

 4. Verify you’ve create a classic storage account as below: 

hailey_ding_7-1635331589453.png

 

 

5. Go to the storage account and create a container, then copy the container URL:  https://haileyclassicstorage.blob.core.windows.net/testcontainer 

hailey_ding_8-1635331589457.png

 

 

Step Three: Use the Invoke-RestMethod PowerShell command to call the Get Package API. 

 

The Get Package operation would retrieve a cloud service package for a deployment and stores the package files in Microsoft Azure Blob storage. 

The following package files would be put into storage: 

  • Service configuration file - The cloud service configuration file (.cscfg) provides configuration settings for the cloud service and individual roles, including the number of role instances. 
  • Service package - The service package (.cspkg) contains the application code and the service definition file. 

 

Usually, the Get Package request is in the below formats: 

hailey_ding_9-1635331589459.png

 

 

1. In PowerShell, run the script to retrieve the package: 

$URI="https://management.core.windows.net/<subscription-id>/services/hostedservices/<cloudservice-name>/deploymentslots/production/package?containerUri= <StoragecontainerURL>" 

$method = "POST"  

$headers = [ordered]@{ "x-ms-version" = "2012-03-01"; "ContentLength" = "0" }  

$cerThumbprint="<mythumbprint>" 

Invoke-RestMethod -Uri $URI -Method $method -Headers $headers -CertificateThumbprint $cerThumbprint 

 

Please note that Storage Container URI would be path till your container of your storage account where your package and configuration file will be uploaded. In this case, we have just copied from step two.  ex- https://haileyclassicstorage.blob.core.windows.net/testcontainer 

hailey_ding_10-1635331589594.png

 

 

2. Then, navigate to the container, and you would see the package and files. 

hailey_ding_11-1635331589464.png

 

 3. use the deployment package(.cscfg and .cspkg) to make another deployment. 

You can also download the .cscfg file and modify it for your needs. In my case, I made a change of the instance counts from 1 to 3 instances. Then created another cloud service(classic) use the package file and .cscfg file. 

hailey_ding_12-1635331589725.png

 

hailey_ding_13-1635331589601.png

 

 

REMEMBER: these articles are REPUBLISHED. Your best bet to get a reply is to follow the link at the top of the post to the ORIGINAL post! BUT you're more than welcome to start discussions here:

This site uses Akismet to reduce spam. Learn how your comment data is processed.