共用方式為


Microsoft.DBforPostgreSQL 伺服器/virtualNetworkRules

Bicep 資源定義

伺服器/virtualNetworkRules 資源類型可以使用目標作業來部署:

如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔

資源格式

若要建立 Microsoft.DBforPostgreSQL/servers/virtualNetworkRules 資源,請將下列 Bicep 新增至範本。

resource symbolicname 'Microsoft.DBforPostgreSQL/servers/virtualNetworkRules@2017-12-01' = {
  parent: resourceSymbolicName
  name: 'string'
  properties: {
    ignoreMissingVnetServiceEndpoint: bool
    virtualNetworkSubnetId: 'string'
  }
}

屬性值

Microsoft.DBforPostgreSQL/servers/virtualNetworkRules

名字 描述 價值
名字 資源名稱 字串 (必要)
父代 在 Bicep 中,您可以指定子資源的父資源。 只有在父資源外部宣告子資源時,才需要新增這個屬性。

如需詳細資訊,請參閱 父資源外部的子資源
類型的資源符號名稱:伺服器
性能 資源屬性。 VirtualNetworkRuleProperties

VirtualNetworkRuleProperties

名字 描述 價值
ignoreMissingVnetServiceEndpoint 在虛擬網路啟用 vnet 服務端點之前建立防火牆規則。 布爾 (bool)
virtualNetworkSubnetId 虛擬網路子網的 ARM 資源識別碼。 字串 (必要)

使用範例

Bicep 範例

部署 PostgreSQL 虛擬網路規則的基本範例。

param resourceName string = 'acctest0001'
param location string = 'westeurope'
@description('The administrator login for the PostgreSQL server')
param administratorLogin string
@secure()
@description('The administrator login password for the PostgreSQL server')
param administratorLoginPassword string

resource server 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
  name: resourceName
  location: location
  properties: {
    administratorLogin: null
    administratorLoginPassword: null
    createMode: 'Default'
    infrastructureEncryption: 'Disabled'
    minimalTlsVersion: 'TLS1_2'
    publicNetworkAccess: 'Enabled'
    sslEnforcement: 'Enabled'
    storageProfile: {
      backupRetentionDays: 7
      storageAutogrow: 'Enabled'
      storageMB: 51200
    }
    version: '9.5'
  }
  sku: {
    capacity: 2
    family: 'Gen5'
    name: 'GP_Gen5_2'
    tier: 'GeneralPurpose'
  }
}

resource virtualNetwork 'Microsoft.Network/virtualNetworks@2022-07-01' = {
  name: resourceName
  location: location
  properties: {
    addressSpace: {
      addressPrefixes: [
        '10.7.29.0/29'
      ]
    }
    dhcpOptions: {
      dnsServers: []
    }
    subnets: []
  }
}

resource subnet 'Microsoft.Network/virtualNetworks/subnets@2022-07-01' = {
  parent: virtualNetwork
  name: resourceName
  properties: {
    addressPrefix: '10.7.29.0/29'
    delegations: []
    privateEndpointNetworkPolicies: 'Enabled'
    privateLinkServiceNetworkPolicies: 'Enabled'
    serviceEndpointPolicies: []
    serviceEndpoints: [
      {
        service: 'Microsoft.Sql'
      }
    ]
  }
}

resource virtualNetworkRule 'Microsoft.DBforPostgreSQL/servers/virtualNetworkRules@2017-12-01' = {
  parent: server
  name: resourceName
  properties: {
    ignoreMissingVnetServiceEndpoint: false
    virtualNetworkSubnetId: subnet.id
  }
}

Azure 快速入門範例

下列 Azure 快速入門範本 包含用於部署此資源類型的 Bicep 範例。

Bicep 檔案 描述
使用 VNet 部署適用於 PostgreSQL 的 Azure 資料庫 此範本提供部署適用於 PostgreSQL 的 Azure 資料庫與 VNet 整合的方式。

ARM 樣本資源定義

伺服器/virtualNetworkRules 資源類型可以使用目標作業來部署:

如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔

資源格式

若要建立 Microsoft.DBforPostgreSQL/servers/virtualNetworkRules 資源,請將下列 JSON 新增至範本。

{
  "type": "Microsoft.DBforPostgreSQL/servers/virtualNetworkRules",
  "apiVersion": "2017-12-01",
  "name": "string",
  "properties": {
    "ignoreMissingVnetServiceEndpoint": "bool",
    "virtualNetworkSubnetId": "string"
  }
}

屬性值

Microsoft.DBforPostgreSQL/servers/virtualNetworkRules

名字 描述 價值
apiVersion API 版本 '2017-12-01'
名字 資源名稱 字串 (必要)
性能 資源屬性。 VirtualNetworkRuleProperties
型別 資源類型 'Microsoft.DBforPostgreSQL/servers/virtualNetworkRules'

VirtualNetworkRuleProperties

