2

有没有办法像 Azure SQL 一样将虚拟网络规则添加到存储帐户?有azurerm_sql_virtual_network_rule但似乎没有存储帐户的等效项。

4

1 回答 1

1

这是一个使用网络规则的示例,您可以参考它。

resource "azurerm_resource_group" "testrg" {
  name     = "resourceGroupName"
  location = "westus"
}

resource "azurerm_virtual_network" "test" {
    name = "virtnetname"
    address_space = ["10.0.0.0/16"]
    location = "${azurerm_resource_group.testrg.location}"
    resource_group_name = "${azurerm_resource_group.testrg.name}"
}

resource "azurerm_subnet" "test" {
    name                 = "subnetname"
    resource_group_name  = "${azurerm_resource_group.testrg.name}"
    virtual_network_name = "${azurerm_virtual_network.test.name}"
    address_prefix       = "10.0.2.0/24"
    service_endpoints    = ["Microsoft.Sql","Microsoft.Storage"]
  }

resource "azurerm_storage_account" "testsa" {
    name = "storageaccountname"
    resource_group_name = "${azurerm_resource_group.testrg.name}"

    location = "${azurerm_resource_group.testrg.location}"
    account_tier = "Standard"
    account_replication_type = "LRS"

    network_rules {
        ip_rules = ["127.0.0.1"]
        virtual_network_subnet_ids = ["${azurerm_subnet.test.id}"]
    }

    tags {
        environment = "staging"
    }
}
于 2018-11-01T03:15:11.940 回答