Hi,
tl;dr - deploying cloud services fails if “{step name} v{release number}”.Length > 100, which causes problems if your release number includes a very long branch name
Following on from SQL error when creating release with very long version number, I’ve found another issue with long branch names which was sent to me by a different dev team in or organisation (I don’t know why they all insist on extremely long branch names, but that’s beside the point).
In this case, deploying a cloud service (ActionType = “Octopus.AzureCloudService”) fails with the following error:
Set-AzureDeployment : Specified argument was out of the range of valid values.
Parameter name: parameters.Label
At E:\Octopus\Work\20180611163020-601394-70449\staging\DeployToAzure.ps1:42 char:5
+ Set-AzureDeployment -Upgrade -ServiceName $OctopusAzureServiceNam ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Set-AzureDeployment], ArgumentOutOfRangeException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices.SetAzureDeploymentComma
nd
To summarise the error:
-
The step is failing in DeployToAzure.ps1 at the call to Set-AzureDeployment because the Label parameter is invalid.
-
The DeployToAzure.ps1 call to Set-AzureDeployment is here; https://github.com/OctopusDeploy/Calamari/blob/master/source/Calamari.Azure/Scripts/DeployAzureCloudService.ps1#L42 and passes
$OctopusAzureDeploymentLabel
as the Label parameter. -
From this support ticket https://help.octopusdeploy.com/discussions/questions/8817-modify-deployment-label-without-custom-deploytoazureps1, the variable is calculated here: https://github.com/OctopusDeploy/Calamari/blob/master/source/Calamari.Azure/Deployment/Conventions/DeployAzureCloudServicePackageConvention.cs#L39 as the system variable
Octopus.Action.Azure.DeploymentLabel
(if defined) or the default value “{Action.Name} v{Release.Number}” -
Our release number is based on our branch name and is, for example:
1.0.0-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah
, and we don’t haveOctopus.Action.Azure.DeploymentLabel
system variable defined, so our deployment label will be calculated asMyProcessStepName v1.0.0-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah
which is 104 characters long. -
According to the documentation at https://msdn.microsoft.com/en-us/library/azure/ee460813.aspx, the maximum length of the Deployment Label is 100 characters.
-
Chaos ensues!
Obviously, now we’ve identified the length of the branch name as the root cause, I’ve told the devs to use shorter names, but it would be helpful if the Octopus.AzureCloudService action template was aware of the 100 character limit in the Label parameter for Set-AzureDeployment (or just the length of release numbers in general), and gave a meaningful error message with a call to action so our devs didn’t have to escalate to me to investigate :-).
Cheers,
Mike