Terraform 后端无法连接到存储帐户
Terraform backend cannot connect to storage account
这是我的 terraform.tf
terraform {
backend "azurerm" {
resource_group_name = "tstate"
storage_account_name = "strorageaccount1"
container_name = "terraform.tfstate"
access_key = "asdfg45454..."
}
}
当我的存储帐户不在“所有网络”中时,此操作失败。我的存储帐户网络设置如下。 Blob 存储私有或 public 它可以工作,所以没有问题。但是必须启用“所有网络”才能使其工作。我怎样才能让它在禁用“所有网络”的情况下工作?我得到的错误如下:
Error: Failed to get existing workspaces: storage: service returned
error: StatusCode=403, ErrorCode=AuthorizationFailure,
ErrorMessage=This request is not authorized to perform this operation.
不需要 IP 或 Vnet,因为 Azure 默认代理是 运行 devops 管道。 SPN 拥有订阅的所有者访问权限。我错过了什么?
好吧,您明确禁止几乎所有服务(或服务器)访问您的存储帐户。除了“trusted Microsoft services”。但是,您的 Azure DevOps Build Agent 不属于该类别。
因此,您需要先将构建代理列入白名单。有两种方法可以做到这一点:
- 使用您在 VNET 中 运行 的自托管代理。然后在存储帐户的防火墙规则中允许从该 VNET 访问
- 如果您想坚持使用托管构建代理:运行 首先是 AZ CLI 或 Azure Powershell 脚本,它会获取构建代理的 public IP (https://api.ipify.org) and add that to your firewall。 terraform 完成后,使用另一个脚本再次删除该 IP 异常。
这是我的 terraform.tf
terraform {
backend "azurerm" {
resource_group_name = "tstate"
storage_account_name = "strorageaccount1"
container_name = "terraform.tfstate"
access_key = "asdfg45454..."
}
}
当我的存储帐户不在“所有网络”中时,此操作失败。我的存储帐户网络设置如下。 Blob 存储私有或 public 它可以工作,所以没有问题。但是必须启用“所有网络”才能使其工作。我怎样才能让它在禁用“所有网络”的情况下工作?我得到的错误如下:
Error: Failed to get existing workspaces: storage: service returned error: StatusCode=403, ErrorCode=AuthorizationFailure, ErrorMessage=This request is not authorized to perform this operation.
不需要 IP 或 Vnet,因为 Azure 默认代理是 运行 devops 管道。 SPN 拥有订阅的所有者访问权限。我错过了什么?
好吧,您明确禁止几乎所有服务(或服务器)访问您的存储帐户。除了“trusted Microsoft services”。但是,您的 Azure DevOps Build Agent 不属于该类别。
因此,您需要先将构建代理列入白名单。有两种方法可以做到这一点:
- 使用您在 VNET 中 运行 的自托管代理。然后在存储帐户的防火墙规则中允许从该 VNET 访问
- 如果您想坚持使用托管构建代理:运行 首先是 AZ CLI 或 Azure Powershell 脚本,它会获取构建代理的 public IP (https://api.ipify.org) and add that to your firewall。 terraform 完成后,使用另一个脚本再次删除该 IP 异常。