gpt4 book ai didi

azure - 逻辑应用消费 API 连接 - ARM 模板函数

转载 作者:行者123 更新时间:2023-12-03 05:19:18 27 4
gpt4 key购买 nike

我尝试对 Microsoft.Web/connections api id 属性使用 resourceid() 函数而不是 concat()。

如果我像这样使用 concat,它会起作用:

{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[parameters('Office365_ConnectionName')]",
"location": "[parameters('logicApp_Location')]",
"kind": "V1",
"properties": {
"displayName": "[parameters('Office365_ConnectionDisplayName')]",
"customParameterValues": {},
"api": {
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('logicApp_Location'), '/managedApis/', 'office365')]"
}
}
}

如果我尝试使用resourceid(),我会收到一个错误的请求:

    {
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[parameters('Office365_ConnectionName')]",
"location": "[parameters('logicApp_Location')]",
"kind": "V1",
"properties": {
"displayName": "[parameters('Office365_ConnectionDisplayName')]",
"customParameterValues": {},
"api": {
"id": "[resourceId('Microsoft.Web/locations/managedApis', parameters('logicApp_Location'), 'office365')]"
}
}
}

InvalidRequestContent: The request content is not valid and could not be deserialized:'The 'id' property '/subscriptions/xxxx/resourceGroups/xxxxx/providers/Microsoft.Web/locations/westeurope/managedApis/office365' under 'properties.api' is not valid.'

我是否正确使用了resourceid()函数?

最佳答案

在我这边重现问题后,我发现您收到此消息是因为您正在使用 resourceId() 函数,该函数返回没有任何定义的单个资源的 Id模板部署到的级别。

Returns the unique identifier of a resource. You use this function when the resource name is ambiguous or not provisioned within the same template. The format of the returned identifier varies based on whether the deployment happens at the scope of a resource group, subscription, management group, or tenant.

subscriptionResourceId()函数,它获取部署在订阅级别的资源的ID,该ID实际上需要包含在properties.api中。

Returns the unique identifier for a resource deployed at the subscription level.

在您的情况下,下面将是模板

    {
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[parameters('Office365_ConnectionName')]",
"location": "[parameters('logicApp_Location')]",
"kind": "V1",
"properties": {
"displayName": "[parameters('Office365_ConnectionDisplayName')]",
"customParameterValues": {},
"api": {
"id": "[subscriptionResourceId('Microsoft.Web/locations/managedApis', parameters('logicApp_Location'), 'office365')]"
}
}
}

使用resourceId()函数时的结果

enter image description here

使用 subscriptionResourceId() 函数时的结果

enter image description here

引用文献: Template functions - MSFT Docs

关于azure - 逻辑应用消费 API 连接 - ARM 模板函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73529379/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com