Setting a Swappable Cloud Service when using New-AzCloudService

Morné Zaayman 36 Reputation points
2022-08-02T09:14:45.29+00:00

I am able to successfully create a new Cloud Service using the following command:
New-AzCloudService -Name $cloudServiceName
-ResourceGroupName $resourceGroupName -Location $location
-DefinitionFile $definitionFilePath -ConfigurationFile $configurationFilePath
-PackageFile $packageFilePath -KeyVaultName $keyVaultName
-StorageAccount $storageAccountName

I am trying to also set the Cloud Service to be swappable with another Cloud Service. Based on the documentation here, I tried:

$networkProfile = @{SwappableCloudService = $swappableCloudService.Id }

New-AzCloudService -Name $cloudServiceName
-ResourceGroupName $resourceGroupName -Location $location
-DefinitionFile $definitionFilePath -ConfigurationFile $configurationFilePath
-PackageFile $packageFilePath -KeyVaultName $keyVaultName
-StorageAccount $storageAccountName `
-NetworkProfile $networkProfile

This however results in the following error: New-AzCloudService: Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided.

I see the documentation also provides other methods of creating a Cloud Service, by specifying the -PackageUrl and -Configuration instead of a PackageFile and ConfigurationFile. In the example, the NetworkProfile is included with this method.

Is setting a swappable Cloud Service only possible when using these methods? So it is not possible to set a swappable Cloud Service when providing the Configuration File and Package File directly (like it is in the portal)? If this is the case, then why?

If it is supported, then can you please explain how to do so?

I did some research before posting this, and I am not the only person having this issue: https://stackoverflow.com/questions/72940711/azure-cloud-services-extended-support-deploy-using-new-azcloudservice-powershell

Azure Cloud Services
Azure Cloud Services
An Azure platform as a service offer that is used to deploy web and cloud applications.
665 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Morné Zaayman 36 Reputation points
    2023-10-25T14:07:27.1366667+00:00

    We gave up using the New-AzCloudService command and instead used New-AzResourceGroupDeployment. I made a blog post about it here: https://mzansibytes.com/2023/04/11/powershell-script-to-update-a-cloud-service-extended-support-deployment/

    0 comments No comments

  2. Fred Henning 0 Reputation points
    2024-03-07T14:16:50.9766667+00:00

    This post in the techcommunity shows in detail how this can be achieved:
    https://techcommunity.microsoft.com/t5/azure-paas-blog/how-to-manage-the-vip-swap-in-cloud-service-extended-support-via/ba-p/3694504

    As I mention in another common the cause for the Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided. error is because -NetworkProfile cannot be used along with -ConfigurationFile and/or -DefinitionFile as those files are used to build the network profile.

    From the link I ended up with the following (I just formatted it for readability) which works well with an automation that uploads the cspk & cscfg to a container from which a SAS token is generated for the URLs:

    New-AzCloudService `
        -StartCloudService:$false `
        -Name $CloudServiceName `
        -ResourceGroupName $ResourceGroupName `
        -Location $Location `
        -PackageUrl $cspkgUrl `
        -ConfigurationUrl $cscfgUrl `
        -NetworkProfile $networkProfile `
        -RoleProfile $roleProfile `
        -OSProfile $osProfile
    
    0 comments No comments