0

我想使用 Azuread Provider 创建一个应用注册,并将 applictionid 输出用于我的 appservice 中的配置。每次我计划时,我都会收到一条错误消息。如果我删除配置行,一切正常。

我试图将 App-Registration 放在一个模块中并使用输出,但我得到了同样的错误。

有人有建议吗?

//Azure App Registration
  resource "azuread_application" "appregistration" {
  name                       = "${var.state}Site-${var.typ}-ar"
  reply_urls                 = ["https://${azurerm_app_service.appservice.default_site_hostname}/signin-callback"]
  available_to_other_tenants = false
  oauth2_allow_implicit_flow = true
}
resource "azuread_application_password" "AppRegistrationPwd" {
  application_object_id = "${azuread_application.appregistration.id}"
  value                 = "SOMECODE"
  end_date              = "2020-01-01T01:02:03Z"
}
resource "azuread_service_principal" "serviceprincipal" {
  application_id                = "${azuread_application.appregistration.application_id}"
  app_role_assignment_required  = false
}

应用服务

resource "azurerm_app_service" "appservice" {
    name = "${var.state}-Site-${var.typ}-as"
    location = "${var.location}"
    resource_group_name = "${azurerm_app_service_plan.serviceplan.resource_group_name}"
    app_service_plan_id = "${azurerm_app_service_plan.serviceplan.id}"

    site_config {
    dotnet_framework_version = "v4.0"
    scm_type                 = "LocalGit"
  }

    app_settings = {
    "AzureAd:ClientId"  = "${azuread_service_principal.serviceprincipal.application_id}"


  }



  }

错误:

Error: Cycle: module.devcentralhub.azuread_service_principal.serviceprincipal, module.devcentralhub.azurerm_app_service.appservice, module.devcentralhub.azuread_application.appregistration
4

1 回答 1

1

您的理解与您的评论一样,资源azurerm_app_service需要application_id来自资源azuread_service_principal,而资源azuread_service_principal需要应用服务名称在 中reply_urls,因此会导致循环。

要打破循环,您可以指定${azurerm_app_service.appservice.default_site_hostname}via,${var.state}-Site-${var.typ}-as.azurewebsites.net因为通常这两个值是相同的。

reply_urls = ["https://${var.state}-Site-${var.typ}-as.azurewebsites.net/signin-callback"]在您的代码中更改为。

于 2019-09-06T09:20:07.970 回答