您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

排查使用 Azure 资源管理器时的常见 Azure 部署错误Troubleshoot common Azure deployment errors with Azure Resource Manager

本文介绍我们可能会遇到的一些常见 Azure 部署错误,并提供有关如何解决这些错误的信息。This article describes some common Azure deployment errors you may encounter, and provides information to resolve the errors. 如果找不到部署错误的错误代码,请参阅查找错误代码If you cannot find the error code for your deployment error, see Find error code.

错误代码Error codes

错误代码Error code 缓解措施Mitigation 详细信息More information
AccountNameInvalidAccountNameInvalid 遵循存储帐户的命名限制。Follow naming restrictions for storage accounts. 解析存储帐户名称Resolve storage account name
AccountPropertyCannotBeSetAccountPropertyCannotBeSet 检查可用的存储帐户属性。Check available storage account properties. storageAccountsstorageAccounts
AllocationFailedAllocationFailed 群集或区域没有可用的资源或无法支持所请求的 VM 大小。The cluster or region does not have resources available or cannot support the requested VM size. 稍后重试请求,或者请求不同的 VM 大小。Retry the request at a later time, or request a different VM size. Linux 预配和分配问题Windows 预配和分配问题Provisioning and allocation issues for Linux and Provisioning and allocation issues for Windows
AnotherOperationInProgressAnotherOperationInProgress 等待并发操作完成。Wait for concurrent operation to complete.
AuthorizationFailedAuthorizationFailed 帐户或服务主体没有足够的访问权限,无法完成部署。Your account or service principal does not have sufficient access to complete the deployment. 检查帐户所属的角色及其在部署范围内的访问权限。Check the role your account belongs to, and its access for the deployment scope. Azure 基于角色的访问控制Azure Role-Based Access Control
BadRequestBadRequest 发送的部署值与资源管理器预期的值不匹配。You sent deployment values that do not match what is expected by Resource Manager. 检查内部状态消息,以帮助进行故障排除。Check the inner status message for help with troubleshooting. 模板引用支持的位置Template reference and Supported locations
冲突Conflict 请求的操作在资源的当前状态下不受允许。You are requesting an operation that is not permitted in the resource's current state. 例如,仅当创建 VM 或该 VM 已解除分配时,才允许调整磁盘大小。For example, disk resizing is allowed only when creating a VM or when the VM is deallocated.
DeploymentActiveDeploymentActive 等待此资源组上的并发部署完成。Wait for concurrent deployment to this resource group to complete.
DeploymentFailedDeploymentFailed DeploymentFailed 错误为常规错误,不提供解决错误所需的详细信息。The DeploymentFailed error is a general error that does not provide the details you need to solve the error. 请查看错误代码的错误详情,其中提供了详细信息。Look in the error details for an error code that provides more information. 查找错误代码Find error code
DeploymentQuotaExceededDeploymentQuotaExceeded 如果达到每个资源组的部署数限制 800,则会从历史记录中删除不再需要的部署。If you reach the limit of 800 deployments per resource group, delete deployments from the history that are no longer needed. 可以使用 Azure CLI 的 az group deployment delete 或 PowerShell 中的 Remove-AzureRmResourceGroupDeployment 删除历史记录中的条目。You can delete entries from the history with az group deployment delete for Azure CLI, or Remove-AzureRmResourceGroupDeployment in PowerShell. 从部署历史记录中删除条目不会影响部署资源。Deleting an entry from the deployment history does not affect the deploy resources.
DnsRecordInUseDnsRecordInUse DNS 记录名称必须唯一。The DNS record name must be unique. 提供不同的名称,或修改现有记录。Either provide a different name, or modify the existing record.
ImageNotFoundImageNotFound 检查 VM 映像设置。Check VM image settings.
InUseSubnetCannotBeDeletedInUseSubnetCannotBeDeleted 如果尝试更新资源,但已通过删除并创建资源处理了请求,则可能会遇到此错误。You may encounter this error when attempting to update a resource, but the request is processed by deleting and creating the resource. 确保指定所有未更改值。Make sure to specify all unchanged values. 更新资源Update resource
InvalidAuthenticationTokenTenantInvalidAuthenticationTokenTenant 获取相应租户的访问令牌。Get access token for the appropriate tenant. 只能从帐户所属的租户获取该令牌。You can only get the token from the tenant that your account belongs to.
InvalidContentLinkInvalidContentLink 很可能尝试过链接到不可用的嵌套模板。You have most likely attempted to link to a nested template that is not available. 再次确认为嵌套模板提供的 URI。Double check the URI you provided for the nested template. 如果模板存在于存储帐户中,请确保 URI 可访问。If the template exists in a storage account, make sure the URI is accessible. 可能需要传递 SAS 令牌。You may need to pass a SAS token. 链接的模板Linked templates
InvalidParameterInvalidParameter 为资源提供的某个值与预期值不匹配。One of the values you provided for a resource does not match the expected value. 此错误可能由许多不同的状况造成。This error can result from many different conditions. 例如,密码强度可能不足,或者 Blob 名称可能不正确。For example, a password may be insufficient, or a blob name may be incorrect. 检查错误消息,确定需要更正哪个值。Check the error message to determine which value needs to be corrected.
InvalidRequestContentInvalidRequestContent 部署值包含意外的值,或者缺少必需的值。Your deployment values either include values that are not expected or are missing required values. 确认资源类型的值。Confirm the values for your resource type. 模板参考Template reference
InvalidRequestFormatInvalidRequestFormat 执行部署时启用调试日志记录,并验证请求的内容。Enable debug logging when executing the deployment, and verify the contents of the request. 调试日志记录Debug logging
InvalidResourceNamespaceInvalidResourceNamespace 检查在 type 属性中指定的资源命名空间。Check the resource namespace you specified in the type property. 模板参考Template reference
InvalidResourceReferenceInvalidResourceReference 资源尚不存在,或错误地引用了它。The resource either does not yet exist or is incorrectly referenced. 检查是否需要添加依赖项。Check whether you need to add a dependency. 验证所用的 reference 函数是否包含方案所需的参数。Verify that your use of the reference function includes the required parameters for your scenario. 解决依赖项问题Resolve dependencies
InvalidResourceTypeInvalidResourceType 检查在 type 属性中指定的资源类型。Check the resource type you specified in the type property. 模板参考Template reference
InvalidSubscriptionRegistrationStateInvalidSubscriptionRegistrationState 将订阅注册到资源提供程序。Register your subscription with the resource provider. 解决注册问题Resolve registration
InvalidTemplateInvalidTemplate 检查模板语法是否有错误。Check your template syntax for errors. 解决模板无效问题Resolve invalid template
InvalidTemplateCircularDependencyInvalidTemplateCircularDependency 删除不必要的依赖项。Remove unnecessary dependencies. 解决循环依赖项Resolve circular dependencies
LinkedAuthorizationFailedLinkedAuthorizationFailed 检查帐户所属的租户是否与要部署到的资源组所属的租户相同。Check if your account belongs to the same tenant as the resource group you are deploying to.
LinkedInvalidPropertyIdLinkedInvalidPropertyId 无法正确解析资源的资源 ID。The resource ID for a resource is not resolving correctly. 检查是否为资源 ID 提供了所有必需值,包括订阅 ID、资源组名称、资源类型、父资源名称(如果需要)和资源名称。Check that you provide all required values for the resource ID, including subscription ID, resource group name, resource type, parent resource name (if needed), and resource name.
LocationRequiredLocationRequired 提供资源的位置。Provide a location for your resource. 设置位置Set location
MismatchingResourceSegmentsMismatchingResourceSegments 请确保嵌套资源的名称和类型中包含正确数量的段。Make sure nested resource has correct number of segments in name and type. 解决资源段Resolve resource segments
MissingRegistrationForLocationMissingRegistrationForLocation 检查资源提供程序注册状态和支持的位置。Check resource provider registration status, and supported locations. 解决注册问题Resolve registration
MissingSubscriptionRegistrationMissingSubscriptionRegistration 将订阅注册到资源提供程序。Register your subscription with the resource provider. 解决注册问题Resolve registration
NoRegisteredProviderFoundNoRegisteredProviderFound 检查资源提供程序注册状态。Check resource provider registration status. 解决注册问题Resolve registration
NotFoundNotFound 可能正在尝试同时部署依赖资源和父资源。You may be attempting to deploy a dependent resource in parallel with a parent resource. 检查是否需要添加依赖项。Check if you need to add a dependency. 解决依赖项问题Resolve dependencies
OperationNotAllowedOperationNotAllowed 部署正在尝试执行一个超过了订阅、资源组或区域配额的操作。The deployment is attempting an operation that exceeds the quota for the subscription, resource group, or region. 如果可能,请修改部署,以保持在配额范围内。If possible, revise your deployment to stay within the quotas. 否则,请考虑请求更改配额。Otherwise, consider requesting a change to your quotas. 解决配额问题Resolve quotas
ParentResourceNotFoundParentResourceNotFound 确保在创建子资源之前父资源已存在。Make sure a parent resource exists before creating the child resources. 解决父资源问题Resolve parent resource
PrivateIPAddressInReservedRangePrivateIPAddressInReservedRange 指定的 IP 地址包括 Azure 所需的地址范围。The specified IP address includes an address range required by Azure. 更改 IP 地址以避免保留的范围。Change IP address to avoid reserved range. IP 地址IP addresses
PrivateIPAddressNotInSubnetPrivateIPAddressNotInSubnet 指定的 IP 地址超出子网范围。The specified IP address is outside of the subnet range. 更改 IP 地址,使之在子网范围内。Change IP address to fall within subnet range. IP 地址IP addresses
PropertyChangeNotAllowedPropertyChangeNotAllowed 无法在已部署的资源上更改某些属性。Some properties cannot be changed on a deployed resource. 更新资源时,请限制为对允许的属性进行更改。When updating a resource, limit your changes to permitted properties. 更新资源Update resource
RequestDisallowedByPolicyRequestDisallowedByPolicy 订阅包含阻止尝试在部署期间执行的操作的资源策略。Your subscription includes a resource policy that prevents an action you are trying to perform during deployment. 查找阻止该操作的策略。Find the policy that blocks the action. 如果可能,请修改部署,以满足策略中的限制。If possible, modify your deployment to meet the limitations from the policy. 解决策略问题Resolve policies
ReservedResourceNameReservedResourceName 提供不包含保留名称的资源名称。Provide a resource name that does not include a reserved name. 保留的资源名称Reserved resource names
ResourceGroupBeingDeletedResourceGroupBeingDeleted 等待删除操作完成。Wait for deletion to complete.
ResourceGroupNotFoundResourceGroupNotFound 检查部署的目标资源组的名称。Check the name of the target resource group for the deployment. 该名称必须已在订阅中存在。It must already exist in your subscription. 检查订阅上下文。Check your subscription context. Azure CLI PowerShellAzure CLI PowerShell
ResourceNotFoundResourceNotFound 部署引用了一个无法解析的资源。Your deployment references a resource that cannot be resolved. 验证所用的 reference 函数是否包含方案所需的参数。Verify that your use of the reference function includes the parameters required for your scenario. 解决引用问题Resolve references
ResourceQuotaExceededResourceQuotaExceeded 部署尝试创建的资源超过了订阅、资源组或区域的配额。The deployment is attempting to create resources that exceed the quota for the subscription, resource group, or region. 如果可能,请修改基础结构,以保持在配额范围内。If possible, revise your infrastructure to stay within the quotas. 否则,请考虑请求更改配额。Otherwise, consider requesting a change to your quotas. 解决配额问题Resolve quotas
SkuNotAvailableSkuNotAvailable 选择可在所选位置中使用的 SKU(例如 VM 大小)。Select SKU (such as VM size) that is available for the location you have selected. 解决 SKU 问题Resolve SKU
StorageAccountAlreadyExistsStorageAccountAlreadyExists 为存储帐户提供唯一名称。Provide a unique name for the storage account. 解析存储帐户名称Resolve storage account name
StorageAccountAlreadyTakenStorageAccountAlreadyTaken 为存储帐户提供唯一名称。Provide a unique name for the storage account. 解析存储帐户名称Resolve storage account name
StorageAccountNotFoundStorageAccountNotFound 检查尝试使用的存储帐户的订阅、资源组和名称。Check the subscription, resource group, and name of the storage account you are attempting to use.
SubnetsNotInSameVnetSubnetsNotInSameVnet 一个虚拟机只能有一个虚拟网络。A virtual machine can only have one virtual network. 部署多个 NIC 时,请确保它们属于同一虚拟网络。When deploying multiple NICs, make sure they belong to the same virtual network. 多个 NICMultiple NICs
TemplateResourceCircularDependencyTemplateResourceCircularDependency 删除不必要的依赖项。Remove unnecessary dependencies. 解决循环依赖项Resolve circular dependencies
TooManyTargetResourceGroupsTooManyTargetResourceGroups 减少单个部署的资源组数。Reduce number of resource groups for a single deployment. 跨资源组部署Cross resource group deployment

