I'm migrating from cloud services classic to cloud services extended support and I'm also moving to deploy with a mixture of yml and powershell.
The documentation text mentions around using New-AzureCloudService for creating and updating the service but when I try to call it for the update I get an error saying the cloud service already exists hence why I've tried to get the cloud service first and if found, update they values but I can't seem to update the definition file as no property exists.
Here is the snippet of code I'm using
$cloudService = Get-AzCloudService -ResourceGroupName $resourceGroupName -CloudServiceName $name -ErrorAction SilentlyContinue
if ($cloudService) {
$cloudService.packageUrl = $cspkgUrl
$cloudService.Configuration = Get-Content "$buildDirectory/ServiceConfiguration.Dev.cscfg"
$cloudService | Update-AzCloudService
} else {
New-AzCloudService `
-Name $name `
-ResourceGroupName $resourceGroupName `
-Location "$location" `
-ConfigurationFile "$buildDirectory/ServiceConfiguration*.cscfg" `
-DefinitionFile "$buildDirectory/ServiceDefinition.csdef" `
-packageUrl $cspkgUrl
}
I'm using Az v11.1.0 and Az.CloudService v2.0.0
I'm expecting to be able to set the definition file path or url when updating the cloud service but I can't seem to workout how.
Slightly unrelated but the cloud service is triggered via a service bus so I could delete the cloud service and redeploy the entire service but I feel this is overcomplicating it and I should just be able to update the csdef.
After a workaround on your requirement, the solution I found is you have to modify the
.csdefor.csdeffiles manually and then point it to the updated package file with theUpdate-AzCloudServicecommand. It means that you can only modify thepackageurlas you already did in your code. There is no possibility of modifying the.csdefor.cscfgfiles directly with theUpdate-AzCloudServicecommand.As mentioned above, I modified
.csdeffile and uploaded it to the storage account. Once it's done, I was obtaining the updated package URL from storage account as shown below.Note: After retrieving the URL in the above given manner, use your existed code to update the cloud service.
Refer MSDoc for better understanding on create/update a cloud service with PowerShell.