0
votes

I am trying to deploy a cspkg file that is stored in a blob container in an Azure storage account using VSTS release pipeline.

I am trying to mimic the upgrade process of updating the cloud service with a new version so I have the current PROD version of the app in storage. I want to release this version to this test upgrade cloud service and then release the new version that is coming from TEST onto the test upgrade cloud service and then check that app still works.

I am using an Azure PowerShell task to perform this process that is similar to an Azure Automation runbook that I used in the past to perform this operation.

The first step is to get the cspkg file and get the url

$pkgFile = Get-AzureRmStorageAccount -Name $StorageAccountName -ResourceGroupName $ResourceGroupName | Get-AzureStorageBlob -Container $ContainerName -Blob $BlobNamePackageFull
$package = $pkgFile.ICloudBlob.uri.AbsoluteUri

I also write the config file to a temp folder

$TempFileLocation = "C:\temp\$BlobNameConfiguration"
Get-AzureRmStorageAccount -Name $StorageAccountName -ResourceGroupName $ResourceGroupName | Get-AzureStorageBlobContent -Container $ContainerName -Blob $BlobNameConfiguration -Destination $TempFileLocation -Force

I then try to deploy the cloud service using New-AzureDeployment

New-AzureDeployment -ServiceName "$ServiceName" -Slot "$Slot" -Package "$package" -Configuration $TempFileLocation -Label "$Label" -ErrorAction Stop

I keep getting an error related to the default subscription not being set.

Error details = No default subscription has been designated. Use Select-AzureSubscription -Default <subscriptionName> to set the default subscription.

I have used this task to run other tasks without having this error pop up. I have tried using the subscription ID I used to run the Azure PowerShell task and got the following error even though the subscription exists.

The subscription id XXX-XXX-XXXX doesn't exist

How can I run this cmdlet? This does work in Azure Automation. Should I look at a different way to deploy an older version of a cspkg?

1
Do you solve this issue?starian chen-MSFT
I didn't have a chance to try out the solution you suggested below. To get around this issue I changed the release definition to include the last build that was released to our production environment. I then used the regular Azure Deployment task to test upgrade process which seems to have worked out OK so far.Tom
Yes, as I said there is Azure Deployment task that used to deploy Cloud Service.starian chen-MSFT
You can post a new answer or accept my solution as answer.starian chen-MSFT

1 Answers

0
votes

For New-AzureDeployment command, it is classic command, so you need to choose Azure Classic as Azure Connection Type for Azure PowerShell task and specify a Classic endpoint.

So, you can add another PowerShell task with Azure Classic endpoint to call New-AzureDeployment to deploy.

On the other hand, there is Azure Deployment task that used to deploy Cloud Service.