2017-04-11 98 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