Microsoft。Sql伺服器/防火牆規則 2025-01-01

Bicep 資源定義

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

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

使用範例

Bicep 範例

部署 Azure SQL 防火牆規則的基本範例。

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

resource server 'Microsoft.Sql/servers@2021-02-01-preview' = {
  name: resourceName
  location: location
  properties: {
    administratorLogin: 'msincredible'
    administratorLoginPassword: administratorLoginPassword
    minimalTlsVersion: '1.2'
    publicNetworkAccess: 'Enabled'
    restrictOutboundNetworkAccess: 'Disabled'
    version: '12.0'
  }
}

resource firewallRule 'Microsoft.Sql/servers/firewallRules@2020-11-01-preview' = {
  name: resourceName
  parent: server
  properties: {
    endIpAddress: '255.255.255.255'
    startIpAddress: '0.0.0.0'
  }
}

Azure 已驗證的模組

下列 Azure 驗證模組 可用來部署此資源類型。

Module Description
Azure SQL Server - 防火牆規則 AVM Child Module for Azure SQL Server - Firewall Rule

Azure 快速入門範例

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

Bicep 檔案 Description
在 Azure 架構上部署體育分析 建立已啟用 ADLS Gen 2 的 Azure 記憶體帳戶、具有記憶體帳戶連結服務的 Azure Data Factory 實例(如果已部署的 Azure SQL Database),以及 Azure Databricks 實例。 部署範本和 ADF 實例受控識別的使用者 AAD 身分識別,將會在記憶體帳戶上授與記憶體 Blob 數據參與者角色。 還有一個選項可用來部署 Azure Key Vault 實例、Azure SQL Database 和 Azure 事件中樞(適用於串流使用案例)。 部署 Azure Key Vault 時,部署範本之使用者的 Data Factory 受控識別和 AAD 身分識別將會獲得 金鑰保存庫 秘密使用者角色。
使用 SQL Database 布建 Web 應用程式 此範本會布建 Web 應用程式、SQL Database、自動調整設定、警示規則和 App Insights。 它會在資料庫的 Web 應用程式中設定連接字串。
使用 Azure SQL 在 Linux 上 Sonarqube Docker Web 應用程式 此範本會使用官方 Sonarqube 映像,並在 Azure SQL Server 支援下,在 Azure App 服務 Web 應用程式 Linux 容器中部署 Sonarqube。
SQL 邏輯伺服器 此範本可讓您建立 SQL 邏輯伺服器。
具有受控識別、SQL Server 和 的 Web 應用程式 針對應用程式 + 資料 + 受控識別 + 監視部署 Azure 基礎結構的簡單範例

資源格式

創造一個 Microsoft。Sql/servers/firewallRules 資源,請在你的範本中加入以下 Bicep。

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

屬性值

Microsoft.Sql/servers/firewallRules

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

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

ServerFirewallRuleProperties

名稱 Description 價值
endIpAddress 防火牆規則的結束IP位址。 必須是 IPv4 格式。 必須大於或等於 startIpAddress。 針對所有 Azure 內部 IP 位址使用值 『0.0.0.0』。 字串
startIpAddress 防火牆規則的起始IP位址。 必須是 IPv4 格式。 針對所有 Azure 內部 IP 位址使用值 『0.0.0.0』。 字串

ARM 樣本資源定義

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

使用範例

Azure 快速入門範本

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

範本 Description
部署新的 SQL 彈性池

部署至Azure
此範本允許您部署新的 SQL 彈性池,並附帶其新關聯的 SQL Server 及可指派的新 SQL 資料庫。
在 Azure 架構上部署體育分析

部署至Azure
建立已啟用 ADLS Gen 2 的 Azure 記憶體帳戶、具有記憶體帳戶連結服務的 Azure Data Factory 實例(如果已部署的 Azure SQL Database),以及 Azure Databricks 實例。 部署範本和 ADF 實例受控識別的使用者 AAD 身分識別,將會在記憶體帳戶上授與記憶體 Blob 數據參與者角色。 還有一個選項可用來部署 Azure Key Vault 實例、Azure SQL Database 和 Azure 事件中樞(適用於串流使用案例)。 部署 Azure Key Vault 時,部署範本之使用者的 Data Factory 受控識別和 AAD 身分識別將會獲得 金鑰保存庫 秘密使用者角色。
使用 SQL Database 布建 Web 應用程式

