- Latest
- 2024-11-01-preview
- 2024-05-01-preview
- 2023-08-01
- 2023-08-01-preview
- 2023-05-01-preview
- 2023-02-01-preview
- 2022-11-01-preview
- 2022-08-01-preview
- 2022-05-01-preview
- 2022-02-01-preview
- 2021-11-01
- 2021-11-01-preview
- 2021-08-01-preview
- 2021-05-01-preview
- 2021-02-01-preview
- 2020-11-01-preview
- 2020-08-01-preview
- 2020-02-02-preview
- 2019-06-01-preview
- 2017-10-01-preview
- 2017-03-01-preview
- 2014-04-01
Bicep 資源定義
伺服器/資料庫資源類型可以使用目標作業來部署:
- 資源群組 - 請參閱 資源群組部署命令
如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔。
資源格式
若要建立 Microsoft.Sql/servers/databases 資源,請將下列 Bicep 新增至範本。
resource symbolicname 'Microsoft.Sql/servers/databases@2024-11-01-preview' = {
parent: resourceSymbolicName
identity: {
type: 'string'
userAssignedIdentities: {
{customized property}: {}
}
}
location: 'string'
name: 'string'
properties: {
autoPauseDelay: int
availabilityZone: 'string'
catalogCollation: 'string'
collation: 'string'
createMode: 'string'
elasticPoolId: 'string'
encryptionProtector: 'string'
encryptionProtectorAutoRotation: bool
federatedClientId: 'string'
freeLimitExhaustionBehavior: 'string'
highAvailabilityReplicaCount: int
isLedgerOn: bool
keys: {
{customized property}: {}
}
licenseType: 'string'
longTermRetentionBackupResourceId: 'string'
maintenanceConfigurationId: 'string'
manualCutover: bool
maxSizeBytes: int
minCapacity: int
performCutover: bool
preferredEnclaveType: 'string'
readScale: 'string'
recoverableDatabaseId: 'string'
recoveryServicesRecoveryPointId: 'string'
requestedBackupStorageRedundancy: 'string'
restorableDroppedDatabaseId: 'string'
restorePointInTime: 'string'
sampleName: 'string'
secondaryType: 'string'
sourceDatabaseDeletionDate: 'string'
sourceDatabaseId: 'string'
sourceResourceId: 'string'
useFreeLimit: bool
zoneRedundant: bool
}
sku: {
capacity: int
family: 'string'
name: 'string'
size: 'string'
tier: 'string'
}
tags: {
{customized property}: 'string'
}
}
屬性值
Microsoft.Sql/servers/databases
| Name | Description | Value |
|---|---|---|
| 身分識別 | 資料庫的 Azure Active Directory 身分識別。 | DatabaseIdentity |
| 位置 | 資源位置。 | 字串 (必要) |
| name | 資源名稱 | 字串 (必要) |
| 父代 | 在 Bicep 中,您可以指定子資源的父資源。 只有在父資源外部宣告子資源時,才需要新增這個屬性。 如需詳細資訊,請參閱 父資源外部的子資源。 |
類型的資源符號名稱:伺服器 |
| properties | 資源屬性。 | DatabaseProperties |
| sku | 資料庫 SKU。 SKU 清單可能會因區域和支援供應項目而異。 若要判斷 Azure 區域中訂用帳戶可用的 SKU(包括 SKU 名稱、層級/版本、系列和容量),請使用 Capabilities_ListByLocation REST API 或下列其中一個命令:azurecli<br />az sql db list-editions -l <location> -o table<br />````<br /><br />PowerShell<Get-AzSqlServerServiceObjective -Location 位置> ```` |
Sku |
| tags | 資源標籤 | 標記名稱和值的字典。 請參閱範本中的 標籤 |
DatabaseIdentity
| Name | Description | Value |
|---|---|---|
| 型別 | 識別類型 | 'None' 'UserAssigned' |
| userAssignedIdentities | 要使用的使用者指派身分識別的資源標識碼 | DatabaseIdentityUserAssignedIdentities |
DatabaseIdentityUserAssignedIdentities
| Name | Description | Value |
|---|
DatabaseKey
| Name | Description | Value |
|---|
DatabaseProperties
| Name | Description | Value |
|---|---|---|
| autoPauseDelay | 在幾分鐘后自動暫停資料庫的時間。 -1 值表示已停用自動暫停 | int |
| availabilityZone | 指定資料庫釘選到的可用性區域。 | '1' '2' '3' 'NoPreference' |
| catalogCollation | 元資料目錄的定序。 | 'DATABASE_DEFAULT' 'SQL_Latin1_General_CP1_CI_AS' |
| 定序 | 資料庫的定序。 | 字串 |
| createMode | 指定資料庫建立模式。 默認值:定期建立資料庫。 複製:建立資料庫做為現有資料庫的複本。 sourceDatabaseId 必須指定為源資料庫的資源標識碼。 次要:建立資料庫做為現有資料庫的次要複本。 sourceDatabaseId 必須指定為現有主資料庫的資源標識碼。 PointInTimeRestore:藉由還原現有資料庫的時間點備份來建立資料庫。 sourceDatabaseId 必須指定為現有資料庫的資源標識符,而且必須指定 restorePointInTime。 復原:藉由還原異地復寫備份來建立資料庫。 sourceDatabaseId 必須指定為要還原的可復原資料庫資源標識符。 還原:藉由還原已刪除資料庫的備份來建立資料庫。 必須指定sourceDatabaseId。 如果 sourceDatabaseId 是資料庫的原始資源識別碼,則必須指定 sourceDatabaseDeletionDate。 否則,sourceDatabaseId 必須是可還原的卸除資料庫資源標識符,而且會忽略 sourceDatabaseDeletionDate。 restorePointInTime 也可以指定為從先前的時間點還原。 RestoreLongTermRetentionBackup:從長期保留保存庫還原來建立資料庫。 recoveryServicesRecoveryPointResourceId 必須指定為恢復點資源標識符。 DataWarehouse 版本不支援 Copy、Secondary 和 RestoreLongTermRetentionBackup。 |
'Copy' 'Default' 'OnlineSecondary' 'PointInTimeRestore' 'Recovery' 'Restore' 'RestoreExternalBackup' 'RestoreExternalBackupSecondary' 'RestoreLongTermRetentionBackup' 'Secondary' |
| elasticPoolId | 包含此資料庫之彈性集區的資源標識碼。 | 字串 |
| encryptionProtector | 如果資料庫已針對每個資料庫客戶管理的金鑰進行設定,則為資料庫的 Azure 金鑰保存庫 URI。 | 字串 |
| encryptionProtectorAutoRotation | 啟用或停用資料庫加密保護裝置 AKV 金鑰自動輪替的旗標。 | bool |
| federatedClientId | 用於每個資料庫跨租使用者的用戶端標識碼 CMK 案例 | string Constraints: 最小長度 = 36 最大長度 = 36 圖案 = ^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$ |
| freeLimitExhaustionBehavior | 指定免費資料庫用完每月可用限制時的行為。 AutoPause:資料庫會在當月剩餘時間的可用限制用盡時自動暫停。 BillForUsage:資料庫會在免費限制用盡時繼續上線,並收取任何超額費用。 |
'AutoPause' 'BillOverUsage' |
| highAvailabilityReplicaCount | 與用來提供高可用性的商業關鍵、進階或超大規模資料庫相關聯的次要複本數目。 不適用於彈性集區內的超大規模資料庫。 | int |
| isLedgerOn | 這個資料庫是否為總賬資料庫,這表示資料庫中的所有數據表都是總賬數據表。 注意:建立資料庫之後,就無法變更此屬性的值。 | bool |
| keys | 要使用的使用者指派身分識別的資源標識碼 | DatabasePropertiesKeys |
| licenseType | 要套用此資料庫的授權類型。
LicenseIncluded 如果您需要授權,或 BasePrice 擁有授權且符合 Azure Hybrid Benefit 的資格。 |
'BasePrice' 'LicenseIncluded' |
| longTermRetentionBackupResourceId | 與此資料庫建立作業相關聯的長期保留備份資源標識符。 | 字串 |
| maintenanceConfigurationId | 指派給資料庫的維護組態標識碼。 此組態會定義維護更新發生的期間。 | 字串 |
| manualCutover | 客戶控制手動完全移轉是否需要在更新資料庫作業期間完成超大規模資料庫層。 只有在將資料庫從業務關鍵/一般用途/進階/標準層調整為超大規模資料庫層時,才適用此屬性。 指定manualCutover時,調整作業會等候使用者輸入觸發超大規模資料庫完全移轉。 若要觸發完全移轉,請在調整作業處於等候狀態時提供 『performCutover』 參數。 |
bool |
| maxSizeBytes | 以位元組表示的資料庫大小上限。 | int |
| minCapacity | 資料庫一律配置的最小容量,如果未暫停,則為 | int |
| performCutover | 在調整作業進行中時,觸發客戶控制的手動完全移轉。 這個屬性參數僅適用於起始與 'manualCutover' 參數一起起始的調整作業。 只有當資料庫從業務關鍵/一般用途/進階/標準層調整至超大規模資料庫層級正在進行時,才適用此屬性。 指定了performCutover時,調整作業會觸發完全移轉,並執行超大規模資料庫的角色變更。 |
bool |
| preferredEnclaveType | 資料庫上要求的記憶體保護區類型,也就是預設或 VBS記憶體保護區。 | 'Default' 'VBS' |
| readScale | 唯讀路由的狀態。 如果啟用,在其連接字串中將應用程式意圖設定為唯讀的連線,可能會路由傳送至相同區域中的唯讀次要複本。 不適用於彈性集區內的超大規模資料庫。 | 'Disabled' 'Enabled' |
| recoverableDatabaseId | 與此資料庫建立作業相關聯的可復原資料庫資源標識符。 | 字串 |
| recoveryServicesRecoveryPointId | 與此資料庫建立作業相關聯的恢復點資源標識碼。 | 字串 |
| requestedBackupStorageRedundancy | 要用來儲存此資料庫的備份的記憶體帳戶類型。 | 'Geo' 'GeoZone' 'Local' 'Zone' |
| restorableDroppedDatabaseId | 與這個資料庫建立作業相關聯的可還原卸除資料庫資源標識符。 | 字串 |
| restorePointInTime | 指定要還原以建立新資料庫的源資料庫的時間點(ISO8601格式)。 | 字串 |
| sampleName | 建立這個資料庫時要套用的範例架構名稱。 | 'AdventureWorksLT' 'WideWorldImportersFull' 'WideWorldImportersStd' |
| secondaryType | 如果資料庫是輔助資料庫,則為次要類型。 有效值為 Geo、Named 和 Standby。 | 'Geo' 'Named' 'Standby' |
| sourceDatabaseDeletionDate | 指定刪除資料庫的時間。 | 字串 |
| sourceDatabaseId | 與這個資料庫建立作業相關聯的源資料庫資源標識符。 | 字串 |
| sourceResourceId | 與這個資料庫建立作業相關聯的來源資源標識符。 只有 DataWarehouse 版本才支援此屬性,而且允許跨訂用帳戶還原。 指定 sourceResourceId 時,sourceDatabaseId、recoverableDatabaseId、restoreableDroppedDatabaseId 和 sourceDatabaseDeletionDate 不得指定,而 CreateMode 必須是 PointInTimeRestore、Restore 或 Recover。 當 createMode 是 PointInTimeRestore 時,sourceResourceId 必須是現有資料庫或現有 sql 集區的資源標識碼,而且必須指定 restorePointInTime。 當 createMode 為 Restore 時,sourceResourceId 必須是可還原卸除資料庫或可還原的已卸除 sql 集區的資源識別符。 當 createMode 為 Recover 時,sourceResourceId 必須是可復原資料庫或可復原 SQL 集區的資源標識碼。 當來源訂用帳戶屬於與目標訂用帳戶不同的租使用者時,“x-ms-authorization-auxiliary” 標頭必須包含來源租使用者的驗證令牌。 如需“x-ms-authorization-auxiliary” 標頭的詳細資訊,請參閱 /azure/azure-resource-manager/management/authenticate-multi-tenant |
字串 |
| useFreeLimit | 資料庫是否使用免費每月限制。 在訂用帳戶中的一個資料庫上允許。 | bool |
| zoneRedundant | 此資料庫是否為區域備援,這表示此資料庫的複本會分散到多個可用性區域。 | bool |
DatabasePropertiesKeys
| Name | Description | Value |
|---|
DatabaseUserIdentity
| Name | Description | Value |
|---|
Sku
| Name | Description | Value |
|---|---|---|
| 容量 | 特定 SKU 的容量。 | int |
| family | 如果服務有不同世代的硬體,針對相同的 SKU,則可以在這裡擷取。 | 字串 |
| name | SKU 的名稱,通常是字母 + 數位碼,例如 P3。 | 字串 (必要) |
| size | 特定 SKU 的大小 | 字串 |
| 分層 | 特定 SKU 的階層或版本,例如基本、進階。 | 字串 |
TrackedResourceTags
| Name | Description | Value |
|---|
使用範例
Azure 已驗證的模組
下列 Azure 驗證模組 可用來部署此資源類型。
| 模組 | Description |
|---|---|
| Azure SQL 資料庫 | AVM Resource Module for Azure SQL Database |
Azure 快速入門範例
下列 Azure 快速入門範本 包含用於部署此資源類型的 Bicep 範例。
| Bicep 檔案 | Description |
|---|---|
| 使用寫入 Log Analytics 稽核的 Azure SQL Server |
此樣本可讓您部署已啟用稽核的 Azure SQL 伺服器,以將稽核記錄寫入 Log Analytics (OMS 工作區) |
| 建立 SQL Server 和資料庫 | 此範本可讓您建立 SQL Database 和 Server。 |
| 具有透明加密的專用SQL集區 | 使用透明數據加密建立 SQL Server 和專用 SQL 集區(先前稱為 SQL DW)。 |
| 在 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 身分識別將會獲得 Key Vault 秘密使用者角色。 |
| 私人端點範例 | 此範本示範如何建立指向 Azure SQL Server 的私人端點 |
| 使用 SQL Database 布建 Web 應用程式 | 此範本會布建 Web 應用程式、SQL Database、自動調整設定、警示規則和 App Insights。 它會在資料庫的 Web 應用程式中設定連接字串。 |
| 使用 Azure SQL 在 Linux 上 Sonarqube Docker Web 應用程式 | 此範本會使用官方 Sonarqube 映像,並在 Azure SQL Server 支援下,在 Azure App Service Web 應用程式 Linux 容器中部署 Sonarqube。 |
| 具有受控識別、SQL Server 和 的 Web 應用程式 | 針對應用程式 + 資料 + 受控識別 + 監視部署 Azure 基礎結構的簡單範例 |
ARM 樣本資源定義
伺服器/資料庫資源類型可以使用目標作業來部署:
- 資源群組 - 請參閱 資源群組部署命令
如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔。
資源格式
若要建立 Microsoft.Sql/servers/databases 資源,請將下列 JSON 新增至範本。
{
"type": "Microsoft.Sql/servers/databases",
"apiVersion": "2024-11-01-preview",
"name": "string",
"identity": {
"type": "string",
"userAssignedIdentities": {
"{customized property}": {
}
}
},
"location": "string",
"properties": {
"autoPauseDelay": "int",
"availabilityZone": "string",
"catalogCollation": "string",
"collation": "string",
"createMode": "string",
"elasticPoolId": "string",
"encryptionProtector": "string",
"encryptionProtectorAutoRotation": "bool",
"federatedClientId": "string",
"freeLimitExhaustionBehavior": "string",
"highAvailabilityReplicaCount": "int",
"isLedgerOn": "bool",
"keys": {
"{customized property}": {
}
},
"licenseType": "string",
"longTermRetentionBackupResourceId": "string",
"maintenanceConfigurationId": "string",
"manualCutover": "bool",
"maxSizeBytes": "int",
"minCapacity": "int",
"performCutover": "bool",
"preferredEnclaveType": "string",
"readScale": "string",
"recoverableDatabaseId": "string",
"recoveryServicesRecoveryPointId": "string",
"requestedBackupStorageRedundancy": "string",
"restorableDroppedDatabaseId": "string",
"restorePointInTime": "string",
"sampleName": "string",
"secondaryType": "string",
"sourceDatabaseDeletionDate": "string",
"sourceDatabaseId": "string",
"sourceResourceId": "string",
"useFreeLimit": "bool",
"zoneRedundant": "bool"
},
"sku": {
"capacity": "int",
"family": "string",
"name": "string",
"size": "string",
"tier": "string"
},
"tags": {
"{customized property}": "string"
}
}
屬性值
Microsoft.Sql/servers/databases
| Name | Description | Value |
|---|---|---|
| apiVersion | API 版本 | '2024-11-01-preview' |
| 身分識別 | 資料庫的 Azure Active Directory 身分識別。 | DatabaseIdentity |
| 位置 | 資源位置。 | 字串 (必要) |
| name | 資源名稱 | 字串 (必要) |
| properties | 資源屬性。 | DatabaseProperties |
| sku | 資料庫 SKU。 SKU 清單可能會因區域和支援供應項目而異。 若要判斷 Azure 區域中訂用帳戶可用的 SKU(包括 SKU 名稱、層級/版本、系列和容量),請使用 Capabilities_ListByLocation REST API 或下列其中一個命令:azurecli<br />az sql db list-editions -l <location> -o table<br />````<br /><br />PowerShell<Get-AzSqlServerServiceObjective -Location 位置> ```` |
Sku |
| tags | 資源標籤 | 標記名稱和值的字典。 請參閱範本中的 標籤 |
| 型別 | 資源類型 | 'Microsoft.Sql/servers/databases' |
DatabaseIdentity
| Name | Description | Value |
|---|---|---|
| 型別 | 識別類型 | 'None' 'UserAssigned' |
| userAssignedIdentities | 要使用的使用者指派身分識別的資源標識碼 | DatabaseIdentityUserAssignedIdentities |
DatabaseIdentityUserAssignedIdentities
| Name | Description | Value |
|---|
DatabaseKey
| Name | Description | Value |
|---|
DatabaseProperties
| Name | Description | Value |
|---|---|---|
| autoPauseDelay | 在幾分鐘后自動暫停資料庫的時間。 -1 值表示已停用自動暫停 | int |
| availabilityZone | 指定資料庫釘選到的可用性區域。 | '1' '2' '3' 'NoPreference' |
| catalogCollation | 元資料目錄的定序。 | 'DATABASE_DEFAULT' 'SQL_Latin1_General_CP1_CI_AS' |
| 定序 | 資料庫的定序。 | 字串 |
| createMode | 指定資料庫建立模式。 默認值:定期建立資料庫。 複製:建立資料庫做為現有資料庫的複本。 sourceDatabaseId 必須指定為源資料庫的資源標識碼。 次要:建立資料庫做為現有資料庫的次要複本。 sourceDatabaseId 必須指定為現有主資料庫的資源標識碼。 PointInTimeRestore:藉由還原現有資料庫的時間點備份來建立資料庫。 sourceDatabaseId 必須指定為現有資料庫的資源標識符,而且必須指定 restorePointInTime。 復原:藉由還原異地復寫備份來建立資料庫。 sourceDatabaseId 必須指定為要還原的可復原資料庫資源標識符。 還原:藉由還原已刪除資料庫的備份來建立資料庫。 必須指定sourceDatabaseId。 如果 sourceDatabaseId 是資料庫的原始資源識別碼,則必須指定 sourceDatabaseDeletionDate。 否則,sourceDatabaseId 必須是可還原的卸除資料庫資源標識符,而且會忽略 sourceDatabaseDeletionDate。 restorePointInTime 也可以指定為從先前的時間點還原。 RestoreLongTermRetentionBackup:從長期保留保存庫還原來建立資料庫。 recoveryServicesRecoveryPointResourceId 必須指定為恢復點資源標識符。 DataWarehouse 版本不支援 Copy、Secondary 和 RestoreLongTermRetentionBackup。 |
'Copy' 'Default' 'OnlineSecondary' 'PointInTimeRestore' 'Recovery' 'Restore' 'RestoreExternalBackup' 'RestoreExternalBackupSecondary' 'RestoreLongTermRetentionBackup' 'Secondary' |
| elasticPoolId | 包含此資料庫之彈性集區的資源標識碼。 | 字串 |
| encryptionProtector | 如果資料庫已針對每個資料庫客戶管理的金鑰進行設定,則為資料庫的 Azure 金鑰保存庫 URI。 | 字串 |
| encryptionProtectorAutoRotation | 啟用或停用資料庫加密保護裝置 AKV 金鑰自動輪替的旗標。 | bool |
| federatedClientId | 用於每個資料庫跨租使用者的用戶端標識碼 CMK 案例 | string Constraints: 最小長度 = 36 最大長度 = 36 圖案 = ^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$ |
| freeLimitExhaustionBehavior | 指定免費資料庫用完每月可用限制時的行為。 AutoPause:資料庫會在當月剩餘時間的可用限制用盡時自動暫停。 BillForUsage:資料庫會在免費限制用盡時繼續上線,並收取任何超額費用。 |
'AutoPause' 'BillOverUsage' |
| highAvailabilityReplicaCount | 與用來提供高可用性的商業關鍵、進階或超大規模資料庫相關聯的次要複本數目。 不適用於彈性集區內的超大規模資料庫。 | int |
| isLedgerOn | 這個資料庫是否為總賬資料庫,這表示資料庫中的所有數據表都是總賬數據表。 注意:建立資料庫之後,就無法變更此屬性的值。 | bool |
| keys | 要使用的使用者指派身分識別的資源標識碼 | DatabasePropertiesKeys |
| licenseType | 要套用此資料庫的授權類型。
LicenseIncluded 如果您需要授權,或 BasePrice 擁有授權且符合 Azure Hybrid Benefit 的資格。 |
'BasePrice' 'LicenseIncluded' |
| longTermRetentionBackupResourceId | 與此資料庫建立作業相關聯的長期保留備份資源標識符。 | 字串 |
| maintenanceConfigurationId | 指派給資料庫的維護組態標識碼。 此組態會定義維護更新發生的期間。 | 字串 |
| manualCutover | 客戶控制手動完全移轉是否需要在更新資料庫作業期間完成超大規模資料庫層。 只有在將資料庫從業務關鍵/一般用途/進階/標準層調整為超大規模資料庫層時,才適用此屬性。 指定manualCutover時,調整作業會等候使用者輸入觸發超大規模資料庫完全移轉。 若要觸發完全移轉,請在調整作業處於等候狀態時提供 『performCutover』 參數。 |
bool |
| maxSizeBytes | 以位元組表示的資料庫大小上限。 | int |
| minCapacity | 資料庫一律配置的最小容量,如果未暫停,則為 | int |
| performCutover | 在調整作業進行中時,觸發客戶控制的手動完全移轉。 這個屬性參數僅適用於起始與 'manualCutover' 參數一起起始的調整作業。 只有當資料庫從業務關鍵/一般用途/進階/標準層調整至超大規模資料庫層級正在進行時,才適用此屬性。 指定了performCutover時,調整作業會觸發完全移轉,並執行超大規模資料庫的角色變更。 |
bool |
| preferredEnclaveType | 資料庫上要求的記憶體保護區類型,也就是預設或 VBS記憶體保護區。 | 'Default' 'VBS' |
| readScale | 唯讀路由的狀態。 如果啟用,在其連接字串中將應用程式意圖設定為唯讀的連線,可能會路由傳送至相同區域中的唯讀次要複本。 不適用於彈性集區內的超大規模資料庫。 | 'Disabled' 'Enabled' |
| recoverableDatabaseId | 與此資料庫建立作業相關聯的可復原資料庫資源標識符。 | 字串 |
| recoveryServicesRecoveryPointId | 與此資料庫建立作業相關聯的恢復點資源標識碼。 | 字串 |
| requestedBackupStorageRedundancy | 要用來儲存此資料庫的備份的記憶體帳戶類型。 | 'Geo' 'GeoZone' 'Local' 'Zone' |
| restorableDroppedDatabaseId | 與這個資料庫建立作業相關聯的可還原卸除資料庫資源標識符。 | 字串 |
| restorePointInTime | 指定要還原以建立新資料庫的源資料庫的時間點(ISO8601格式)。 | 字串 |
| sampleName | 建立這個資料庫時要套用的範例架構名稱。 | 'AdventureWorksLT' 'WideWorldImportersFull' 'WideWorldImportersStd' |
| secondaryType | 如果資料庫是輔助資料庫,則為次要類型。 有效值為 Geo、Named 和 Standby。 | 'Geo' 'Named' 'Standby' |
| sourceDatabaseDeletionDate | 指定刪除資料庫的時間。 | 字串 |
| sourceDatabaseId | 與這個資料庫建立作業相關聯的源資料庫資源標識符。 | 字串 |
| sourceResourceId | 與這個資料庫建立作業相關聯的來源資源標識符。 只有 DataWarehouse 版本才支援此屬性,而且允許跨訂用帳戶還原。 指定 sourceResourceId 時,sourceDatabaseId、recoverableDatabaseId、restoreableDroppedDatabaseId 和 sourceDatabaseDeletionDate 不得指定,而 CreateMode 必須是 PointInTimeRestore、Restore 或 Recover。 當 createMode 是 PointInTimeRestore 時,sourceResourceId 必須是現有資料庫或現有 sql 集區的資源標識碼,而且必須指定 restorePointInTime。 當 createMode 為 Restore 時,sourceResourceId 必須是可還原卸除資料庫或可還原的已卸除 sql 集區的資源識別符。 當 createMode 為 Recover 時,sourceResourceId 必須是可復原資料庫或可復原 SQL 集區的資源標識碼。 當來源訂用帳戶屬於與目標訂用帳戶不同的租使用者時,“x-ms-authorization-auxiliary” 標頭必須包含來源租使用者的驗證令牌。 如需“x-ms-authorization-auxiliary” 標頭的詳細資訊,請參閱 /azure/azure-resource-manager/management/authenticate-multi-tenant |
字串 |
| useFreeLimit | 資料庫是否使用免費每月限制。 在訂用帳戶中的一個資料庫上允許。 | bool |
| zoneRedundant | 此資料庫是否為區域備援,這表示此資料庫的複本會分散到多個可用性區域。 | bool |
DatabasePropertiesKeys
| Name | Description | Value |
|---|
DatabaseUserIdentity
| Name | Description | Value |
|---|
Sku
| Name | Description | Value |
|---|---|---|
| 容量 | 特定 SKU 的容量。 | int |
| family | 如果服務有不同世代的硬體,針對相同的 SKU,則可以在這裡擷取。 | 字串 |
| name | SKU 的名稱,通常是字母 + 數位碼,例如 P3。 | 字串 (必要) |
| size | 特定 SKU 的大小 | 字串 |
| 分層 | 特定 SKU 的階層或版本,例如基本、進階。 | 字串 |
TrackedResourceTags
| Name | Description | Value |
|---|
使用範例
Azure 快速入門範本
下列 Azure 快速入門範本 部署此資源類型。
| Template | Description |
|---|---|
| 使用寫入 Log Analytics 稽核的 Azure SQL Server |
此樣本可讓您部署已啟用稽核的 Azure SQL 伺服器,以將稽核記錄寫入 Log Analytics (OMS 工作區) |
|
建立 SQL Server 和資料庫 |
此範本可讓您建立 SQL Database 和 Server。 |
|
具有透明加密的專用SQL集區 |
使用透明數據加密建立 SQL Server 和專用 SQL 集區(先前稱為 SQL DW)。 |
|
部署新的 SQL 彈性集區 |
此範本可讓您使用新的相關聯的 SQL Server 和新的 SQL Database 來部署新的 SQL 彈性集區,並將其指派給它。 |
|
在 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 身分識別將會獲得 Key Vault 秘密使用者角色。 |
| 使用 VNET 中的自訂 Ambari + Hive 中繼存放區 DB HDInsight |
此範本可讓您使用新的 SQL DB,在現有的虛擬網路中建立 HDInsight 叢集,以作為自訂 Ambari DB 和 Hive 中繼存放區。 您必須擁有現有的 SQL Sever、記憶體帳戶和 VNET。 |
|
私人端點範例 |
此範本示範如何建立指向 Azure SQL Server 的私人端點 |
|
使用 SQL Database 布建 Web 應用程式 |
此範本會布建 Web 應用程式、SQL Database、自動調整設定、警示規則和 App Insights。 它會在資料庫的 Web 應用程式中設定連接字串。 |
|
具有高可用性的遠端桌面服務 |
此 ARM 範例程式代碼會部署具有高可用性的 遠端桌面服務 2019 會話集合 實驗室。 目標是使用 Windows Server 2019 部署遠端桌面服務的完整備援高可用性解決方案。 |
| 使用 Azure SQL 在 Linux 上 Sonarqube Docker Web 應用程式 |
此範本會使用官方 Sonarqube 映像,並在 Azure SQL Server 支援下,在 Azure App Service Web 應用程式 Linux 容器中部署 Sonarqube。 |
|
具有受控識別、SQL Server 和 的 Web 應用程式 |
針對應用程式 + 資料 + 受控識別 + 監視部署 Azure 基礎結構的簡單範例 |
|
WebApp 取用 Azure SQL 私人端點 |
此範本示範如何建立 Web 應用程式,以取用指向 Azure SQL Server 的私人端點 |
Terraform (AzAPI 提供者) 資源定義
伺服器/資料庫資源類型可以使用目標作業來部署:
- 資源群組
如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔。
資源格式
若要建立 Microsoft.Sql/servers/databases 資源,請將下列 Terraform 新增至範本。
resource "azapi_resource" "symbolicname" {
type = "Microsoft.Sql/servers/databases@2024-11-01-preview"
name = "string"
parent_id = "string"
identity {
type = "string"
identity_ids = [
"string"
]
}
location = "string"
tags = {
{customized property} = "string"
}
body = {
properties = {
autoPauseDelay = int
availabilityZone = "string"
catalogCollation = "string"
collation = "string"
createMode = "string"
elasticPoolId = "string"
encryptionProtector = "string"
encryptionProtectorAutoRotation = bool
federatedClientId = "string"
freeLimitExhaustionBehavior = "string"
highAvailabilityReplicaCount = int
isLedgerOn = bool
keys = {
{customized property} = {
}
}
licenseType = "string"
longTermRetentionBackupResourceId = "string"
maintenanceConfigurationId = "string"
manualCutover = bool
maxSizeBytes = int
minCapacity = int
performCutover = bool
preferredEnclaveType = "string"
readScale = "string"
recoverableDatabaseId = "string"
recoveryServicesRecoveryPointId = "string"
requestedBackupStorageRedundancy = "string"
restorableDroppedDatabaseId = "string"
restorePointInTime = "string"
sampleName = "string"
secondaryType = "string"
sourceDatabaseDeletionDate = "string"
sourceDatabaseId = "string"
sourceResourceId = "string"
useFreeLimit = bool
zoneRedundant = bool
}
sku = {
capacity = int
family = "string"
name = "string"
size = "string"
tier = "string"
}
}
}
屬性值
Microsoft.Sql/servers/databases
| Name | Description | Value |
|---|---|---|
| 身分識別 | 資料庫的 Azure Active Directory 身分識別。 | DatabaseIdentity |
| 位置 | 資源位置。 | 字串 (必要) |
| name | 資源名稱 | 字串 (必要) |
| parent_id | 此資源為父系之資源的標識碼。 | 類型資源的標識碼:伺服器 |
| properties | 資源屬性。 | DatabaseProperties |
| sku | 資料庫 SKU。 SKU 清單可能會因區域和支援供應項目而異。 若要判斷 Azure 區域中訂用帳戶可用的 SKU(包括 SKU 名稱、層級/版本、系列和容量),請使用 Capabilities_ListByLocation REST API 或下列其中一個命令:azurecli<br />az sql db list-editions -l <location> -o table<br />````<br /><br />PowerShell<Get-AzSqlServerServiceObjective -Location 位置> ```` |
Sku |
| tags | 資源標籤 | 標記名稱和值的字典。 |
| 型別 | 資源類型 | 「Microsoft.Sql/servers/databases@2024-11-01-preview」 |
DatabaseIdentity
| Name | Description | Value |
|---|---|---|
| 型別 | 識別類型 | 'None' 'UserAssigned' |
| userAssignedIdentities | 要使用的使用者指派身分識別的資源標識碼 | DatabaseIdentityUserAssignedIdentities |
DatabaseIdentityUserAssignedIdentities
| Name | Description | Value |
|---|
DatabaseKey
| Name | Description | Value |
|---|
DatabaseProperties
| Name | Description | Value |
|---|---|---|
| autoPauseDelay | 在幾分鐘后自動暫停資料庫的時間。 -1 值表示已停用自動暫停 | int |
| availabilityZone | 指定資料庫釘選到的可用性區域。 | '1' '2' '3' 'NoPreference' |
| catalogCollation | 元資料目錄的定序。 | 'DATABASE_DEFAULT' 'SQL_Latin1_General_CP1_CI_AS' |
| 定序 | 資料庫的定序。 | 字串 |
| createMode | 指定資料庫建立模式。 默認值:定期建立資料庫。 複製:建立資料庫做為現有資料庫的複本。 sourceDatabaseId 必須指定為源資料庫的資源標識碼。 次要:建立資料庫做為現有資料庫的次要複本。 sourceDatabaseId 必須指定為現有主資料庫的資源標識碼。 PointInTimeRestore:藉由還原現有資料庫的時間點備份來建立資料庫。 sourceDatabaseId 必須指定為現有資料庫的資源標識符,而且必須指定 restorePointInTime。 復原:藉由還原異地復寫備份來建立資料庫。 sourceDatabaseId 必須指定為要還原的可復原資料庫資源標識符。 還原:藉由還原已刪除資料庫的備份來建立資料庫。 必須指定sourceDatabaseId。 如果 sourceDatabaseId 是資料庫的原始資源識別碼,則必須指定 sourceDatabaseDeletionDate。 否則,sourceDatabaseId 必須是可還原的卸除資料庫資源標識符,而且會忽略 sourceDatabaseDeletionDate。 restorePointInTime 也可以指定為從先前的時間點還原。 RestoreLongTermRetentionBackup:從長期保留保存庫還原來建立資料庫。 recoveryServicesRecoveryPointResourceId 必須指定為恢復點資源標識符。 DataWarehouse 版本不支援 Copy、Secondary 和 RestoreLongTermRetentionBackup。 |
'Copy' 'Default' 'OnlineSecondary' 'PointInTimeRestore' 'Recovery' 'Restore' 'RestoreExternalBackup' 'RestoreExternalBackupSecondary' 'RestoreLongTermRetentionBackup' 'Secondary' |
| elasticPoolId | 包含此資料庫之彈性集區的資源標識碼。 | 字串 |
| encryptionProtector | 如果資料庫已針對每個資料庫客戶管理的金鑰進行設定,則為資料庫的 Azure 金鑰保存庫 URI。 | 字串 |
| encryptionProtectorAutoRotation | 啟用或停用資料庫加密保護裝置 AKV 金鑰自動輪替的旗標。 | bool |
| federatedClientId | 用於每個資料庫跨租使用者的用戶端標識碼 CMK 案例 | string Constraints: 最小長度 = 36 最大長度 = 36 圖案 = ^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$ |
| freeLimitExhaustionBehavior | 指定免費資料庫用完每月可用限制時的行為。 AutoPause:資料庫會在當月剩餘時間的可用限制用盡時自動暫停。 BillForUsage:資料庫會在免費限制用盡時繼續上線,並收取任何超額費用。 |
'AutoPause' 'BillOverUsage' |
| highAvailabilityReplicaCount | 與用來提供高可用性的商業關鍵、進階或超大規模資料庫相關聯的次要複本數目。 不適用於彈性集區內的超大規模資料庫。 | int |
| isLedgerOn | 這個資料庫是否為總賬資料庫,這表示資料庫中的所有數據表都是總賬數據表。 注意:建立資料庫之後,就無法變更此屬性的值。 | bool |
| keys | 要使用的使用者指派身分識別的資源標識碼 | DatabasePropertiesKeys |
| licenseType | 要套用此資料庫的授權類型。
LicenseIncluded 如果您需要授權,或 BasePrice 擁有授權且符合 Azure Hybrid Benefit 的資格。 |
'BasePrice' 'LicenseIncluded' |
| longTermRetentionBackupResourceId | 與此資料庫建立作業相關聯的長期保留備份資源標識符。 | 字串 |
| maintenanceConfigurationId | 指派給資料庫的維護組態標識碼。 此組態會定義維護更新發生的期間。 | 字串 |
| manualCutover | 客戶控制手動完全移轉是否需要在更新資料庫作業期間完成超大規模資料庫層。 只有在將資料庫從業務關鍵/一般用途/進階/標準層調整為超大規模資料庫層時,才適用此屬性。 指定manualCutover時,調整作業會等候使用者輸入觸發超大規模資料庫完全移轉。 若要觸發完全移轉,請在調整作業處於等候狀態時提供 『performCutover』 參數。 |
bool |
| maxSizeBytes | 以位元組表示的資料庫大小上限。 | int |
| minCapacity | 資料庫一律配置的最小容量,如果未暫停,則為 | int |
| performCutover | 在調整作業進行中時,觸發客戶控制的手動完全移轉。 這個屬性參數僅適用於起始與 'manualCutover' 參數一起起始的調整作業。 只有當資料庫從業務關鍵/一般用途/進階/標準層調整至超大規模資料庫層級正在進行時,才適用此屬性。 指定了performCutover時,調整作業會觸發完全移轉,並執行超大規模資料庫的角色變更。 |
bool |
| preferredEnclaveType | 資料庫上要求的記憶體保護區類型,也就是預設或 VBS記憶體保護區。 | 'Default' 'VBS' |
| readScale | 唯讀路由的狀態。 如果啟用,在其連接字串中將應用程式意圖設定為唯讀的連線,可能會路由傳送至相同區域中的唯讀次要複本。 不適用於彈性集區內的超大規模資料庫。 | 'Disabled' 'Enabled' |
| recoverableDatabaseId | 與此資料庫建立作業相關聯的可復原資料庫資源標識符。 | 字串 |
| recoveryServicesRecoveryPointId | 與此資料庫建立作業相關聯的恢復點資源標識碼。 | 字串 |
| requestedBackupStorageRedundancy | 要用來儲存此資料庫的備份的記憶體帳戶類型。 | 'Geo' 'GeoZone' 'Local' 'Zone' |
| restorableDroppedDatabaseId | 與這個資料庫建立作業相關聯的可還原卸除資料庫資源標識符。 | 字串 |
| restorePointInTime | 指定要還原以建立新資料庫的源資料庫的時間點(ISO8601格式)。 | 字串 |
| sampleName | 建立這個資料庫時要套用的範例架構名稱。 | 'AdventureWorksLT' 'WideWorldImportersFull' 'WideWorldImportersStd' |
| secondaryType | 如果資料庫是輔助資料庫,則為次要類型。 有效值為 Geo、Named 和 Standby。 | 'Geo' 'Named' 'Standby' |
| sourceDatabaseDeletionDate | 指定刪除資料庫的時間。 | 字串 |
| sourceDatabaseId | 與這個資料庫建立作業相關聯的源資料庫資源標識符。 | 字串 |
| sourceResourceId | 與這個資料庫建立作業相關聯的來源資源標識符。 只有 DataWarehouse 版本才支援此屬性,而且允許跨訂用帳戶還原。 指定 sourceResourceId 時,sourceDatabaseId、recoverableDatabaseId、restoreableDroppedDatabaseId 和 sourceDatabaseDeletionDate 不得指定,而 CreateMode 必須是 PointInTimeRestore、Restore 或 Recover。 當 createMode 是 PointInTimeRestore 時,sourceResourceId 必須是現有資料庫或現有 sql 集區的資源標識碼,而且必須指定 restorePointInTime。 當 createMode 為 Restore 時,sourceResourceId 必須是可還原卸除資料庫或可還原的已卸除 sql 集區的資源識別符。 當 createMode 為 Recover 時,sourceResourceId 必須是可復原資料庫或可復原 SQL 集區的資源標識碼。 當來源訂用帳戶屬於與目標訂用帳戶不同的租使用者時,“x-ms-authorization-auxiliary” 標頭必須包含來源租使用者的驗證令牌。 如需“x-ms-authorization-auxiliary” 標頭的詳細資訊,請參閱 /azure/azure-resource-manager/management/authenticate-multi-tenant |
字串 |
| useFreeLimit | 資料庫是否使用免費每月限制。 在訂用帳戶中的一個資料庫上允許。 | bool |
| zoneRedundant | 此資料庫是否為區域備援,這表示此資料庫的複本會分散到多個可用性區域。 | bool |
DatabasePropertiesKeys
| Name | Description | Value |
|---|
DatabaseUserIdentity
| Name | Description | Value |
|---|
Sku
| Name | Description | Value |
|---|---|---|
| 容量 | 特定 SKU 的容量。 | int |
| family | 如果服務有不同世代的硬體,針對相同的 SKU,則可以在這裡擷取。 | 字串 |
| name | SKU 的名稱,通常是字母 + 數位碼,例如 P3。 | 字串 (必要) |
| size | 特定 SKU 的大小 | 字串 |
| 分層 | 特定 SKU 的階層或版本,例如基本、進階。 | 字串 |
TrackedResourceTags
| Name | Description | Value |
|---|
使用範例
Terraform 範例
部署 MS SQL 資料庫的基本範例。
terraform {
required_providers {
azapi = {
source = "Azure/azapi"
}
azurerm = {
source = "hashicorp/azurerm"
}
}
}
provider "azurerm" {
features {
}
}
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
}
data "azurerm_client_config" "current" {
}
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 = "mradministrator"
administratorLoginPassword = var.administrator_login_password
minimalTlsVersion = "1.2"
publicNetworkAccess = "Enabled"
restrictOutboundNetworkAccess = "Disabled"
version = "12.0"
}
}
schema_validation_enabled = false
response_export_values = ["*"]
}
data "azapi_resource_id" "publicMaintenanceConfiguration" {
type = "Microsoft.Maintenance/publicMaintenanceConfigurations@2023-04-01"
parent_id = "/subscriptions/${data.azurerm_client_config.current.subscription_id}"
name = "SQL_Default"
}
resource "azapi_resource" "database" {
type = "Microsoft.Sql/servers/databases@2021-02-01-preview"
parent_id = azapi_resource.server.id
name = var.resource_name
location = var.location
body = {
properties = {
autoPauseDelay = 0
createMode = "Default"
elasticPoolId = ""
highAvailabilityReplicaCount = 0
isLedgerOn = false
licenseType = "LicenseIncluded"
maintenanceConfigurationId = data.azapi_resource_id.publicMaintenanceConfiguration.id
minCapacity = 0
readScale = "Disabled"
requestedBackupStorageRedundancy = "Geo"
zoneRedundant = false
}
}
schema_validation_enabled = false
response_export_values = ["*"]
}
部署 MS SQL 資料庫的基本範例。
terraform {
required_providers {
azapi = {
source = "Azure/azapi"
}
azurerm = {
source = "hashicorp/azurerm"
}
}
}
provider "azurerm" {
features {
}
}
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
}
data "azurerm_client_config" "current" {
}
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 = "mradministrator"
administratorLoginPassword = var.administrator_login_password
minimalTlsVersion = "1.2"
publicNetworkAccess = "Enabled"
restrictOutboundNetworkAccess = "Disabled"
version = "12.0"
}
}
schema_validation_enabled = false
response_export_values = ["*"]
}
data "azapi_resource_id" "publicMaintenanceConfiguration" {
type = "Microsoft.Maintenance/publicMaintenanceConfigurations@2023-04-01"
parent_id = "/subscriptions/${data.azurerm_client_config.current.subscription_id}"
name = "SQL_Default"
}
resource "azapi_resource" "database" {
type = "Microsoft.Sql/servers/databases@2021-02-01-preview"
parent_id = azapi_resource.server.id
name = var.resource_name
location = var.location
body = {
properties = {
autoPauseDelay = 0
createMode = "Default"
elasticPoolId = ""
highAvailabilityReplicaCount = 0
isLedgerOn = false
licenseType = "LicenseIncluded"
maintenanceConfigurationId = data.azapi_resource_id.publicMaintenanceConfiguration.id
minCapacity = 0
readScale = "Disabled"
requestedBackupStorageRedundancy = "Geo"
zoneRedundant = false
}
}
schema_validation_enabled = false
response_export_values = ["*"]
}