查找错误代码Find error code

可能接收到的错误有两种类型:There are two types of errors you can receive:

  • 验证错误validation errors
  • 部署错误deployment errors

验证错误源于部署之前可确定的方案。Validation errors arise from scenarios that can be determined before deployment. 原因包括模板中的语法错误,或尝试部署超出订阅配额的资源。They include syntax errors in your template, or trying to deploy resources that would exceed your subscription quotas. 部署错误源于部署过程中发生的条件。Deployment errors arise from conditions that occur during the deployment process. 原因包括尝试访问并行部署的资源。They include trying to access a resource that is being deployed in parallel.

两种类型的错误都会返回用于对部署进行故障排除的错误代码。Both types of errors return an error code that you use to troubleshoot the deployment. 两种类型的错误都会显示在活动日志中。Both types of errors appear in the activity log. 但是,验证错误不会显示在部署历史记录中,因为部署从未启动。However, validation errors do not appear in your deployment history because the deployment never started.

验证错误Validation errors

通过门户部署时,提交值后会看到验证错误。When deploying through the portal, you see a validation error after submitting your values.

显示门户验证错误

选择消息获取更多详细信息。Select the message for more details. 下图显示了一条 InvalidTemplateDeployment 错误,以及一条指出策略阻止了部署的消息。In the following image, you see an InvalidTemplateDeployment error and a message that indicates a policy blocked deployment.

