Deployments - Validate
验证指定的模板是否语法正确,并且将由 Azure 资源管理器接受。
POST https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate?api-version=2025-04-01
URI 参数
| 名称 | 在 | 必需 | 类型 | 说明 |
|---|---|---|---|---|
|
deployment
|
path | True |
string minLength: 1maxLength: 64 pattern: ^[-\w\._\(\)]+$ |
部署的名称。 |
|
resource
|
path | True |
string minLength: 1maxLength: 90 pattern: ^[-\w\._\(\)]+$ |
模板将部署到的资源组的名称。 此名称不区分大小写。 |
|
subscription
|
path | True |
string |
Microsoft Azure 订阅 ID。 |
|
api-version
|
query | True |
string |
用于此操作的 API 版本。 |
请求正文
| 名称 | 必需 | 类型 | 说明 |
|---|---|---|---|
| properties | True |
部署属性。 |
|
| identity |
部署的托管标识配置。 |
||
| location |
string |
用于存储部署数据的位置。 |
|
| tags |
object |
部署标记 |
响应
| 名称 | 类型 | 说明 |
|---|---|---|
| 200 OK |
模板部署验证成功。 请检查“warnings”属性,因为某些资源可能已从验证中跳过。 |
|
| 202 Accepted |
已接受 - 已接受处理请求,操作将以异步方式完成。 |
|
| 400 Bad Request |
模板部署验证检测到失败。 |
|
| Other Status Codes |
描述作失败的原因的错误响应。 |
安全性
azure_auth
Azure Active Directory OAuth2 流
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
| 名称 | 说明 |
|---|---|
| user_impersonation | 模拟用户帐户 |
示例
Validates a template at resource group scope
示例请求
POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000001/resourcegroups/my-resource-group/providers/Microsoft.Resources/deployments/my-deployment/validate?api-version=2025-04-01
{
"properties": {
"templateLink": {
"uri": "https://example.com/exampleTemplate.json",
"queryString": "sv=2019-02-02&st=2019-04-29T22%3A18%3A26Z&se=2019-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=xxxxxxxx0xxxxxxxxxxxxx%2bxxxxxxxxxxxxxxxxxxxx%3d"
},
"parameters": {},
"mode": "Incremental"
}
}
示例响应
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/deployments/my-deployment",
"name": "my-deployment",
"type": "Microsoft.Resources/deployments",
"properties": {
"templateLink": {
"id": "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1",
"contentVersion": "1.0.0.0"
},
"templateHash": "0000000000000000000",
"parameters": {},
"mode": "Incremental",
"provisioningState": "Succeeded",
"timestamp": "2020-06-05T01:20:01.723776Z",
"duration": "PT22.8356799S",
"correlationId": "00000000-0000-0000-0000-000000000000",
"providers": [
{
"namespace": "Microsoft.Storage",
"resourceTypes": [
{
"resourceType": "storageAccounts",
"locations": [
"eastus"
]
}
]
}
],
"dependencies": [],
"validatedResources": [
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/my-storage-account"
}
],
"diagnostics": [
{
"level": "Warning",
"code": "NestedDeploymentShortCircuited",
"message": "A nested deployment got short-circuited and all its resources got skipped from validation. This is due to a nested template having a parameter that was not fully evaluated (e.g. contains a reference() function)."
},
{
"level": "Warning",
"code": "NestedDeploymentSkippedFromInternalExpansion",
"message": "When nested deployments are expanded, all its inner resources are retrieved for further validation. This process is performed in batch of: '10' at a time. Nested deployments exceeding this batch count are skipped from expansion."
},
{
"level": "Warning",
"code": "NestedDeploymentExpansionLimitReached",
"message": "Nested deployments are expanded up to: '50' in total. Nested deployments exceeding this count are skipped from expansion."
}
]
}
}
Location: /subscriptions/00000000-0000-0000-0000-000000000001/operationResults/XXXXXXXXXXXXXXX?api-version=2025-04-01
x-ms-request-id: dccf336d-c3ee-4057-a902-9efc0e023cd0
x-ms-correlation-request-id: dccf336d-c3ee-4057-a902-9efc0e023cd0
{
"error": {
"code": "InvalidTemplateDeployment",
"message": "The template deployment 'my-deployment' is not valid according to the validation procedure. The tracking id is 'dccf336d-c3ee-4057-a902-9efc0e023cd0'. See inner errors for details.",
"details": [
{
"code": "PreflightValidationCheckFailed",
"message": "Preflight validation failed. Please refer to the details for the specific errors.",
"details": [
{
"code": "AccountNameInvalid",
"target": "a",
"message": "a is not a valid storage account name. Storage account name must be between 3 and 24 characters in length and use numbers and lower-case letters only."
}
]
}
]
}
}
定义
Alias
别名类型。
| 名称 | 类型 | 说明 |
|---|---|---|
| defaultMetadata |
默认别名路径元数据。 适用于默认路径和不具有元数据的任何别名路径 |
|
| defaultPath |
string |
别名的默认路径。 |
| defaultPattern |
别名的默认模式。 |
|
| name |
string |
别名。 |
| paths |
别名的路径。 |
|
| type |
别名的类型。 |
AliasPath
别名的路径的类型。
| 名称 | 类型 | 说明 |
|---|---|---|
| apiVersions |
string[] |
API 版本。 |
| metadata |
别名路径的元数据。 如果缺少,请回退到别名的默认元数据。 |
|
| path |
string |
别名的路径。 |
| pattern |
别名路径的模式。 |
AliasPathAttributes
别名路径引用的令牌的属性。
| 值 | 说明 |
|---|---|
| None |
别名路径引用的标记没有属性。 |
| Modifiable |
别名路径引用的标记可由具有“modify”效果的策略修改。 |
AliasPathMetadata
| 名称 | 类型 | 说明 |
|---|---|---|
| attributes |
别名路径引用的令牌的属性。 |
|
| type |
别名路径引用的标记的类型。 |
AliasPathTokenType
别名路径引用的标记的类型。
| 值 | 说明 |
|---|---|
| NotSpecified |
未指定标记类型。 |
| Any |
标记类型可以是任何内容。 |
| String |
标记类型为字符串。 |
| Object |
标记类型为对象。 |
| Array |
标记类型为数组。 |
| Integer |
标记类型为整数。 |
| Number |
标记类型为数字。 |
| Boolean |
标记类型为布尔值。 |
AliasPattern
别名路径的模式类型。
| 名称 | 类型 | 说明 |
|---|---|---|
| phrase |
string |
别名模式短语。 |
| type |
别名模式的类型 |
|
| variable |
string |
别名模式变量。 |
AliasPatternType
别名模式的类型
| 值 | 说明 |
|---|---|
| NotSpecified |
不允许指定。 |
| Extract |
提取是唯一允许的值。 |
AliasType
别名的类型。
| 值 | 说明 |
|---|---|
| NotSpecified |
别名类型未知(与不提供别名类型相同)。 |
| PlainText |
别名值不是机密。 |
| Mask |
别名值为机密。 |
ApiProfile
| 名称 | 类型 | 说明 |
|---|---|---|
| apiVersion |
string |
API 版本。 |
| profileVersion |
string |
配置文件版本。 |
BasicDependency
部署依赖项信息。
| 名称 | 类型 | 说明 |
|---|---|---|
| id |
string |
依赖项的 ID。 |
| resourceName |
string |
依赖项资源名称。 |
| resourceType |
string |
依赖项资源类型。 |
CloudError
资源管理请求的错误响应。
| 名称 | 类型 | 说明 |
|---|---|---|
| error |
错误响应 |
DebugSetting
调试设置。
| 名称 | 类型 | 说明 |
|---|---|---|
| detailLevel |
string |
指定要记录以供调试的信息的类型。 允许的值不为 none、requestContent、responseContent,或两者均用逗号分隔的 requestContent 和 responseContent。 默认值为 none。 设置此值时,请仔细考虑在部署期间传入的信息类型。 通过记录有关请求或响应的信息,可能会公开通过部署作检索的敏感数据。 |
Dependency
部署依赖项信息。
| 名称 | 类型 | 说明 |
|---|---|---|
| dependsOn |
依赖项列表。 |
|
| id |
string |
依赖项的 ID。 |
| resourceName |
string |
依赖项资源名称。 |
| resourceType |
string |
依赖项资源类型。 |
Deployment
部署作参数。
| 名称 | 类型 | 说明 |
|---|---|---|
| identity |
部署的托管标识配置。 |
|
| location |
string |
用于存储部署数据的位置。 |
| properties |
部署属性。 |
|
| tags |
object |
部署标记 |
DeploymentDiagnosticsDefinition
| 名称 | 类型 | 说明 |
|---|---|---|
| additionalInfo |
错误附加信息。 |
|
| code |
string |
错误代码。 |
| level |
表示附加响应级别。 |
|
| message |
string |
错误消息。 |
| target |
string |
错误目标。 |
DeploymentExtensionConfigItem
| 名称 | 类型 | 说明 |
|---|---|---|
| keyVaultReference |
用于检索扩展配置属性的机密值的 Azure Key Vault 引用。 |
|
| type |
扩展配置属性的值类型。 |
|
| value |
扩展配置属性的值。 |
DeploymentExtensionDefinition
| 名称 | 类型 | 说明 |
|---|---|---|
| alias |
string |
部署模板中定义的扩展的别名。 |
| config |
<string,
Deployment |
扩展配置。 |
| configId |
string |
扩展配置 ID。 它唯一标识扩展中的部署控制平面。 |
| name |
string |
扩展名称。 |
| version |
string |
扩展版本。 |
DeploymentExternalInput
部署外部输入以进行参数化。
| 名称 | 类型 | 说明 |
|---|---|---|
| value |
外部输入值。 |
DeploymentExternalInputDefinition
部署用于参数化的外部输入定义。
| 名称 | 类型 | 说明 |
|---|---|---|
| config |
外部输入的配置。 |
|
| kind |
string |
外部输入的类型。 |
DeploymentIdentity
部署的托管标识配置。
| 名称 | 类型 | 说明 |
|---|---|---|
| type |
标识类型。 |
|
| userAssignedIdentities |
<string,
User |
与资源关联的用户分配标识集。 |
DeploymentIdentityType
标识类型。
| 值 | 说明 |
|---|---|
| None | |
| UserAssigned |
DeploymentMode
用于部署资源的模式。 此值可以是增量值,也可以是“完成”。 在增量模式下,部署资源而不删除模板中不包含的现有资源。 在“完成”模式下,将部署资源,并删除模板中不包含的资源组中的现有资源。 使用“完成”模式时请注意,因为可能会无意中删除资源。
| 值 | 说明 |
|---|---|
| Incremental | |
| Complete |
DeploymentParameter
模板的部署参数。
| 名称 | 类型 | 说明 |
|---|---|---|
| expression |
string |
参数的 input expression。 |
| reference |
Azure Key Vault 参数引用。 |
|
| value |
参数的输入值。 |
DeploymentProperties
部署属性。
| 名称 | 类型 | 说明 |
|---|---|---|
| debugSetting |
部署的调试设置。 |
|
| expressionEvaluationOptions |
指定模板表达式是在父模板或嵌套模板的范围内计算的。 仅适用于嵌套模板。 如果未指定,则默认值为外部值。 |
|
| extensionConfigs |
object |
用于部署扩展的配置。 此对象的键是部署模板中定义的部署扩展别名。 |
| externalInputDefinitions |
<string,
Deployment |
外部输入定义,由外部工具用于定义预期的外部输入值。 |
| externalInputs |
<string,
Deployment |
外部输入值,由外部工具用于参数评估。 |
| mode |
用于部署资源的模式。 此值可以是增量值,也可以是“完成”。 在增量模式下,部署资源而不删除模板中不包含的现有资源。 在“完成”模式下,将部署资源,并删除模板中不包含的资源组中的现有资源。 使用“完成”模式时请注意,因为可能会无意中删除资源。 |
|
| onErrorDeployment |
错误行为的部署。 |
|
| parameters |
<string,
Deployment |
定义模板部署参数的名称和值对。 如果要直接在请求中提供参数值,而不是链接到现有参数文件,请使用此元素。 使用 parametersLink 属性或 parameters 属性,但不能同时使用两者。 它可以是 JObject 或格式良好的 JSON 字符串。 |
| parametersLink |
参数文件的 URI。 使用此元素链接到现有参数文件。 使用 parametersLink 属性或 parameters 属性,但不能同时使用两者。 |
|
| template |
object |
模板内容。 如果要直接在请求中传递模板语法,而不是链接到现有模板,请使用此元素。 它可以是 JObject 或格式正确的 JSON 字符串。 使用 templateLink 属性或模板属性,但不能同时使用这两者。 |
| templateLink |
模板的 URI。 使用 templateLink 属性或模板属性,但不能同时使用这两者。 |
|
| validationLevel |
部署的验证级别 |
DeploymentPropertiesExtended
具有更多详细信息的部署属性。
| 名称 | 类型 | 说明 |
|---|---|---|
| correlationId |
string |
部署的相关 ID。 |
| debugSetting |
部署的调试设置。 |
|
| dependencies |
部署依赖项的列表。 |
|
| diagnostics |
包含在验证过程中收集的诊断信息。 |
|
| duration |
string |
模板部署的持续时间。 |
| error |
错误响应 |
|
| extensions |
此部署中使用的扩展。 |
|
| mode |
部署模式。 可能的值为 Incremental 和 Complete。 |
|
| onErrorDeployment |
错误行为的部署。 |
|
| outputResources |
预配的资源数组。 |
|
| outputs |
object |
表示部署输出的键/值对。 |
| parameters |
object |
部署参数。 |
| parametersLink |
引用参数的 URI。 |
|
| providers |
Provider[] |
部署所需的资源提供程序列表。 |
| provisioningState |
表示预配的状态。 |
|
| templateHash |
string |
为模板生成的哈希。 |
| templateLink |
引用模板的 URI。 |
|
| timestamp |
string (date-time) |
模板部署的时间戳。 |
| validatedResources |
已验证的资源数组。 |
|
| validationLevel |
部署的验证级别 |
DeploymentValidateResult
来自验证模板部署响应的信息。
| 名称 | 类型 | 说明 |
|---|---|---|
| error |
错误响应 |
|
| id |
string |
部署的 ID。 |
| name |
string |
部署的名称。 |
| properties |
模板部署属性。 |
|
| type |
string |
部署的类型。 |
ErrorAdditionalInfo
资源管理错误附加信息。
| 名称 | 类型 | 说明 |
|---|---|---|
| info |
object |
其他信息。 |
| type |
string |
其他信息类型。 |
ErrorResponse
错误响应
| 名称 | 类型 | 说明 |
|---|---|---|
| additionalInfo |
错误附加信息。 |
|
| code |
string |
错误代码。 |
| details |
错误详细信息。 |
|
| message |
string |
错误消息。 |
| target |
string |
错误目标。 |
ExpressionEvaluationOptions
指定模板表达式是在父模板或嵌套模板的范围内计算的。
| 名称 | 类型 | 说明 |
|---|---|---|
| scope |
用于计算嵌套模板中的参数、变量和函数的范围。 |
ExpressionEvaluationOptionsScopeType
用于计算嵌套模板中的参数、变量和函数的范围。
| 值 | 说明 |
|---|---|
| NotSpecified | |
| Outer | |
| Inner |
ExtensionConfigPropertyType
| 值 | 说明 |
|---|---|
| String |
表示字符串值的属性类型。 |
| Int |
表示整数值的属性类型。 |
| Bool |
Property 类型表示布尔值。 |
| Array |
属性类型。 |
| Object |
表示对象值的属性类型。 |
| SecureString |
表示安全字符串值的属性类型。 |
| SecureObject |
表示安全对象值的属性类型。 |
KeyVaultParameterReference
Azure Key Vault 参数引用。
| 名称 | 类型 | 说明 |
|---|---|---|
| keyVault |
Azure Key Vault 参考。 |
|
| secretName |
string |
Azure Key Vault 机密名称。 |
| secretVersion |
string |
Azure Key Vault 机密版本。 |
KeyVaultReference
Azure Key Vault 参考。
| 名称 | 类型 | 说明 |
|---|---|---|
| id |
string |
Azure Key Vault 资源 ID。 |
Level
表示附加响应级别。
| 值 | 说明 |
|---|---|
| Warning | |
| Info | |
| Error |
OnErrorDeployment
针对错误行为进行部署。
| 名称 | 类型 | 说明 |
|---|---|---|
| deploymentName |
string |
要用于错误案例的部署。 |
| type |
错误行为类型的部署。 可能的值为 LastSuccessful 和 SpecificDeployment。 |
OnErrorDeploymentExtended
有关错误行为的部署,并提供了其他详细信息。
| 名称 | 类型 | 说明 |
|---|---|---|
| deploymentName |
string |
要用于错误案例的部署。 |
| provisioningState |
string |
错误部署的预配状态。 |
| type |
错误行为类型的部署。 可能的值为 LastSuccessful 和 SpecificDeployment。 |
OnErrorDeploymentType
错误行为类型的部署。 可能的值为 LastSuccessful 和 SpecificDeployment。
| 值 | 说明 |
|---|---|
| LastSuccessful | |
| SpecificDeployment |
ParametersLink
表示对部署参数的引用的实体。
| 名称 | 类型 | 说明 |
|---|---|---|
| contentVersion |
string |
如果包含,则必须匹配模板中的 ContentVersion。 |
| uri |
string |
参数文件的 URI。 |
Provider
资源提供程序信息。
| 名称 | 类型 | 说明 |
|---|---|---|
| id |
string |
提供程序 ID。 |
| namespace |
string |
资源提供程序的命名空间。 |
| providerAuthorizationConsentState |
提供程序授权许可状态。 |
|
| registrationPolicy |
string |
资源提供程序的注册策略。 |
| registrationState |
string |
资源提供程序的注册状态。 |
| resourceTypes |
提供程序资源类型的集合。 |
ProviderAuthorizationConsentState
提供程序授权许可状态。
| 值 | 说明 |
|---|---|
| NotSpecified | |
| Required | |
| NotRequired | |
| Consented |
ProviderExtendedLocation
提供程序扩展位置。
| 名称 | 类型 | 说明 |
|---|---|---|
| extendedLocations |
string[] |
Azure 位置的扩展位置。 |
| location |
string |
Azure 位置。 |
| type |
string |
扩展位置类型。 |
ProviderResourceType
资源提供程序管理的资源类型。
| 名称 | 类型 | 说明 |
|---|---|---|
| aliases |
Alias[] |
此资源类型支持的别名。 |
| apiProfiles |
资源提供程序的 API 配置文件。 |
|
| apiVersions |
string[] |
API 版本。 |
| capabilities |
string |
此资源类型提供的其他功能。 |
| defaultApiVersion |
string |
默认 API 版本。 |
| locationMappings |
此资源类型支持的位置映射。 |
|
| locations |
string[] |
可以创建此资源类型的位置的集合。 |
| properties |
object |
属性。 |
| resourceType |
string |
资源类型。 |
| zoneMappings |
ProvisioningState
表示预配的状态。
| 值 | 说明 |
|---|---|
| NotSpecified | |
| Accepted | |
| Running | |
| Ready | |
| Creating | |
| Created | |
| Deleting | |
| Deleted | |
| Canceled | |
| Failed | |
| Succeeded | |
| Updating |
ResourceReference
资源 ID 模型。
| 名称 | 类型 | 说明 |
|---|---|---|
| apiVersion |
string |
部署资源时使用的 API 版本。 |
| extension |
部署资源时使用的扩展。 |
|
| id |
string |
完全限定的 Azure 资源 ID。 |
| identifiers |
object |
可扩展资源标识符。 |
| resourceType |
string |
资源类型。 |
TemplateLink
表示对模板的引用的实体。
| 名称 | 类型 | 说明 |
|---|---|---|
| contentVersion |
string |
如果包含,则必须匹配模板中的 ContentVersion。 |
| id |
string |
模板规格的资源 ID。请使用 ID 或 uri 属性,但不能同时使用这两个属性。 |
| queryString |
string |
要与 templateLink URI 一起使用的查询字符串(例如 SAS 令牌)。 |
| relativePath |
string |
relativePath 属性可用于在相对于父级的位置部署链接模板。 如果父模板与 TemplateSpec 链接,则会引用 TemplateSpec 中的项目。 如果父级已链接到 URI,则子部署将是父 URI 和 relativePath URI 的组合 |
| uri |
string |
要部署的模板的 URI。 使用 URI 或 ID 属性,但不能同时使用这两个属性。 |
UserAssignedIdentity
用户分配的标识属性
| 名称 | 类型 | 说明 |
|---|---|---|
| clientId |
string (uuid) |
分配的标识的客户端 ID。 |
| principalId |
string (uuid) |
已分配标识的主体 ID。 |
ValidationLevel
对部署执行的验证级别。
| 值 | 说明 |
|---|---|
| Template |
对模板进行静态分析。 |
| Provider |
对模板进行静态分析,并将资源声明发送到资源提供程序进行语义验证。 验证调用方是否对每个资源具有 RBAC 写入权限。 |
| ProviderNoRbac |
对模板进行静态分析,并将资源声明发送到资源提供程序进行语义验证。 跳过验证调用方是否对每个资源具有 RBAC 写入权限。 |
ZoneMapping
| 名称 | 类型 | 说明 |
|---|---|---|
| location |
string |
区域映射的位置。 |
| zones |
string[] |