Terraform:在Azure中指定后端类型
上下文:在手动在Azure中部署后端服务时, 提示我选择类型:自定义,Azure或服务面料。
如何通过Terraform声明类型(我想选择Azure资源)并说我要使用哪个应用程序? 根据文档,它说使用该应用程序的资源ID(我在部署开始时生成),然后我尝试了:
resource "azurerm_api_management_backend" "polo-backend" {
name = "polo-backend"
resource_group_name = azurerm_resource_group.polo-rg.name
api_management_name = azurerm_api_management.polo-api-mgmt.name
protocol = "http"
url = "https://myurl"
resource_id = azurerm_windows_web_app.app-service.id
}
但是它给了我这个错误:
错误:创建 /更新后端:(名称“ polo-backend” / service名称“ polo-api-mgmt” / resource group“ polo1-default-rg”):apimanagement.backendclient#createorupdate:失败响应对 请求:statuscode = 400-原始错误:Autorest/Azure:服务返回错误。 status = 400代码=“ validationError” messages =“一个或多个字段包含不正确的值:” ResourceD“}]
此外。如果应用程序是用Terraform生成的,我该如何在URL部分中动态分配URL?
Context: While manually deploying a backend service in AZURE,
I am prompted to select the type: custom, azure or service fabric.
How can I declare via terraform the type (I would like to select Azure resource) and say which app I want to use?
As per documentation it says to use a resource id of the app (that i generate at the start of the deployment) and I tried this:
resource "azurerm_api_management_backend" "polo-backend" {
name = "polo-backend"
resource_group_name = azurerm_resource_group.polo-rg.name
api_management_name = azurerm_api_management.polo-api-mgmt.name
protocol = "http"
url = "https://myurl"
resource_id = azurerm_windows_web_app.app-service.id
}
But it gives me this error:
Error: creating/updating Backend: (Name "polo-backend" / Service Name "polo-api-mgmt" / Resource Group "polo1-default-rg"): apimanagement.BackendClient#CreateOrUpdate: Failure responding to
request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="ValidationError" Message="One or more fields contain incorrect values:" Details=[{"code":"ValidationError","message":"Value should represent absolute http URL","target":"resourceId"}]
Furthermore.. if the app is generated with terraform how can I assign the URL dynamically in the URL section?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,我找到了我问题的答案:
基本上,您必须将资源ID(文字网址)传递给所需的资源。通过参数传递它,到目前为止不支持它,或者我试图分配的那个论点是错误的。
因此,我设法做的是使用数据模块尽可能多地“模板化”代码:
如果有人有更好的解决方案,请随时建议!
编辑:
感谢您的答案 - 我能够使用以下方式解决错误:
So I found the answer to my question:
Basically you have to pass to the resource id, the literal URL to the desired resource. passing it via arguments it's not supported as of now OR that argument I was trying to assign is wrong.
So what I managed to do was using the data module to "template-ify" the code as much as I can:
IF anyone has a better solution than this please feel free to suggest!
EDIT:
Thanks for this answer - I was able to resolve the error using: