json - 无法在 Azure 中解析参数 : azuredeploy.parameters.json

标签 json azure azure-resource-manager

您好,当我使用 VS code 创建 azuredeploy.json 和 azuredeploy.parameter.json 后尝试部署存储帐户时,收到以下错误消息

"cli.azure.cli.core.azclierror: Unable to parse parameter: azuredeploy.parameters.json az_command_data_logger: Unable to parse parameter: azuredeploy.parameters.json"

我用过 终端中的 az 部署组 create --resource-group az204-arm-rg --template-file D:\Azure\azuredeploy.json --parameters azuredeploy.parameter 命令。

azuredeploy.json 文件有

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {"storageAccountName": {
        "type": "string",
        "metadata": {
            "description": "Storage Account Name",
            "minLength": 3,
            "maxLength": 24
        },

    }},
    "functions": [],
    "variables": {},
    "resources": [{
        "name": "[parameters('storageAccountName')]",
        "type": "Microsoft.Storage/storageAccounts",
        "apiVersion": "2021-04-01",
        "tags": {
            "displayName": "storageaccount1"
        },
        "location": "[resourceGroup().location]",
        "kind": "StorageV2",
        "sku": {
            "name": "Premium_LRS",
            "tier": "Premium"
        }
    }],
    "outputs":{}

}

azuredeploy.parameters.json 有

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "storageAccountName": {
            "value": "az204storageacctarm" // TODO: Fill in parameter value
        }
    }

}

错误:-

enter image description here

最佳答案

I used az deployment group create --resource-group az204-arm-rg --template-file D:\Azure\azuredeploy.json --parameters azuredeploy.parameter command in the terminal

您似乎已经在 azuredeploy.parameter.json 文件中填写了所有必需的参数。

您尝试在不提供参数文件路径的情况下使用的命令,请尝试使用以下建议的命令通过给出参数文件的路径来使用参数文件进行部署参数文件的路径 .

例如:-

az deployment group create -n TestDeployment -g resourcegroup --template-file "C:\Users\source\repos\yourtemplatearm.json" --parameters "C:\users\source\repos\azuredeploy.parameters.json"

注意:- 在部署模板之前,请确保您已使用 az login 登录

步骤如下:-

我们尝试使用和部署的默认模板。

storagetest.json-

{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
},
"storageAccountName": {
"type": "string"
},
"accountType": {
"type": "string"
},
"kind": {
"type": "string"
},
"accessTier": {
"type": "string"
},
"minimumTlsVersion": {
"type": "string"
},
"supportsHttpsTrafficOnly": {
"type": "bool"
},
"publicNetworkAccess": {
"type": "string"
},
"allowBlobPublicAccess": {
"type": "bool"
},
"allowSharedKeyAccess": {
"type": "bool"
},
"allowCrossTenantReplication": {
"type": "bool"
},
"defaultOAuth": {
"type": "bool"
},
"networkAclsBypass": {
"type": "string"
},
"networkAclsDefaultAction": {
"type": "string"
},
"dnsEndpointType": {
"type": "string"
},
"keySource": {
"type": "string"
},
"encryptionEnabled": {
"type": "bool"
},
"keyTypeForTableAndQueueEncryption": {
"type": "string"
},
"infrastructureEncryptionEnabled": {
"type": "bool"
},
"isContainerRestoreEnabled": {
"type": "bool"
},
"isBlobSoftDeleteEnabled": {
"type": "bool"
},
"blobSoftDeleteRetentionDays": {
"type": "int"
},
"isContainerSoftDeleteEnabled": {
"type": "bool"
},
"containerSoftDeleteRetentionDays": {
"type": "int"
},
"changeFeed": {
"type": "bool"
},
"isVersioningEnabled": {
"type": "bool"
},
"isShareSoftDeleteEnabled": {
"type": "bool"
},
"shareSoftDeleteRetentionDays": {
"type": "int"
}
},
"variables": {},
"resources": [
{
"name": "[parameters('storageAccountName')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2021-09-01",
"location": "[parameters('location')]",
"properties": {
"accessTier": "[parameters('accessTier')]",
"minimumTlsVersion": "[parameters('minimumTlsVersion')]",
"supportsHttpsTrafficOnly": "[parameters('supportsHttpsTrafficOnly')]",
"publicNetworkAccess": "[parameters('publicNetworkAccess')]",
"allowBlobPublicAccess": "[parameters('allowBlobPublicAccess')]",
"allowSharedKeyAccess": "[parameters('allowSharedKeyAccess')]",
"allowCrossTenantReplication": "[parameters('allowCrossTenantReplication')]",
"defaultToOAuthAuthentication": "[parameters('defaultOAuth')]",
"networkAcls": {
"bypass": "[parameters('networkAclsBypass')]",
"defaultAction": "[parameters('networkAclsDefaultAction')]",
"ipRules": []
},
"dnsEndpointType": "[parameters('dnsEndpointType')]",
"encryption": {
"keySource": "[parameters('keySource')]",
"services": {
"blob": {
"enabled": "[parameters('encryptionEnabled')]"
},
"file": {
"enabled": "[parameters('encryptionEnabled')]"
},
"table": {
"enabled": "[parameters('encryptionEnabled')]"
},
"queue": {
"enabled": "[parameters('encryptionEnabled')]"
}
},
"requireInfrastructureEncryption": "[parameters('infrastructureEncryptionEnabled')]"
}
},
"dependsOn": [],
"sku": {
"name": "[parameters('accountType')]"
},
"kind": "[parameters('kind')]",
"tags": {}
},
{
"name": "[concat(parameters('storageAccountName'), '/default')]",
"type": "Microsoft.Storage/storageAccounts/blobServices",
"apiVersion": "2021-09-01",
"properties": {
"restorePolicy": {
"enabled": "[parameters('isContainerRestoreEnabled')]"
},
"deleteRetentionPolicy": {
"enabled": "[parameters('isBlobSoftDeleteEnabled')]",
"days": "[parameters('blobSoftDeleteRetentionDays')]"
},
"containerDeleteRetentionPolicy": {
"enabled": "[parameters('isContainerSoftDeleteEnabled')]",
"days": "[parameters('containerSoftDeleteRetentionDays')]"
},
"changeFeed": {
"enabled": "[parameters('changeFeed')]"
},
"isVersioningEnabled": "[parameters('isVersioningEnabled')]"
},
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]"
]
},
{
"name": "[concat(parameters('storageAccountName'), '/default')]",
"type": "Microsoft.Storage/storageAccounts/fileservices",
"apiVersion": "2021-09-01",
"properties": {
"shareDeleteRetentionPolicy": {
"enabled": "[parameters('isShareSoftDeleteEnabled')]",
"days": "[parameters('shareSoftDeleteRetentionDays')]"
}
},
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]",
"[concat(concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName')), '/blobServices/default')]"
]
}
],
"outputs": {}
}

