共用方式為


Microsoft.DBforPostgreSQL 伺服器/firewallRules

Bicep 資源定義

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

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

資源格式

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

resource symbolicname 'Microsoft.DBforPostgreSQL/servers/firewallRules@2017-12-01' = {
  parent: resourceSymbolicName
  name: 'string'
  properties: {
    endIpAddress: 'string'
    startIpAddress: 'string'
  }
}

屬性值

Microsoft.DBforPostgreSQL/servers/firewallRules

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

如需詳細資訊,請參閱 父資源外部的子資源
類型的資源符號名稱:伺服器
性能 防火牆規則的屬性。 FirewallRuleProperties (必要)

FirewallRuleProperties

名字 描述 價值
endIp位址 伺服器防火牆規則的結束IP位址。 必須是 IPv4 格式。 字串

約束:
模式 = ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$ (必要)
startIpAddress (啟動 IpAddress) 伺服器防火牆規則的起始IP位址。 必須是 IPv4 格式。 字串

約束:
模式 = ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$ (必要)

使用範例

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.6'
  }
  sku: {
    capacity: 2
    family: 'Gen5'
    name: 'GP_Gen5_2'
    tier: 'GeneralPurpose'
  }
}

resource firewallRule 'Microsoft.DBforPostgreSQL/servers/firewallRules@2017-12-01' = {
  parent: server
  name: resourceName
  properties: {
    endIpAddress: '255.255.255.255'
    startIpAddress: '0.0.0.0'
  }
}

Azure 快速入門範例

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

Bicep 檔案 描述
使用 VNet 部署適用於 PostgreSQL 的 Azure 資料庫 此範本提供部署適用於 PostgreSQL 的 Azure 資料庫與 VNet 整合的方式。
在 Linux 上使用 PostgreSQL Sonarqube Docker Web 應用程式 此範本提供在 Linux Web 應用程式上使用適用於 PostgreSQL 的 Azure 資料庫部署 Sonarqube Docker 映射 (alpine tag) 的簡單方式(預覽版)

ARM 樣本資源定義

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

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

資源格式

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

{
  "type": "Microsoft.DBforPostgreSQL/servers/firewallRules",
  "apiVersion": "2017-12-01",
  "name": "string",
  "properties": {
    "endIpAddress": "string",
    "startIpAddress": "string"
  }
}

屬性值

Microsoft.DBforPostgreSQL/servers/firewallRules

名字 描述 價值
apiVersion API 版本 '2017-12-01'
名字 資源名稱 字串 (必要)
性能 防火牆規則的屬性。 FirewallRuleProperties (必要)
型別 資源類型 “Microsoft.DBforPostgreSQL/servers/firewallRules”

FirewallRuleProperties

名字 描述 價值
endIp位址 伺服器防火牆規則的結束IP位址。 必須是 IPv4 格式。 字串

約束:
模式 = ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$ (必要)
startIpAddress (啟動 IpAddress) 伺服器防火牆規則的起始IP位址。 必須是 IPv4 格式。 字串

約束:
模式 = ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$ (必要)

使用範例

Azure 快速入門範本

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

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

部署至 Azure
此範本提供部署適用於 PostgreSQL 的 Azure 資料庫與 VNet 整合的方式。
在 Linux 上使用 PostgreSQL Sonarqube Docker Web 應用程式

部署至 Azure
此範本提供在 Linux Web 應用程式上使用適用於 PostgreSQL 的 Azure 資料庫部署 Sonarqube Docker 映射 (alpine tag) 的簡單方式(預覽版)

Terraform (AzAPI 提供者) 資源定義

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

  • 資源群組

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

資源格式

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

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.DBforPostgreSQL/servers/firewallRules@2017-12-01"
  name = "string"
  parent_id = "string"
  body = {
    properties = {
      endIpAddress = "string"
      startIpAddress = "string"
    }
  }
}

屬性值

Microsoft.DBforPostgreSQL/servers/firewallRules

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

FirewallRuleProperties

名字 描述 價值
endIp位址 伺服器防火牆規則的結束IP位址。 必須是 IPv4 格式。 字串

約束:
模式 = ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$ (必要)
startIpAddress (啟動 IpAddress) 伺服器防火牆規則的起始IP位址。 必須是 IPv4 格式。 字串

約束:
模式 = ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$ (必要)

使用範例

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" "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.6"
    }
    sku = {
      capacity = 2
      family   = "Gen5"
      name     = "GP_Gen5_2"
      tier     = "GeneralPurpose"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "firewallRule" {
  type      = "Microsoft.DBforPostgreSQL/servers/firewallRules@2017-12-01"
  parent_id = azapi_resource.server.id
  name      = var.resource_name
  body = {
    properties = {
      endIpAddress   = "255.255.255.255"
      startIpAddress = "0.0.0.0"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}