名字 描述 價值
ignoreMissingVnetServiceEndpoint 在虛擬網路啟用 vnet 服務端點之前建立防火牆規則。 布爾 (bool)
virtualNetworkSubnetId 虛擬網路子網的 ARM 資源識別碼。 字串 (必要)

使用範例

Azure 快速入門範本

下列 Azure 快速入門範本 部署此資源類型。

範本 描述
使用 VNet 部署適用於 PostgreSQL 的 Azure 資料庫

部署至 Azure
此範本提供部署適用於 PostgreSQL 的 Azure 資料庫與 VNet 整合的方式。

Terraform (AzAPI 提供者) 資源定義

伺服器/virtualNetworkRules 資源類型可以使用目標作業來部署:

  • 資源群組

如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔

資源格式

若要建立 Microsoft.DBforPostgreSQL/servers/virtualNetworkRules 資源,請將下列 Terraform 新增至您的範本。

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.DBforPostgreSQL/servers/virtualNetworkRules@2017-12-01"
  name = "string"
  parent_id = "string"
  body = {
    properties = {
      ignoreMissingVnetServiceEndpoint = bool
      virtualNetworkSubnetId = "string"
    }
  }
}

屬性值

Microsoft.DBforPostgreSQL/servers/virtualNetworkRules

名字 描述 價值
名字 資源名稱 字串 (必要)
parent_id 此資源為父系之資源的標識碼。 類型資源的標識碼:伺服器
性能 資源屬性。 VirtualNetworkRuleProperties
型別 資源類型 “Microsoft.DBforPostgreSQL/servers/virtualNetworkRules@2017-12-01”

VirtualNetworkRuleProperties

名字 描述 價值
ignoreMissingVnetServiceEndpoint 在虛擬網路啟用 vnet 服務端點之前建立防火牆規則。 布爾 (bool)
virtualNetworkSubnetId 虛擬網路子網的 ARM 資源識別碼。 字串 (必要)

使用範例

Terraform 範例

部署 PostgreSQL 虛擬網路規則的基本範例。

terraform {
  required_providers {
    azapi = {
      source = "Azure/azapi"
    }
  }
}

provider "azapi" {
  skip_provider_registration = false
}

variable "resource_name" {
  type    = string
  default = "acctest0001"
}

variable "location" {
  type    = string
  default = "westeurope"
}

variable "administrator_login" {
  type        = string
  description = "The administrator login for the PostgreSQL server"
}

variable "administrator_login_password" {
  type        = string
  description = "The administrator login password for the PostgreSQL server"
  sensitive   = true
}

resource "azapi_resource" "resourceGroup" {
  type     = "Microsoft.Resources/resourceGroups@2020-06-01"
  name     = var.resource_name
  location = var.location
}

resource "azapi_resource" "virtualNetwork" {
  type      = "Microsoft.Network/virtualNetworks@2022-07-01"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  body = {
    properties = {
      addressSpace = {
        addressPrefixes = [
          "10.7.29.0/29",
        ]
      }
      dhcpOptions = {
        dnsServers = [
        ]
      }
      subnets = [
      ]
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
  lifecycle {
    ignore_changes = [body.properties.subnets]
  }
}

resource "azapi_resource" "server" {
  type      = "Microsoft.DBforPostgreSQL/servers@2017-12-01"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  body = {
    properties = {
      administratorLogin         = var.administrator_login
      administratorLoginPassword = var.administrator_login_password
      createMode                 = "Default"
      infrastructureEncryption   = "Disabled"
      minimalTlsVersion          = "TLS1_2"
      publicNetworkAccess        = "Enabled"
      sslEnforcement             = "Enabled"
      storageProfile = {
        backupRetentionDays = 7
        storageAutogrow     = "Enabled"
        storageMB           = 51200
      }
      version = "9.5"
    }
    sku = {
      capacity = 2
      family   = "Gen5"
      name     = "GP_Gen5_2"
      tier     = "GeneralPurpose"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "subnet" {
  type      = "Microsoft.Network/virtualNetworks/subnets@2022-07-01"
  parent_id = azapi_resource.virtualNetwork.id
  name      = var.resource_name
  body = {
    properties = {
      addressPrefix = "10.7.29.0/29"
      delegations = [
      ]
      privateEndpointNetworkPolicies    = "Enabled"
      privateLinkServiceNetworkPolicies = "Enabled"
      serviceEndpointPolicies = [
      ]
      serviceEndpoints = [
        {
          service = "Microsoft.Sql"
        },
      ]
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "virtualNetworkRule" {
  type      = "Microsoft.DBforPostgreSQL/servers/virtualNetworkRules@2017-12-01"
  parent_id = azapi_resource.server.id
  name      = var.resource_name
  body = {
    properties = {
      ignoreMissingVnetServiceEndpoint = false
      virtualNetworkSubnetId           = azapi_resource.subnet.id
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}