azure 如何将PowerBI嵌入式容量链接到terraform中的PowerBI工作区

gk7wooem  于 2023-06-30  发布在  其他
关注(0)|答案(1)|浏览(108)

我运行下面的terraform代码

resource "azurerm_powerbi_embedded" "powerbi" {
  count               = var.environment != "dev" ? 0 : 1
  name                = "biarm${var.app_name}${var.environment}"
  location            = var.location
  resource_group_name = "rg-arm-${var.app_name}-${var.environment}"
  sku_name            = "A1"
  mode                = "Gen2"
  administrators      = [module.pbi_object_id.env_shared_kv_secret_value, data.azuread_client_config.current.object_id]
  provider            = azurerm.saas-shared
}
provider "powerbi" {
  tenant_id     = data.azuread_client_config.current.tenant_id
  client_id     = module.pbi_client_id.env_shared_kv_secret_value
  client_secret = module.pbi_secret.env_shared_kv_secret_value
}

resource "powerbi_workspace" "myworkspace" {
  name        = "Workspace for ${var.environment}-${var.location}-${var.instance_number}"
  capacity_id = azurerm_powerbi_embedded.powerbi.id
}

此代码失败,并出现以下错误

│ Error: Capacity id /subscriptions/xxxxxxx-9a95-4b71-8290-0f8b11f4d5f5/resourceGroups/rg-arm-shared-dev/providers/Microsoft.PowerBIDedicated/capacities/biarmshareddev not found or logged-in user doesn't have capacity admin rights
│
│   with powerbi_workspace.myworkspace,
│   on power-bi.tf line 61, in resource "powerbi_workspace" "myworkspace":
│   61: resource "powerbi_workspace" "myworkspace" {
│

azurerm_powerbi_embedded只公开一个属性,即id。这不是GUID,而是Azure资源ID。powerbi_workspace需要capacity id,它似乎是GUID。我的问题是,是否有可能在terraform中建立这种连接,或者我应该单独创建这些资源,然后在powerbi portal中连接它们。

mo49yndu

mo49yndu1#

我检查了以下代码。

data "azuread_application" "name" {
  display_name = "powbiapp"
}

data "azuread_service_principal" "svp" {
  application_id = data.azuread_application.name.application_id
}

resource "azurerm_powerbi_embedded" "example" {
  name                = "powerbiapp"
  location            = data.azurerm_resource_group.example.location
  resource_group_name = data.azurerm_resource_group.example.name
  sku_name            = "A1"
  administrators      = [data.azuread_client_config.current.object_id  , data.azurerm_client_config.current.object_id, data.azuread_service_principal.svp.object_id  ]
}

provider "powerbi" {
  tenant_id     = "7xxxx"
  client_id     = "8xxxxxxxxxx5"
  client_secret = "eYjxxxxxxxxxIcv-"
}

确保用户具有管理员权限,如Office 365全局管理员或*Power BI服务管理员。***
并检查委派权限和应用程序权限。
检查是否添加了访问PowerBi所需的所有权限(如容量管理员权限),如果未使用服务主体,请确保Tenant.ReadWrite.All权限Capacity.Read.All权限已
授予管理员同意。**

如果用户是某个工作区的管理员,则将该工作区分配给某个容量的用户分配为具有参与者权限的用户。
根据需要添加电源BI管理员角色。

相关问题