azuredeploy.parameter.json -

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
    "location": {
    "value": "eastus"
    },
    "storageAccountName": {
    "value": "yourstorageaccountname"
    },
    "accountType": {
    "value": "Standard_RAGRS"
    },
    "kind": {
    "value": "StorageV2"
    },
    "accessTier": {
    "value": "Hot"
    },
    "minimumTlsVersion": {
    "value": "TLS1_2"
    },
    "supportsHttpsTrafficOnly": {
    "value": true
    },
    "publicNetworkAccess": {
    "value": "Enabled"
    },
    "allowBlobPublicAccess": {
    "value": true
    },
    "allowSharedKeyAccess": {
    "value": true
    },
    "allowCrossTenantReplication": {
    "value": true
    },
    "defaultOAuth": {
    "value": false
    },
    "networkAclsBypass": {
    "value": "AzureServices"
    },
    "networkAclsDefaultAction": {
    "value": "Allow"
    },
    "dnsEndpointType": {
    "value": "Standard"
    },
    "keySource": {
    "value": "Microsoft.Storage"
    },
    "encryptionEnabled": {
    "value": true
    },
    "keyTypeForTableAndQueueEncryption": {
    "value": "Account"
    },
    "infrastructureEncryptionEnabled": {
    "value": false
    },
    "isContainerRestoreEnabled": {
    "value": false
    },
    "isBlobSoftDeleteEnabled": {
    "value": true
    },
    "blobSoftDeleteRetentionDays": {
    "value": 7
    },
    "isContainerSoftDeleteEnabled": {
    "value": true
    },
    "containerSoftDeleteRetentionDays": {
    "value": 7
    },
    "changeFeed": {
    "value": false
    },
    "isVersioningEnabled": {
    "value": false
    },
    "isShareSoftDeleteEnabled": {
    "value": true
    },
    "shareSoftDeleteRetentionDays": {
    "value": 7
    }
    }
    }

引用屏幕截图:-

enter image description here

enter image description here

enter image description here

欲了解更多信息,请参阅此MICROSOFT DOCUMENTATION .

关于json - 无法在 Azure 中解析参数 : azuredeploy.parameters.json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72701726/

相关文章:

java - 基于类反序列化json时发生异常,该类内部有一个接口(interface)类型

azure - 如何使用 Azure 数据工厂删除文件中的重复项,而不使用 Dataflow 或 Databricks 或 Azure datalake 分析

azure - 为 MVC WebRole 指定暂存和生产部署 URL

azure - CSPack 1.4 因 OutOfMemoryException 崩溃

Azure Arm 模板依赖于链接模板

ios - 如何使用 objective c 在 iOS 中解析 jsonstring?

python - 如何在不使用 json 库或没有任何其他库的情况下读取 json 文件到字典或列表中?

powershell - 新的 AzResourceGroupDeployment : Cannot retrieve the dynamic parameters for the cmdlet

powershell - 通过 Azure 资源管理器应用多个 DSC

javascript - 排序 JSON 提要