显示验证详细信息

部署错误Deployment errors

如果操作通过了验证但部署期间失败,则通知中会出现错误。When the operation passes validation, but fails during deployment, you see the error in the notifications. 选择通知。Select the notification.

通知错误

查看有关部署的更多详细信息。You see more details about the deployment. 选择查找有关错误的详细信息的选项。Select the option to find more information about the error.

部署失败

看到错误消息和错误代码。You see the error message and error codes. 请注意有两个错误代码。Notice there are two error codes. 第一个错误代码 (DeploymentFailed) 表示常规错误,不提供解决错误所需的详细信息。The first error code (DeploymentFailed) is a general error that doesn't provide the details you need to solve the error. 第二个错误代码 (StorageAccountNotFound) 提供所需的详细信息。The second error code (StorageAccountNotFound) provides the details you need.

错误详细信息

启用调试日志记录Enable debug logging

有时需要有关请求和响应的详细信息才能了解出现的问题。Sometimes you need more information about the request and response to learn what went wrong. 使用 PowerShell 或 Azure CLI 可以请求在部署期间记录更多信息。By using PowerShell or Azure CLI, you can request that additional information is logged during a deployment.

  • PowerShellPowerShell

    在 PowerShell 中,将 DeploymentDebugLogLevel 参数设置为 All、ResponseContent 或 RequestContent。In PowerShell, set the DeploymentDebugLogLevel parameter to All, ResponseContent, or RequestContent.

    New-AzureRmResourceGroupDeployment -ResourceGroupName examplegroup -TemplateFile c:\Azure\Templates\storage.json -DeploymentDebugLogLevel All
    

    使用以下 cmdlet 检查请求内容:Examine the request content with the following cmdlet:

    (Get-AzureRmResourceGroupDeploymentOperation -DeploymentName storageonly -ResourceGroupName startgroup).Properties.request | ConvertTo-Json
    

    或者,使用以下信息检查响应内容:Or, the response content with:

    (Get-AzureRmResourceGroupDeploymentOperation -DeploymentName storageonly -ResourceGroupName startgroup).Properties.response | ConvertTo-Json
    

    此信息可帮助确定模板中某个值的设置是否错误。This information can help you determine whether a value in the template is being incorrectly set.

  • Azure CLIAzure CLI

    使用以下命令查看部署操作:Examine the deployment operations with the following command:

    az group deployment operation list --resource-group ExampleGroup --name vmlinux
    
  • 嵌套模板Nested template

    若要记录嵌套模板的调试信息,请使用 debugSetting 元素。To log debug information for a nested template, use the debugSetting element.

    {
        "apiVersion": "2016-09-01",
        "name": "nestedTemplate",
        "type": "Microsoft.Resources/deployments",
        "properties": {
            "mode": "Incremental",
            "templateLink": {
                "uri": "{template-uri}",
                "contentVersion": "1.0.0.0"
            },
            "debugSetting": {
               "detailLevel": "requestContent, responseContent"
            }
        }
    }
    

