Integer variable types in variable sets?

cloud

(mcalnd) #1

I’m using Octopus Variable sets to drive replacing JSON parameter values in ARM templates, but the whole process falls over if the ARM template requires an integer variable type rather than a string.

I package both my azure template and the azure parameters json files together in a zip and pass them to Octopus to process using the “Deploy an Azure Resource Manager Template” in-build step.

For example, in my Octopus variable set I have…

ovs-appServicePlan_myapp_skuTier with a value of “Free” which has a Variable type of Text
ovs-appServicePlan_myapp_workerSizeId with a value of 0 which is also set as Text (as there doesn’t appear to be a numeric/integer type available?)

In the JSON template set by Azure…

"appServicePlan_myapp_skuTier": {
  "type": "string"
},
"appServicePlan_myapp_workerSizeId": {
  "type": "int"
},

In the parameters file I have…

"appServicePlan_myapp_skuTier": {
  "value": "#{ovs-appServicePlan_myapp_skuTier}"
},
"appServicePlan_myapp_workerSizeId": {
  "value": "#{ovs-appServicePlan_myapp_workerSizeId}"
}

When the step runs everything is fine until the type integer in the parameters json file is hit…

09:12:17 Error | Microsoft.Rest.Azure.CloudException: Deployment template validation failed: ‘The provided value for the template parameter ‘appServicePlan_myapp_workerSizeId’ at line ‘31’ and column ‘55’ is not valid.’.
09:12:17 Error | at Microsoft.Azure.Management.ResourceManager.DeploymentsOperations.d__14.MoveNext()
09:12:17 Error | — End of stack trace from previous location where exception was thrown —
09:12:17 Error | at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
09:12:17 Error | at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
09:12:17 Error | at Microsoft.Azure.Management.ResourceManager.DeploymentsOperationsExtensions.d__19.MoveNext()
09:12:17 Error | — End of stack trace from previous location where exception was thrown —
09:12:17 Error | at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
09:12:17 Error | at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
09:12:17 Error | at Microsoft.Azure.Management.ResourceManager.DeploymentsOperationsExtensions.BeginCreateOrUpdate(IDeploymentsOperations operations, String resourceGroupName, String deploymentName, Deployment parameters)
09:12:17 Error | at Calamari.Azure.Deployment.Conventions.DeployAzureResourceGroupConvention.CreateDeployment(Func1 createArmClient, String resourceGroupName, String deploymentName, DeploymentMode deploymentMode, String template, String parameters) 09:12:17 Error | at Calamari.Azure.Deployment.Conventions.DeployAzureResourceGroupConvention.Install(RunningDeployment deployment) 09:12:17 Error | at Calamari.Deployment.ConventionProcessor.RunInstallConventions() 09:12:17 Error | at Calamari.Deployment.ConventionProcessor.RunConventions() 09:12:17 Error | Running rollback conventions... 09:12:17 Error | Deployment template validation failed: 'The provided value for the template parameter 'appServicePlan_myapp_workerSizeId' at line '31' and column '55' is not valid.'. 09:12:17 Error | Microsoft.Rest.Azure.CloudException 09:12:17 Error | at Microsoft.Azure.Management.ResourceManager.DeploymentsOperations.<BeginCreateOrUpdateWithHttpMessagesAsync>d__14.MoveNext() 09:12:17 Error | --- End of stack trace from previous location where exception was thrown --- 09:12:17 Error | at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 09:12:17 Error | at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 09:12:17 Error | at Microsoft.Azure.Management.ResourceManager.DeploymentsOperationsExtensions.<BeginCreateOrUpdateAsync>d__19.MoveNext() 09:12:17 Error | --- End of stack trace from previous location where exception was thrown --- 09:12:17 Error | at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 09:12:17 Error | at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 09:12:17 Error | at Microsoft.Azure.Management.ResourceManager.DeploymentsOperationsExtensions.BeginCreateOrUpdate(IDeploymentsOperations operations, String resourceGroupName, String deploymentName, Deployment parameters) 09:12:17 Error | at Calamari.Azure.Deployment.Conventions.DeployAzureResourceGroupConvention.CreateDeployment(Func1 createArmClient, String resourceGroupName, String deploymentName, DeploymentMode deploymentMode, String template, String parameters)
09:12:17 Error | at Calamari.Azure.Deployment.Conventions.DeployAzureResourceGroupConvention.Install(RunningDeployment deployment)
09:12:17 Error | at Calamari.Deployment.ConventionProcessor.RunInstallConventions()
09:12:17 Error | at Calamari.Deployment.ConventionProcessor.RunConventions()
09:12:17 Error | at Calamari.Azure.Commands.DeployAzureResourceGroupCommand.Execute(String[] commandLineArguments)
09:12:17 Error | at Calamari.Program.Execute(String[] args)
09:12:17 Verbose | Process C:\Windows\system32\WindowsPowershell\v1.0\PowerShell.exe in C:\OctopusDeployHome\Work\20180918081214-15386-246 exited with code 100
09:12:17 Verbose | Updating manifest with output variables
09:12:17 Verbose | Updating manifest with action evaluated variables
09:12:17 Fatal | The remote script failed with exit code 100
09:12:17 Fatal | The action arm setup on the Octopus Server failed

This is a bit of a show-stopped for us. I believe it is because Octopus passes a string value back to the template that wants an integer.

Can this be worked around?? I couldn’t see anything in the variable sets that would allow anything other than a String/Text type associated with it.


(John Simons) #2

Hi Neil,

Sorry that you have run into this issue.
To pass an integer type to the template, you need to remove the double quotes from the parameter json value.
So your parameters json should be:

"appServicePlan_myapp_skuTier": {
  "value": "#{ovs-appServicePlan_myapp_skuTier}"
},
"appServicePlan_myapp_workerSizeId": {
  "value": #{ovs-appServicePlan_myapp_workerSizeId}
}

So I removed the "s around #{ovs-appServicePlan_myapp_workerSizeId}.
This should make it an integer type.

I hope this solves the issue you having. Let me know ?

Cheers
John


(mcalnd) #3

Thanks John, that worked perfectly.

Cheers

Neil