Azure Resource Groups and JSON Configuration Variables

Anyone know if it is possible to configure ARM templates with JSON Configuration Variables, when using the Azure Resource Groups step template?

Hi Jasper,

Thanks for reaching out! You mean the feature JSON Configuration Variables? It should be possible in that case.

Could you tell me a bit more what you are trying to do, what have you tried already and which blockers did you encounter?

Thanks,
Dalmiro

Hi Dalmiro,

Well I’ve got some generic templates for various resources in Azure and wanted to Octopus to configure the ARM templates. Not really a big fan of variable substitution and wanted to utilize the build ind JSON configuration support. Didn’t see any support in the step template / documentation, but was hoping it was supported implicit. From the logs, it kind of looks like it might be supported, but I’m receiving an error.

Input is the parameter file:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "sites_name": {
            "defaultValue": "someSiteName",
            "type": "String"
        },
        ...
    }
}

I’ve created an variable with the following name

parameters:sites_name:defaultValue

However

In the log output I get the following, indicating that it may not be fully supported:

Hyak.Common.CloudException: InvalidRequestContent: The request content was invalid and could not be deserialized: 'Could not find member 'defaultValue' on object of type 'DeploymentParameterDefinition'. Path 'properties.parameters.sites_name.defaultValue', line 202, position 24.'.

Just tried to remove the schema information from the parameter file and change the variable accordingly, however no dice.

Looks related: http://help.octopusdeploy.com/discussions/problems/53046-arm-template-deployment-fails-when-parameters-file-contains-metadata

Haven’t really found a solution yet, however the above mentioned error has nothing to do with configuration of any sort. It seems that Resource Group step simple has a problem parsing the parameter file.

The step template seems not to support merging the ARM template and parameters file into a single file.

. I’ve validated that the template works, when invoking it manually with the New-AzureRmResourceGroupDeployment command.

Please note, I’ve also tried to disable the bundled azure cmdlets and installed the newest version on the agent.

Any ideas or input?

Hi Jasper,

Deep apologies for the delay here.

I realize that in my first reply I said the opposite, but the JSON configuration Variables feature does not work in the built-in Azure RM Template step. I was totally wrong about this and I offer you my sincere apologies.

The feature that does work out of the box with ARM templates is Variable Substitution. So the recommended way to deploy a template that’s inside a package is to:

  • Have the template.json file rely completely on the parameters.json.
  • Use Octopus variables in the parameters.json file. These will get replaced by the Variable Substitution feature automatically during the deployment.

If you haven’t tried the above setup, please do so and let me know how it goes.

If you have already tried it and things didn’t go as expected. Please provide the following info so we can test it on our end:

  • Octopus Server version.
  • Send us a template.json and parameters.json file that can help us reproduce this issue. If possible, make this template as small as possible (i.e. only deploy an Azure Web app), and try not to write it by yourself. Instead export it directly from the Azure Portal so we can make sure the syntax if correct.
  • Send us a detailed deployment log following these instructions: https://octopus.com/docs/how-to/how-to-turn-on-variable-logging-and-export-the-task-log

I have made this ticket private so all the info/attachments shared on it stay between you and our staff.

Best regards,
Dalmiro

HI Dalmiro -

Ok - thanks. However I’m pretty sure that the missing json configuraiton option is unrelated to the above mentioned problems. Let’s just close this and I will create a new ticket.