创建故障排除模板Create a troubleshooting template

在某些情况下,排除模板故障的最简单方法是测试部分模板。In some cases, the easiest way to troubleshoot your template is to test parts of it. 可以创建一个简化的模板,通过该模板将测试重点放在最可能导致错误的部分。You can create a simplified template that enables you to focus on the part that you believe is causing the error. 例如,假设在引用资源时收到错误消息。For example, suppose you are receiving an error when referencing a resource. 创建一个模板,该模板返回可能导致问题的部分,而不是处理整个模板。Rather than dealing with an entire template, create a template that returns the part that may be causing your problem. 这可以帮助确定传入的是否是正确的参数,是否正确使用模板函数,以及是否获得所需的资源。It can help you determine whether you are passing in the right parameters, using template functions correctly, and getting the resource you expect.

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "storageName": {
        "type": "string"
    },
    "storageResourceGroup": {
        "type": "string"
    }
  },
  "variables": {},
  "resources": [],
  "outputs": {
    "exampleOutput": {
        "value": "[reference(resourceId(parameters('storageResourceGroup'), 'Microsoft.Storage/storageAccounts', parameters('storageName')), '2016-05-01')]",
        "type" : "object"
    }
  }
}

或者,假设遇到认为与不正确设置的依赖项相关的部署错误。Or, suppose you are encountering deployment errors that you believe are related to incorrectly set dependencies. 通过将模板分解为多个简化模板进行测试。Test your template by breaking it into simplified templates. 首先,创建仅部署单个资源(如 SQL Server)的模板。First, create a template that deploys only a single resource (like a SQL Server). 确定已正确定义该资源后,添加依赖于该资源的资源(如 SQL 数据库)。When you are sure you have that resource correctly defined, add a resource that depends on it (like a SQL Database). 正确定义这两个资源后,添加其他从属资源(如审核策略)。When you have those two resources correctly defined, add other dependent resources (like auditing policies). 在每个测试部署之间,删除资源组,以确保充分测试依赖关系。In between each test deployment, delete the resource group to make sure you adequately testing the dependencies.

后续步骤Next steps