你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Microsoft.DBforPostgreSQL flexibleServers/firewallRules

Bicep 资源定义

可以使用目标操作部署 flexibleServers/firewallRules 资源类型:

有关每个 API 版本中已更改属性的列表,请参阅 更改日志

资源格式

若要创建 Microsoft.DBforPostgreSQL/flexibleServers/firewallRules 资源,请将以下 Bicep 添加到模板。

resource symbolicname 'Microsoft.DBforPostgreSQL/flexibleServers/firewallRules@2025-08-01' = {
  parent: resourceSymbolicName
  name: 'string'
  properties: {
    endIpAddress: 'string'
    startIpAddress: 'string'
  }
}

属性值

Microsoft.DBforPostgreSQL/flexibleServers/firewallRules

名字 描述 价值
名字 资源名称 字符串

约束:
最小长度 = 1
最大长度 = 80
模式 = ^[a-zA-Z0-9][-_a-zA-Z0-9]{0,79}(?<!-)$ (必需)
父级 在 Bicep 中,可以为子资源指定父资源。 仅当子资源在父资源外部声明时,才需要添加此属性。

有关详细信息,请参阅 父资源外部的子资源
类型资源的符号名称:flexibleServers
性能 防火墙规则的属性。 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])$ (必需)

ARM 模板资源定义

可以使用目标操作部署 flexibleServers/firewallRules 资源类型:

有关每个 API 版本中已更改属性的列表,请参阅 更改日志

资源格式

若要创建 Microsoft.DBforPostgreSQL/flexibleServers/firewallRules 资源,请将以下 JSON 添加到模板。

{
  "type": "Microsoft.DBforPostgreSQL/flexibleServers/firewallRules",
  "apiVersion": "2025-08-01",
  "name": "string",
  "properties": {
    "endIpAddress": "string",
    "startIpAddress": "string"
  }
}

属性值

Microsoft.DBforPostgreSQL/flexibleServers/firewallRules

名字 描述 价值
apiVersion API 版本 '2025-08-01'
名字 资源名称 字符串

约束:
最小长度 = 1
最大长度 = 80
模式 = ^[a-zA-Z0-9][-_a-zA-Z0-9]{0,79}(?<!-)$ (必需)
性能 防火墙规则的属性。 FirewallRuleProperties (必需)
类型 资源类型 “Microsoft.DBforPostgreSQL/flexibleServers/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])$ (必需)

用法示例

Terraform (AzAPI 提供程序)资源定义

可以使用目标操作部署 flexibleServers/firewallRules 资源类型:

有关每个 API 版本中已更改属性的列表,请参阅 更改日志

资源格式

若要创建 Microsoft.DBforPostgreSQL/flexibleServers/firewallRules 资源,请将以下 Terraform 添加到模板。

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.DBforPostgreSQL/flexibleServers/firewallRules@2025-08-01"
  name = "string"
  parent_id = "string"
  body = {
    properties = {
      endIpAddress = "string"
      startIpAddress = "string"
    }
  }
}

属性值

Microsoft.DBforPostgreSQL/flexibleServers/firewallRules

名字 描述 价值
名字 资源名称 字符串

约束:
最小长度 = 1
最大长度 = 80
模式 = ^[a-zA-Z0-9][-_a-zA-Z0-9]{0,79}(?<!-)$ (必需)
parent_id 此资源的父资源的 ID。 类型资源的 ID:flexibleServers
性能 防火墙规则的属性。 FirewallRuleProperties (必需)
类型 资源类型 “Microsoft.DBforPostgreSQL/flexibleServers/firewallRules@2025-08-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 "postgresql_administrator_password" {
  type        = string
  description = "The administrator password for the PostgreSQL flexible server"
  sensitive   = true
}

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

resource "azapi_resource" "flexibleServer" {
  type      = "Microsoft.DBforPostgreSQL/flexibleServers@2022-12-01"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  body = {
    properties = {
      administratorLogin         = "adminTerraform"
      administratorLoginPassword = var.postgresql_administrator_password
      availabilityZone           = "2"
      backup = {
        geoRedundantBackup = "Disabled"
      }
      highAvailability = {
        mode = "Disabled"
      }
      network = {
      }
      storage = {
        storageSizeGB = 32
      }
      version = "12"
    }
    sku = {
      name = "Standard_D2s_v3"
      tier = "GeneralPurpose"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "firewallRule" {
  type      = "Microsoft.DBforPostgreSQL/flexibleServers/firewallRules@2022-12-01"
  parent_id = azapi_resource.flexibleServer.id
  name      = var.resource_name
  body = {
    properties = {
      endIpAddress   = "122.122.0.0"
      startIpAddress = "122.122.0.0"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}