azure - Azure - 未找到与请求 URI 匹配的 HTTP 资源
问题描述
我正在使用 YAML 管道从 Azure Devops 创建一个资源组。下面是我在管道中使用的 Azure 任务的片段。
- task: AzureResourceGroupDeployment@2
displayName: 'Deploy RG'
inputs:
azureSubscription: 'my-servicePrinciple (SPN)'
resourceGroupName: 'test-rg-001'
location: 'westeurope'
templateLocation: 'Linked artifact'
csmFile: $(Pipeline.Workspace)/arm_templates/ResourceGroup/template.json
csmParametersFile: $(Pipeline.Workspace)/arm_templates/ResourceGroup/parameter.json
deploymentMode: Incremental
这是我的 template.json 文件的内容
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"rgName": {
"type": "string"
},
"rgLocation": {
"type": "string"
},
"tags": {
"type": "object",
"defaultValue": {}
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2020-06-01",
"location": "[parameters('rgLocation')]",
"name": "[parameters('rgName')]",
"properties": {},
"tags": "[parameters('tags')]"
}
],
"outputs": {}
}
管道失败并出现以下错误。
No HTTP resource was found that matches the request URI 'https://management.azure.com/subscriptions/xx4873gx-4yy1-4092-9a70-34812353vv77/resourcegroups/test-rg-001/providers/Microsoft.Resources/resourceGroups/test-rg-001?api-version=2020-06-01'
我在互联网上查找是什么原因造成的,但没有希望。我也尝试过在我的 template.json 中使用以下模式,但这也不起作用。
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#"
奇怪的是,管道创建了我想要的资源组,但是我无法理解部署失败的原因。为了获得更多详细信息,我查看了门户中的部署菜单,这是扩展错误
{
"code": "DeploymentFailed",
"message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.",
"details": [
{
"message": "No HTTP resource was found that matches the request URI 'https://management.azure.com/subscriptions/xx4873gx-4yy1-4092-9a70-34812353vv77/resourcegroups/test-rg-001/providers/Microsoft.Resources/resourceGroups/test-rg-001?api-version=2020-06-01'."
}
]
}
使用 ARM 模板,我只想创建资源组,不想包括任何其他资源的部署。有人已经闻到了,这里的烹饪有什么问题吗?:D
解决方案
您看到上述错误是因为您试图在管道中的资源组内创建资源组。
在您的管道中使用上述任务 AzureResourceGroupDeployment 配置。您正在资源组中创建一个资源组(即test-rg-001
)test-rg-001
。如果它没有找到您在resourceGroupName
参数中指定的资源组(即test-rg-001),它将自动创建一个资源组。这就是为什么您看到资源组test-rg-001
被奇怪地创建了。看到这个类似的问题。
您可以使用任务AzureResourceManagerTemplateDeployment将 设置Deployment scope
为Subscription
而不是Resource Group
. 见下文:
steps:
- task: AzureResourceManagerTemplateDeployment@3
displayName: 'ARM Template deployment: Subscription scope'
inputs:
deploymentScope: Subscription
azureResourceManagerConnection: 'my-servicePrinciple (SPN)'
location: 'West Europe'
csmFile: $(Pipeline.Workspace)/arm_templates/ResourceGroup/template.json
csmParametersFile: $(Pipeline.Workspace)/arm_templates/ResourceGroup/parameter.json
deploymentMode: Incremental
推荐阅读
- image - React 中的图像:是否可以使用来自导入对象的字符串作为图像的源路径?
- git - GIT 在创建新分支时将哪个分支视为源分支?
- java - 如何添加共享库(设置为使用“隔离类加载器”)Websphere?
- java - 如何进行远程 PSSession 并在远程桌面上运行脚本?
- microsoft-graph-api - 如何使用为 MS Teams 创建新的聊天线程“提及”某人
- angular - 405(方法不允许)Ionic 3 RestAPI
- php - 有没有办法通过索引访问行列而不是命名它?
- java - Java 线程(初学者)
- php - PHP如何替换字符串的第二个字符,如果它是一个空格
- c++ - 模板模板函数未按预期推断参数