部署至Azure
此範本會布建 Web 應用程式、SQL Database、自動調整設定、警示規則和 App Insights。 它會在資料庫的 Web 應用程式中設定連接字串。
使用 Azure SQL 在 Linux 上 Sonarqube Docker Web 應用程式

部署至Azure
此範本會使用官方 Sonarqube 映像,並在 Azure SQL Server 支援下,在 Azure App 服務 Web 應用程式 Linux 容器中部署 Sonarqube。
SQL 邏輯伺服器

部署至Azure
此範本可讓您建立 SQL 邏輯伺服器。
具有受控識別、SQL Server 和 的 Web 應用程式

部署至Azure
針對應用程式 + 資料 + 受控識別 + 監視部署 Azure 基礎結構的簡單範例

資源格式

創造一個 Microsoft。Sql/servers/firewallRules 資源,請在你的範本中加入以下 JSON 檔案。

{
  "type": "Microsoft.Sql/servers/firewallRules",
  "apiVersion": "2025-01-01",
  "name": "string",
  "properties": {
    "endIpAddress": "string",
    "startIpAddress": "string"
  }
}

屬性值

Microsoft.Sql/servers/firewallRules

名稱 Description 價值
apiVersion API 版本 '2025-01-01'
名字 資源名稱 字串 (必要)
properties 資源屬性。 ServerFirewallRuleProperties
型別 資源類型 「Microsoft。Sql/servers/firewallRules'

ServerFirewallRuleProperties

名稱 Description 價值
endIpAddress 防火牆規則的結束IP位址。 必須是 IPv4 格式。 必須大於或等於 startIpAddress。 針對所有 Azure 內部 IP 位址使用值 『0.0.0.0』。 字串
startIpAddress 防火牆規則的起始IP位址。 必須是 IPv4 格式。 針對所有 Azure 內部 IP 位址使用值 『0.0.0.0』。 字串

Terraform (AzAPI 提供者) 資源定義

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

  • 資源團體 關於每個 API 版本變更屬性的清單,請參見 變更日誌。

使用範例

Terraform 範例

部署 Azure SQL 防火牆規則的基本範例。

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_password" {
  type        = string
  description = "The administrator login password for the SQL 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.Sql/servers@2021-02-01-preview"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  body = {
    properties = {
      administratorLogin            = "msincredible"
      administratorLoginPassword    = var.administrator_login_password
      minimalTlsVersion             = "1.2"
      publicNetworkAccess           = "Enabled"
      restrictOutboundNetworkAccess = "Disabled"
      version                       = "12.0"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "firewallRule" {
  type      = "Microsoft.Sql/servers/firewallRules@2020-11-01-preview"
  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    = ["*"]
}

部署 Azure SQL 防火牆規則的基本範例。

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_password" {
  type        = string
  description = "The administrator login password for the SQL 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.Sql/servers@2021-02-01-preview"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  body = {
    properties = {
      administratorLogin            = "msincredible"
      administratorLoginPassword    = var.administrator_login_password
      minimalTlsVersion             = "1.2"
      publicNetworkAccess           = "Enabled"
      restrictOutboundNetworkAccess = "Disabled"
      version                       = "12.0"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "firewallRule" {
  type      = "Microsoft.Sql/servers/firewallRules@2020-11-01-preview"
  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    = ["*"]
}

資源格式

創造一個 Microsoft。Sql/servers/firewallRules 資源,將以下 Terraform 加入你的範本。

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

屬性值

Microsoft.Sql/servers/firewallRules

名稱 Description 價值
名字 資源名稱 字串 (必要)
parent_id 此資源為父系之資源的標識碼。 類型資源的標識碼:伺服器
properties 資源屬性。 ServerFirewallRuleProperties
型別 資源類型 「Microsoft。Sql/servers/firewallRules@2025-01-01”

ServerFirewallRuleProperties

名稱 Description 價值
endIpAddress 防火牆規則的結束IP位址。 必須是 IPv4 格式。 必須大於或等於 startIpAddress。 針對所有 Azure 內部 IP 位址使用值 『0.0.0.0』。 字串
startIpAddress 防火牆規則的起始IP位址。 必須是 IPv4 格式。 針對所有 Azure 內部 IP 位址使用值 『0.0.0.0』。 字串