我试图验证一个arm模板-任何arm模板-但我总是得到相同的错误:
The request content was invalid and could not be deserialized: 'Error converting value "
{
...
}" to type 'Microsoft.WindowsAzure.ResourceStack.Frontdoor.Templates.Schema.Template'. Path 'properties.template', line 1, position 1202.'.我在蔚蓝门户上创建了ARM模板,并将其插入:
#!/usr/bin/env python3
# https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-authoring-templates
t='''
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1",
"apiProfile": "",
"parameters": {
"testType": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_ZRS",
"Standard_GRS",
"Standard_RAGRS",
"Premium_LRS"
]
}
},
"variables": {
"testName": "[concat('test', uniqueString(resourceGroup().id))]"
},
"functions": [],
"resources": [
{
"name": "[variables('testName')]",
"type": "Microsoft.Storage/storageAccounts",
"location": "[resourceGroup().location]",
"apiVersion": "2015-06-15",
"dependsOn": [],
"tags": {
"displayName": "test"
},
"properties": {
"accountType": "[parameters('testType')]"
}
}
],
"outputs": {}
}
'''
from azure.common.client_factory import get_client_from_cli_profile
from azure.mgmt.resource import ResourceManagementClient
c = get_client_from_cli_profile(ResourceManagementClient)
print(c.deployments.validate('PAWS_Resources', 'food', c.models().DeploymentProperties(mode='incremental', template=t)).error.message)发布于 2019-09-20 21:18:14
根据医生的说法:
模板对象模板内容。如果希望直接在请求中传递模板语法,而不是链接到现有模板,则可以使用此元素。它可以是JObject或格式良好的JSON字符串。使用templateLink属性或模板属性,但不能同时使用。
但是,它需要一个python对象,而不是一个“格式良好的JSON字符串”。
从模板数据中删除引号可以使其工作。
https://stackoverflow.com/questions/58034772
复制相似问题