"unexpected nil value for service tag information" 使用 data.azurerm_network_service_tags 时

"unexpected nil value for service tag information" when using data.azurerm_network_service_tags

我在使用 data.azurerm_network_service_tags terraform 数据源时遇到以下错误:

Error: unexpected nil value for service tag information

  on main.tf line 171, in data "azurerm_network_service_tags" "sqlservicetags":
 171: data "azurerm_network_service_tags" "sqlservicetags" {

我的代码如下所示:

data "azurerm_network_service_tags" "sqlservicetags" {
  location        = "UK South"
  service         = "Sql"
  location_filter = "uksouth"
}

我在另一个 Azure 帐户上尝试了这个完全相同的代码并且它工作正常,所以帐户中一定有不同的东西导致了这个错误,虽然我无法弄清楚。

知道可能是什么问题吗?

如评论中所述,请与您的管理员检查您在有问题的订阅中的权限级别

您需要对订阅具有 Contributor 访问权限或 Network Contributor 访问权限才能查看订阅中所需的详细信息。如果管理员难以提供贡献者级别的访问权限,那么您还可以创建一个 custom role 操作 Microsoft.Network/locations/serviceTagDetails/read获取服务标签详情 & Microsoft.Network/locations/serviceTags/read获取服务标签 在所需的订阅上。

有关 Built-in RolesResource Provider Opertaions 的更多详细信息 你可以参考这个 Microsoft Document.