使用 ARM 模板(取自 Microsoft 示例),我有以下内容:
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
结果如下:
Unable to load schema from 'http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json': unexpected end of file.
当我手动检索架构文件时,它返回以下内容:
{"id":"https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#","$schema":"http://json-schema.org/draft-04/schema#","title":"Parameters","description":"An Azure deployment parameter file","type":"object","properties":{"$schema":{"type":"string"},"contentVersion":{"type":"string","pattern":"(^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$)","description":"A 4 number format for the version number of this parameter file. For example, 1.0.0.0"},"parameters":{"type":"object","additionalProperties":{"$ref":"#/definitions/parameter"},"description":"Collection of parameters to pass into a template"}},"additionalProperties":false,"required":["$schema","contentVersion","parameters"],"definitions":{"parameter":{"type":"object","properties":{"value":{"$ref":"https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#/definitions/parameterValueTypes","description":"Input value to template"},"reference":{"$ref":"https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#/definitions/keyVaultReference","description":"KeyVault parameter reference"},"metadata":{"type":"object","description":"Client specific metadata"}},"additionalProperties":false,"oneOf":[{"required":["value"]},{"required":["reference"]}]}}}
上面通过了几种类型的 json 验证,包括 jsonlint,所以我不明白为什么 VSCode 会提示它。
有人解决这个问题吗?
最佳答案
据此document ,使用最新版本的$schema
If you're using Visual Studio Code with the Azure Resource Manager tools extension, use the latest version for resource group deployments: https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#
使用此版本2019-04-01
而不是2014-04-01-preview
关于azure - Azure ARM 模板上的 Visual Studio Code 报告无法加载架构 - 文件意外结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70803488/