Azure / AzureRMR

R package for interacting with Azure Resource Manager
Other
19 stars 9 forks source link

Troubles with using template.parameters.json #4

Closed thomaslaber closed 5 years ago

thomaslaber commented 5 years ago

Hey,

I do not seem to be capable to use a template.parameters.json-file while deploying. It works fine using the template.json and according to the definition both parameters (template and parameters) are able to handle the usual Azure deployment templates.

rg$deploy_template(name = "foo",
                           template = "template.json",
                           parameters = "template.parameters.json"

I get the following error message:

Error in process_response(res, match.arg(http_status_handler)) : 
  Bad Request (HTTP 400). Failed to complete operation. Message:
The request content was invalid and could not be deserialized: 'Error converting value
"https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#" to type
'Microsoft.WindowsAzure.ResourceStack.Frontdoor.Data.Definitions.DeploymentParameterDefinition'.
Path 'properties.parameters.$schema', line 57, position 106.'.

I could supply you the json files but I know them to be working. Handing over the parameters as a list works fine.

Thank you!

Best, Thomas

hongooi73 commented 5 years ago

Hey there Thomas, how's it going? I'll guess that your parameters.json file includes the schema. Remove this and it should work. It should be a single JSON object, containing the individual parameters as entries.

thomaslaber commented 5 years ago

Hong, first of all: Your answering time is ridiculous :)

Alright, this means I misunderstood. I thought I could use the Azure format such as:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "workflows_ARM_minimal_test_name": {
        "value": "correct_name"
      } 
    }
  }

What also also had tried was this as parameters.json:

{
    "workflows_ARM_minimal_test_name": "correct_name"
}

And following on what you just tole me this should be working, correct? However, it does is not for me and throws a very similar error message:

Error in process_response(res, match.arg(http_status_handler)) : 
  Bad Request (HTTP 400). Failed to complete operation. Message:
The request content was invalid and could not be deserialized: 'Error converting value
"ARM-minimal-test-deployed_richtig" to type
'Microsoft.WindowsAzure.ResourceStack.Frontdoor.Data.Definitions.DeploymentParameterDefinition'.
Path 'properties.parameters.workflows_ARM_minimal_test_name', line 57, position 82.'.
hongooi73 commented 5 years ago

Well, you happened to get me at a good time. ;)

I'm not at my PC right now, but you can use the build_template_parameters function to create the json. Call it as follows:

build_template_parameters(parm1="value1", parm2="value2", ...)
thomaslaber commented 5 years ago

That helped :)

So the solution is this:

{
    "workflows_ARM_minimal_test_name": {
        "value": "correct_name"
    }
}

Thank you so much!