c# - How can I pass ARM template parameters through the API instead of a parameter file? -
i'm attempting automate creation of resources in azure using azure resource manager .net libraries. able create resource group , have placed arm template in accessible location on blob storage; however, able pass in parameters request in code instead of staging json file somewhere in storage.
it seems should possible. example, on deployment.properties
object, has both parameters
, parameterslink
, cannot find documentation on usage , following throwing exception saying no value specified parameters in template:
deployment.properties = new deploymentproperties { mode = deploymentmode.incremental, templatelink = new templatelink("link-to-my-template-json-in-storage"), parameters = new { diskstorageaccountname = "value", imagevhdpath = "value", virtualnetworkname = "value", virtualnetworksubnetname = "value", vmname = value, vmadminusername = "value", vmadminpassword = "value" } };
this yields following error:
an unhandled exception of type 'microsoft.rest.azure.cloudexception' occurred in mscorlib.dll
additional information: deployment template validation failed: 'the value template parameter 'diskstorageaccountname' @ line '5' , column '32' not provided. please see http://aka.ms/arm-deploy/#parameter-file usage details.'.
am doing wrong? deploymentproperties.parameters
object
had assumed serialized , passed on correctly -- assumption incorrect?
edit: msdn article not helpful either.
edit 2: wonder if bug in autogenerated code. see line 700 here:
looks trying jobject.parse
edit 3: opened issue on github.
for deployment properties parameters
, should use jobject
type newtonsoft.json.linq
namespace.
e.g.
using newtonsoft.json.linq; // paramjsonstring string type object parameters = jobject.parse(paramjsonstring);
note: microsoft.azure.management.resources
nuget package deprecated.
strongly recommend use
microsoft.azure.resourcemanager 1.0.0-preview
microsoft.azure.resourcemanager development related azure resource manager.
hope helps!
Comments
Post a Comment