2017-04-11 116 views
0
PUT /subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName} 
    /providers/Microsoft.Resources/deployments/{deploymentName}?api-version=2016-09-01 

REST调用体:与REST API创建资源组部署

{ 
    "properties": { 
     "template": { 
      "schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 
      "contentVersion": "1.0.0.0", 
      "resources": [] 
     } 
    } 
} 

这是一个最小的有效的JSON模板,如果我的要求去做,我得到:

{ 
    "error": { 
    "code": "InvalidRequestContent", 
    "message": "The request content was invalid and could not be deserialized: 'Could not find member 'schema' on object of type 'Template'. Path 'properties.template.schema', line 4, position 16.'." 
    } 
} 

好吧,这没有意义,就把让我们试着删除“模式”属性,这是我得到:

{ 
    "error": { 
    "code": "InvalidRequestContent", 
    "message": "The request content was invalid and could not be deserialized: 'Required property '$schema' not found in JSON. Path 'properties.template', line 6, position 4.'." 
    } 
} 

模板对象的架构在docs中没有描述。那么WTH?

回答

0

根据错误信息我们可能知道我们需要使用$ schema而不是schema,请尝试使用以下正文和模式是必需的。它在我身边正常工作,我用小提琴测试了它。

{ 
     "properties": { 
     "template": { 
      "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 
      "contentVersion": "1.0.0.0", 
      "resources": [] 
     }, 
     "mode": "Incremental" 
     } 

} 

enter image description here

+0

你知道如何做新AzureRmResource一样吗? – 4c74356b41

+0

'如何用New-AzureRmResource做同样的事情?'你能解释一下吗? –

+0

如何使用New-AzureRmResource创建部署,我试着做同样的调用,但无法处理模板。我知道有一个cmdlet可以做到这一点,但这没有问题 – 4c74356b41