In the Azure portal, my Cloud Service (Extended Support) gets updated pretty frequently and swapped with another Cloud Service (Extended Support) instance. I have a script that uploads the CSPKG, CSDEF, and CSCFG files to blob storage. This works fine.
I then go to the portal, find the instance I want to update, click Update, change to Blob storage, browse to the files I uploaded and click on the update button. This kicks off the process and about 7-9 minutes later the instance is ready to use.
I am trying to replicate this update process in PowerShell, and though it appears that it works, the instance never actually updates. It finds the cloud service just fine. This is what I have put together:
# Get an SAS token to CSPKG
Write-Host ("$(Get-Date -f $timeStampFormat) Getting CSPKG Shared Access Signature (SAS) token") -ForegroundColor DarkCyan
#$tokenStartTime = Get-Date
#$tokenEndTime = $tokenStartTime.AddYears(1)
#$cspkgToken = New-AzStorageBlobSASToken -Container “vs-deploy” -Blob “MyCloudService.cspkg” -Permission rwd -StartTime $tokenStartTime -ExpiryTime $tokenEndTime -Context $storageAccount.Context
$cloudService = (Get-AzCloudService) |
Where-Object {
$_.networkProfile.LoadBalancerConfiguration.FrontendIPConfiguration.PublicIPAddressId -like "*MyIP"
}
$stagingServiceName = $cloudService.Name
Write-Host ("$(Get-Date -f $timeStampFormat) Deploying to {0} Cloud Service" -f $stagingServiceName) -ForegroundColor DarkCyan
# Load the CSCFG XML into a string from local drive
$cscfgContent = Get-Content $cscfgFilePath | Out-String
try {
Write-Host "URI for blob: "$cspkgBlob.ICloudBlob.Uri.AbsoluteUri
# Update the cloud service
$cloudService.PackageUrl = $cspkgBlob.ICloudBlob.Uri.AbsoluteUri
$cloudService.Configuration = $cscfgContent
$cloudService | Update-AzCloudService
} catch {
Write-Host ("$(Get-Date -f $timeStampFormat) Cloud Service {0} failed to update: {1}" -f $service, $_.Exception.Message) -ForegroundColor Red
break;
}
Write-Host ("$(Get-Date -f $timeStampFormat) Finished")
First question is: Why is there no mention of the CSDEF file when the portal requires it to update?
Second question: One of the methods I tried required the SAS token but this one doesn't seem to. Did I miss something?
Third question: I could not find a way to read the CSCFG file from the blob to resorted to reading it from my local drive. What is the proper way to get it from the blob?
Final question: Even though this appears to update, the instance doesn't change. What am I missing?
Thanks, JayTee
I suspect you'll get the most value from the Cloud Services - Create Or Update docs. Create and Update are the same operation in the world of Cloud Services (Extended Support).
configuration(as you're doing above) or you can supply a SAS URI viaconfigurationUrl. (It does look like the docs have a typo there- The second sentence ofconfigurationUrlshould read "The servicepackageconfiguration URL can be....")configurationUrlinstead ofconfigurationin theCloudServiceProperties.