Bicep 資源定義
伺服器/資料庫資源類型可以使用目標作業來部署:
- 資源群組 - 請參閱 資源群組部署命令
如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔。
資源格式
若要建立 Microsoft.DBforPostgreSQL/servers/databases 資源,請將下列 Bicep 新增至範本。
resource symbolicname 'Microsoft.DBforPostgreSQL/servers/databases@2017-12-01' = {
parent: resourceSymbolicName
name: 'string'
properties: {
charset: 'string'
collation: 'string'
}
}
屬性值
Microsoft.DBforPostgreSQL/servers/databases
| 名字 | 描述 | 價值 |
|---|---|---|
| 名字 | 資源名稱 | 字串 (必要) |
| 父代 | 在 Bicep 中,您可以指定子資源的父資源。 只有在父資源外部宣告子資源時,才需要新增這個屬性。 如需詳細資訊,請參閱 父資源外部的子資源。 |
類型的資源符號名稱:伺服器 |
| 性能 | 資料庫的屬性。 | 資料庫屬性 |
資料庫屬性
| 名字 | 描述 | 價值 |
|---|---|---|
| 字元集 | 資料庫的字元集。 | 字串 |
| 定序 | 資料庫的定序。 | 字串 |
使用範例
Bicep 範例
在 PostgreSQL Server 中部署 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 database 'Microsoft.DBforPostgreSQL/servers/databases@2017-12-01' = {
parent: server
name: resourceName
properties: {
charset: 'UTF8'
collation: 'English_United States.1252'
}
}
Azure 快速入門範例
下列 Azure 快速入門範本 包含用於部署此資源類型的 Bicep 範例。
| Bicep 檔案 | 描述 |
|---|---|
| 在 Linux 上使用 PostgreSQL |
此範本提供在 Linux Web 應用程式上使用適用於 PostgreSQL 的 Azure 資料庫部署 Sonarqube Docker 映射 (alpine tag) 的簡單方式(預覽版) |
ARM 樣本資源定義
伺服器/資料庫資源類型可以使用目標作業來部署:
- 資源群組 - 請參閱 資源群組部署命令
如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔。
資源格式
若要建立 Microsoft.DBforPostgreSQL/servers/databases 資源,請將下列 JSON 新增至範本。
{
"type": "Microsoft.DBforPostgreSQL/servers/databases",
"apiVersion": "2017-12-01",
"name": "string",
"properties": {
"charset": "string",
"collation": "string"
}
}
屬性值
Microsoft.DBforPostgreSQL/servers/databases
| 名字 | 描述 | 價值 |
|---|---|---|
| apiVersion | API 版本 | '2017-12-01' |
| 名字 | 資源名稱 | 字串 (必要) |
| 性能 | 資料庫的屬性。 | 資料庫屬性 |
| 型別 | 資源類型 | “Microsoft.DBforPostgreSQL/servers/databases” |
資料庫屬性
| 名字 | 描述 | 價值 |
|---|---|---|
| 字元集 | 資料庫的字元集。 | 字串 |
| 定序 | 資料庫的定序。 | 字串 |
使用範例
Azure 快速入門範本
下列 Azure 快速入門範本 部署此資源類型。
Terraform (AzAPI 提供者) 資源定義
伺服器/資料庫資源類型可以使用目標作業來部署:
- 資源群組
如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔。
資源格式
若要建立 Microsoft.DBforPostgreSQL/servers/databases 資源,請將下列 Terraform 新增至範本。
resource "azapi_resource" "symbolicname" {
type = "Microsoft.DBforPostgreSQL/servers/databases@2017-12-01"
name = "string"
parent_id = "string"
body = {
properties = {
charset = "string"
collation = "string"
}
}
}
屬性值
Microsoft.DBforPostgreSQL/servers/databases
| 名字 | 描述 | 價值 |
|---|---|---|
| 名字 | 資源名稱 | 字串 (必要) |
| 父項識別碼 | 此資源為父系之資源的標識碼。 | 類型資源的標識碼:伺服器 |
| 性能 | 資料庫的屬性。 | 資料庫屬性 |
| 型別 | 資源類型 | “Microsoft.DBforPostgreSQL/servers/databases@2017-12-01” |
資料庫屬性
| 名字 | 描述 | 價值 |
|---|---|---|
| 字元集 | 資料庫的字元集。 | 字串 |
| 定序 | 資料庫的定序。 | 字串 |
使用範例
Terraform 範例
在 PostgreSQL Server 中部署 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" "database" {
type = "Microsoft.DBforPostgreSQL/servers/databases@2017-12-01"
parent_id = azapi_resource.server.id
name = var.resource_name
body = {
properties = {
charset = "UTF8"
collation = "English_United States.1252"
}
}
schema_validation_enabled = false
response_export_values = ["*"]
}