你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Bicep 资源定义
可以使用目标操作部署 sqlVirtualMachines 资源类型:
有关每个 API 版本中已更改属性的列表,请参阅 更改日志。
资源格式
若要创建 Microsoft.SqlVirtualMachine/sqlVirtualMachines 资源,请将以下 Bicep 添加到模板。
resource symbolicname 'Microsoft.SqlVirtualMachine/sqlVirtualMachines@2023-10-01' = {
scope: resourceSymbolicName or scope
identity: {
type: 'string'
}
location: 'string'
name: 'string'
properties: {
assessmentSettings: {
enable: bool
runImmediately: bool
schedule: {
dayOfWeek: 'string'
enable: bool
monthlyOccurrence: int
startTime: 'string'
weeklyInterval: int
}
}
autoBackupSettings: {
backupScheduleType: 'string'
backupSystemDbs: bool
daysOfWeek: [
'string'
]
enable: bool
enableEncryption: bool
fullBackupFrequency: 'string'
fullBackupStartTime: int
fullBackupWindowHours: int
logBackupFrequency: int
password: 'string'
retentionPeriod: int
storageAccessKey: 'string'
storageAccountUrl: 'string'
storageContainerName: 'string'
}
autoPatchingSettings: {
additionalVmPatch: 'string'
dayOfWeek: 'string'
enable: bool
maintenanceWindowDuration: int
maintenanceWindowStartingHour: int
}
enableAutomaticUpgrade: bool
keyVaultCredentialSettings: {
azureKeyVaultUrl: 'string'
credentialName: 'string'
enable: bool
servicePrincipalName: 'string'
servicePrincipalSecret: 'string'
}
leastPrivilegeMode: 'string'
serverConfigurationsManagementSettings: {
additionalFeaturesServerConfigurations: {
isRServicesEnabled: bool
}
azureAdAuthenticationSettings: {
clientId: 'string'
}
sqlConnectivityUpdateSettings: {
connectivityType: 'string'
port: int
sqlAuthUpdatePassword: 'string'
sqlAuthUpdateUserName: 'string'
}
sqlInstanceSettings: {
collation: 'string'
isIfiEnabled: bool
isLpimEnabled: bool
isOptimizeForAdHocWorkloadsEnabled: bool
maxDop: int
maxServerMemoryMB: int
minServerMemoryMB: int
}
sqlStorageUpdateSettings: {
diskConfigurationType: 'string'
diskCount: int
startingDeviceId: int
}
sqlWorkloadTypeUpdateSettings: {
sqlWorkloadType: 'string'
}
}
sqlImageOffer: 'string'
sqlImageSku: 'string'
sqlManagement: 'string'
sqlServerLicenseType: 'string'
sqlVirtualMachineGroupResourceId: 'string'
storageConfigurationSettings: {
diskConfigurationType: 'string'
enableStorageConfigBlade: bool
sqlDataSettings: {
defaultFilePath: 'string'
luns: [
int
]
useStoragePool: bool
}
sqlLogSettings: {
defaultFilePath: 'string'
luns: [
int
]
useStoragePool: bool
}
sqlSystemDbOnDataDisk: bool
sqlTempDbSettings: {
dataFileCount: int
dataFileSize: int
dataGrowth: int
defaultFilePath: 'string'
logFileSize: int
logGrowth: int
luns: [
int
]
persistFolder: bool
persistFolderPath: 'string'
useStoragePool: bool
}
storageWorkloadType: 'string'
}
virtualMachineIdentitySettings: {
resourceId: 'string'
type: 'string'
}
virtualMachineResourceId: 'string'
wsfcDomainCredentials: {
clusterBootstrapAccountPassword: 'string'
clusterOperatorAccountPassword: 'string'
sqlServiceAccountPassword: 'string'
}
wsfcStaticIp: 'string'
}
tags: {
{customized property}: 'string'
}
}
属性值
Microsoft.SqlVirtualMachine/sqlVirtualMachines
| Name | Description | Value |
|---|---|---|
| 标识 | 请勿使用。 此值将弃用。 服务器的 Azure Active Directory 标识。 | ResourceIdentity |
| 位置 | 资源所在的地理位置 | string (必需) |
| name | 资源名称 | string Constraints: 最小长度 = 1 最大长度 = 64 模式 = ^((?!_)[^\\/"'\[\]:|<>+=;,?*@&]{1,64}(?<![.-]))$ (必需) |
| properties | 资源属性。 | SqlVirtualMachineProperties |
| 作用域 | 在与部署范围不同的范围内创建资源时使用。 | 将此属性设置为资源的符号名称以应用 扩展资源。 |
| tags | 资源标记 | 标记名称和值的字典。 请参阅模板 中的 |
AADAuthenticationSettings
| Name | Description | Value |
|---|---|---|
| clientId | 要查询Microsoft图形 API 的托管标识的客户端 ID。 空字符串必须用于系统分配的托管标识 | 字符串 |
AdditionalFeaturesServerConfigurations
| Name | Description | Value |
|---|---|---|
| isRServicesEnabled | 启用或禁用 R 服务(SQL 2016 及更高版本)。 | bool |
AssessmentSettings
| Name | Description | Value |
|---|---|---|
| 启用 | 启用或禁用 SQL 虚拟机上的 SQL 最佳做法评估功能。 | bool |
| runImmediately | 立即在 SQL 虚拟机上运行 SQL 最佳做法评估。 | bool |
| schedule | 计划 SQL 最佳做法评估。 | Schedule |
AutoBackupSettings
| Name | Description | Value |
|---|---|---|
| backupScheduleType | 备份计划类型。 | 'Automated' 'Manual' |
| backupSystemDbs | 包括或排除自动备份中的系统数据库。 | bool |
| daysOfWeek | 当 FullBackupFrequency 设置为“每周”时,备份的一周中的天数。 | 包含任一项的字符串数组: 'Friday' 'Monday' 'Saturday' 'Sunday' 'Thursday' 'Tuesday' 'Wednesday' |
| 启用 | 在 SQL 虚拟机上启用或禁用自动回退。 | bool |
| enableEncryption | 启用或禁用 SQL 虚拟机上备份的加密。 | bool |
| fullBackupFrequency | 完整备份的频率。 在这两种情况下,完整备份将在下一个计划的时间范围内开始。 | 'Daily' 'Weekly' |
| fullBackupStartTime | 给定日期的开始时间,在此期间可以进行完整备份。 0-23 小时。 | int |
| fullBackupWindowHours | 给定日期的时间窗口的持续时间,在此期间可以进行完整备份。 1-23 小时。 | int |
| logBackupFrequency | 日志备份的频率。 5-60 分钟。 | int |
| 密码 | 备份时加密的密码。 | 字符串 |
| retentionPeriod | 备份的保留期:1-90 天。 | int |
| storageAccessKey | 将备份到的存储帐户密钥。 | 字符串 |
| storageAccountUrl | 将备份到的存储帐户 URL。 | 字符串 |
| storageContainerName | 将备份到的存储容器名称。 | 字符串 |
AutoPatchingSettings
| Name | Description | Value |
|---|---|---|
| additionalVmPatch | 要在 SQL 虚拟机上启用或启用的其他修补程序。 | 'MicrosoftUpdate' 'NotSet' |
| dayOfWeek | 应用修补程序的一周中的一天。 | 'Everyday' 'Friday' 'Monday' 'Saturday' 'Sunday' 'Thursday' 'Tuesday' 'Wednesday' |
| 启用 | 在 SQL 虚拟机上启用或禁用自动修补。 | bool |
| maintenanceWindowDuration | 修补的持续时间。 | int |
| maintenanceWindowStartingHour | 开始修补的一天中的一小时。 本地 VM 时间。 | int |
KeyVaultCredentialSettings
| Name | Description | Value |
|---|---|---|
| azureKeyVaultUrl | Azure Key Vault URL。 | 字符串 |
| credentialName | 凭据名称。 | 字符串 |
| 启用 | 启用或禁用密钥保管库凭据设置。 | bool |
| servicePrincipalName | 用于访问密钥保管库的服务主体名称。 | 字符串 |
| servicePrincipalSecret | 用于访问密钥保管库的服务主体名称机密。 | 字符串 |
ResourceIdentity
| Name | Description | Value |
|---|---|---|
| 类型 | 标识类型。 将此设置为“SystemAssigned”,以便自动为资源创建和分配 Azure Active Directory 主体。 | 'None' 'SystemAssigned' 'SystemAssigned,UserAssigned' 'UserAssigned' |
Schedule
| Name | Description | Value |
|---|---|---|
| dayOfWeek | 运行评估的一周中的一天。 | 'Friday' 'Monday' 'Saturday' 'Sunday' 'Thursday' 'Tuesday' 'Wednesday' |
| 启用 | 在 SQL 虚拟机上启用或禁用评估计划。 | bool |
| monthlyOccurrence | 在一个月内发生 DayOfWeek 日期以安排评估。 采用值:1,2,3,4 和 -1。 对月份的最后一天使用 -1 OfWeek 日期 | int |
| startTime | 以 HH:mm 格式表示的一天时间。例如17:30 | 字符串 |
| weeklyInterval | 计划 2 个评估运行之间的周数。 从 1-6 获取值 | int |
ServerConfigurationsManagementSettings
| Name | Description | Value |
|---|---|---|
| additionalFeaturesServerConfigurations | 其他 SQL 功能设置。 | AdditionalFeaturesServerConfigurations |
| azureAdAuthenticationSettings | Azure AD 身份验证设置。 | AADAuthenticationSettings |
| sqlConnectivityUpdateSettings | SQL 连接类型设置。 | SqlConnectivityUpdateSettings |
| sqlInstanceSettings | SQL 实例设置。 | SQLInstanceSettings |
| sqlStorageUpdateSettings | SQL 存储更新设置。 | SqlStorageUpdateSettings |
| sqlWorkloadTypeUpdateSettings | SQL 工作负荷类型设置。 | SqlWorkloadTypeUpdateSettings |
SqlConnectivityUpdateSettings
| Name | Description | Value |
|---|---|---|
| connectivityType | SQL Server 连接选项。 | 'LOCAL' 'PRIVATE' 'PUBLIC' |
| 移植 | SQL Server 端口。 | int |
| sqlAuthUpdatePassword | SQL Server sysadmin 登录密码。 | 字符串 |
| sqlAuthUpdateUserName | 要创建的 SQL Server sysadmin 登录名。 | 字符串 |
SQLInstanceSettings
| Name | Description | Value |
|---|---|---|
| 排序规则 | SQL Server 排序规则。 | 字符串 |
| isIfiEnabled | SQL Server IFI。 | bool |
| isLpimEnabled | SQL Server LPIM。 | bool |
| isOptimizeForAdHocWorkloadsEnabled | SQL Server 针对 Adhoc 工作负载进行优化。 | bool |
| maxDop | SQL Server MAXDOP。 | int |
| maxServerMemoryMB | SQL Server 最大内存。 | int |
| minServerMemoryMB | SQL Server 最小内存。 | int |
SQLStorageSettings
| Name | Description | Value |
|---|---|---|
| defaultFilePath | SQL Server 默认文件路径 | 字符串 |
| luns | 磁盘的逻辑单元号。 | int[] |
| useStoragePool | 使用存储池生成驱动器(如果为 true 或未提供) | bool |
SqlStorageUpdateSettings
| Name | Description | Value |
|---|---|---|
| diskConfigurationType | 要应用于 SQL Server 的磁盘配置。 | 'ADD' 'EXTEND' 'NEW' |
| diskCount | 虚拟机磁盘计数。 | int |
| startingDeviceId | 要更新的第一个磁盘的设备 ID。 | int |
SQLTempDbSettings
| Name | Description | Value |
|---|---|---|
| dataFileCount | SQL Server tempdb 数据文件计数 | int |
| dataFileSize | SQL Server tempdb 数据文件大小 | int |
| dataGrowth | SQL Server tempdb 数据文件自动增长大小 | int |
| defaultFilePath | SQL Server 默认文件路径 | 字符串 |
| logFileSize | SQL Server tempdb 日志文件大小 | int |
| logGrowth | SQL Server tempdb 日志文件自动增长大小 | int |
| luns | 磁盘的逻辑单元号。 | int[] |
| persistFolder | SQL Server tempdb persist 文件夹选项 | bool |
| persistFolderPath | SQL Server tempdb 保留文件夹位置 | 字符串 |
| useStoragePool | 使用存储池生成驱动器(如果为 true 或未提供) | bool |
SqlVirtualMachineProperties
| Name | Description | Value |
|---|---|---|
| assessmentSettings | SQL 最佳做法评估设置。 | AssessmentSettings |
| autoBackupSettings | SQL Server 的自动备份设置。 | AutoBackupSettings |
| autoPatchingSettings | 自动修补设置,用于将关键安全更新应用到 SQL 虚拟机。 | AutoPatchingSettings |
| enableAutomaticUpgrade | 启用 Sql IaaS 扩展代理的自动升级。 | bool |
| keyVaultCredentialSettings | 密钥保管库凭据设置。 | KeyVaultCredentialSettings |
| leastPrivilegeMode | SQL IaaS 代理最低特权模式。 | 'Enabled' 'NotSet' |
| serverConfigurationsManagementSettings | SQL Server 配置管理设置。 | ServerConfigurationsManagementSettings |
| sqlImageOffer | SQL 映像产品/服务。 示例包括 SQL2016-WS2016、SQL2017-WS2016。 | 字符串 |
| sqlImageSku | SQL Server 版本类型。 | 'Developer' 'Enterprise' 'Express' 'Standard' 'Web' |
| sqlManagement | SQL Server 管理类型。 注意:不再使用此参数。 API 会自动检测 Sql 管理,避免使用它。 | 'Full' 'LightWeight' 'NoAgent' |
| sqlServerLicenseType | SQL Server 许可证类型。 | 'AHUB' 'DR' 'PAYG' |
| sqlVirtualMachineGroupResourceId | 此 SQL 虚拟机所属的 SQL 虚拟机组的 ARM 资源 ID 或将成为其中的一部分。 | 字符串 |
| storageConfigurationSettings | 存储配置设置。 | StorageConfigurationSettings |
| virtualMachineIdentitySettings | 用于 Sql IaaS 扩展配置的虚拟机标识详细信息。 | VirtualMachineIdentity |
| virtualMachineResourceId | 从 SQL 市场映像创建的基础虚拟机的 ARM 资源 ID。 | 字符串 |
| wsfcDomainCredentials | 用于为 SQL 可用性组设置 Windows Server 故障转移群集的域凭据。 | WsfcDomainCredentials |
| wsfcStaticIp | 用于为 SQL 可用性组设置 Windows Server 故障转移群集的域凭据。 | 字符串 |
SqlWorkloadTypeUpdateSettings
| Name | Description | Value |
|---|---|---|
| sqlWorkloadType | SQL Server 工作负荷类型。 | 'DW' 'GENERAL' 'OLTP' |
StorageConfigurationSettings
| Name | Description | Value |
|---|---|---|
| diskConfigurationType | 要应用于 SQL Server 的磁盘配置。 | 'ADD' 'EXTEND' 'NEW' |
| enableStorageConfigBlade | 在 Azure 门户中启用 SQL IaaS 代理存储配置边栏选项卡。 | bool |
| sqlDataSettings | SQL Server 数据存储设置。 | SQLStorageSettings |
| sqlLogSettings | SQL Server 日志存储设置。 | SQLStorageSettings |
| sqlSystemDbOnDataDisk | DataPool 上的 SQL Server SystemDb 存储(如果为 true)。 | bool |
| sqlTempDbSettings | SQL Server TempDb 存储设置。 | SQLTempDbSettings |
| storageWorkloadType | 存储工作负荷类型。 | 'DW' 'GENERAL' 'OLTP' |
TrackedResourceTags
| Name | Description | Value |
|---|
VirtualMachineIdentity
| Name | Description | Value |
|---|---|---|
| resourceId | 标识的 ARM 资源 ID。 仅当选择了 UserAssigned 标识时才是必需的。 | 字符串 |
| 类型 | 虚拟机的标识类型。 指定“无”以选择退出托管标识。 | 'None' 'SystemAssigned' 'UserAssigned' |
WsfcDomainCredentials
| Name | Description | Value |
|---|---|---|
| clusterBootstrapAccountPassword | 群集启动帐户密码。 | 字符串 |
| clusterOperatorAccountPassword | 群集操作员帐户密码。 | 字符串 |
| sqlServiceAccountPassword | SQL 服务帐户密码。 | 字符串 |
用法示例
Azure 快速入门示例
以下 Azure 快速入门模板 包含用于部署此资源类型的 Bicep 示例。
| Bicep 文件 | Description |
|---|---|
| 具有性能优化存储设置的 SQL Server VM | 在 PremiumSSD 上创建具有性能优化存储设置的 SQL Server 虚拟机 |
ARM 模板资源定义
可以使用目标操作部署 sqlVirtualMachines 资源类型:
有关每个 API 版本中已更改属性的列表,请参阅 更改日志。
资源格式
若要创建 Microsoft.SqlVirtualMachine/sqlVirtualMachines 资源,请将以下 JSON 添加到模板。
{
"type": "Microsoft.SqlVirtualMachine/sqlVirtualMachines",
"apiVersion": "2023-10-01",
"name": "string",
"identity": {
"type": "string"
},
"location": "string",
"properties": {
"assessmentSettings": {
"enable": "bool",
"runImmediately": "bool",
"schedule": {
"dayOfWeek": "string",
"enable": "bool",
"monthlyOccurrence": "int",
"startTime": "string",
"weeklyInterval": "int"
}
},
"autoBackupSettings": {
"backupScheduleType": "string",
"backupSystemDbs": "bool",
"daysOfWeek": [ "string" ],
"enable": "bool",
"enableEncryption": "bool",
"fullBackupFrequency": "string",
"fullBackupStartTime": "int",
"fullBackupWindowHours": "int",
"logBackupFrequency": "int",
"password": "string",
"retentionPeriod": "int",
"storageAccessKey": "string",
"storageAccountUrl": "string",
"storageContainerName": "string"
},
"autoPatchingSettings": {
"additionalVmPatch": "string",
"dayOfWeek": "string",
"enable": "bool",
"maintenanceWindowDuration": "int",
"maintenanceWindowStartingHour": "int"
},
"enableAutomaticUpgrade": "bool",
"keyVaultCredentialSettings": {
"azureKeyVaultUrl": "string",
"credentialName": "string",
"enable": "bool",
"servicePrincipalName": "string",
"servicePrincipalSecret": "string"
},
"leastPrivilegeMode": "string",
"serverConfigurationsManagementSettings": {
"additionalFeaturesServerConfigurations": {
"isRServicesEnabled": "bool"
},
"azureAdAuthenticationSettings": {
"clientId": "string"
},
"sqlConnectivityUpdateSettings": {
"connectivityType": "string",
"port": "int",
"sqlAuthUpdatePassword": "string",
"sqlAuthUpdateUserName": "string"
},
"sqlInstanceSettings": {
"collation": "string",
"isIfiEnabled": "bool",
"isLpimEnabled": "bool",
"isOptimizeForAdHocWorkloadsEnabled": "bool",
"maxDop": "int",
"maxServerMemoryMB": "int",
"minServerMemoryMB": "int"
},
"sqlStorageUpdateSettings": {
"diskConfigurationType": "string",
"diskCount": "int",
"startingDeviceId": "int"
},
"sqlWorkloadTypeUpdateSettings": {
"sqlWorkloadType": "string"
}
},
"sqlImageOffer": "string",
"sqlImageSku": "string",
"sqlManagement": "string",
"sqlServerLicenseType": "string",
"sqlVirtualMachineGroupResourceId": "string",
"storageConfigurationSettings": {
"diskConfigurationType": "string",
"enableStorageConfigBlade": "bool",
"sqlDataSettings": {
"defaultFilePath": "string",
"luns": [ "int" ],
"useStoragePool": "bool"
},
"sqlLogSettings": {
"defaultFilePath": "string",
"luns": [ "int" ],
"useStoragePool": "bool"
},
"sqlSystemDbOnDataDisk": "bool",
"sqlTempDbSettings": {
"dataFileCount": "int",
"dataFileSize": "int",
"dataGrowth": "int",
"defaultFilePath": "string",
"logFileSize": "int",
"logGrowth": "int",
"luns": [ "int" ],
"persistFolder": "bool",
"persistFolderPath": "string",
"useStoragePool": "bool"
},
"storageWorkloadType": "string"
},
"virtualMachineIdentitySettings": {
"resourceId": "string",
"type": "string"
},
"virtualMachineResourceId": "string",
"wsfcDomainCredentials": {
"clusterBootstrapAccountPassword": "string",
"clusterOperatorAccountPassword": "string",
"sqlServiceAccountPassword": "string"
},
"wsfcStaticIp": "string"
},
"tags": {
"{customized property}": "string"
}
}
属性值
Microsoft.SqlVirtualMachine/sqlVirtualMachines
| Name | Description | Value |
|---|---|---|
| apiVersion | API 版本 | '2023-10-01' |
| 标识 | 请勿使用。 此值将弃用。 服务器的 Azure Active Directory 标识。 | ResourceIdentity |
| 位置 | 资源所在的地理位置 | string (必需) |
| name | 资源名称 | string Constraints: 最小长度 = 1 最大长度 = 64 模式 = ^((?!_)[^\\/"'\[\]:|<>+=;,?*@&]{1,64}(?<![.-]))$ (必需) |
| properties | 资源属性。 | SqlVirtualMachineProperties |
| tags | 资源标记 | 标记名称和值的字典。 请参阅模板 中的 |
| 类型 | 资源类型 | 'Microsoft.SqlVirtualMachine/sqlVirtualMachines' |
AADAuthenticationSettings
| Name | Description | Value |
|---|---|---|
| clientId | 要查询Microsoft图形 API 的托管标识的客户端 ID。 空字符串必须用于系统分配的托管标识 | 字符串 |
AdditionalFeaturesServerConfigurations
| Name | Description | Value |
|---|---|---|
| isRServicesEnabled | 启用或禁用 R 服务(SQL 2016 及更高版本)。 | bool |
AssessmentSettings
| Name | Description | Value |
|---|---|---|
| 启用 | 启用或禁用 SQL 虚拟机上的 SQL 最佳做法评估功能。 | bool |
| runImmediately | 立即在 SQL 虚拟机上运行 SQL 最佳做法评估。 | bool |
| schedule | 计划 SQL 最佳做法评估。 | Schedule |
AutoBackupSettings
| Name | Description | Value |
|---|---|---|
| backupScheduleType | 备份计划类型。 | 'Automated' 'Manual' |
| backupSystemDbs | 包括或排除自动备份中的系统数据库。 | bool |
| daysOfWeek | 当 FullBackupFrequency 设置为“每周”时,备份的一周中的天数。 | 包含任一项的字符串数组: 'Friday' 'Monday' 'Saturday' 'Sunday' 'Thursday' 'Tuesday' 'Wednesday' |
| 启用 | 在 SQL 虚拟机上启用或禁用自动回退。 | bool |
| enableEncryption | 启用或禁用 SQL 虚拟机上备份的加密。 | bool |
| fullBackupFrequency | 完整备份的频率。 在这两种情况下,完整备份将在下一个计划的时间范围内开始。 | 'Daily' 'Weekly' |
| fullBackupStartTime | 给定日期的开始时间,在此期间可以进行完整备份。 0-23 小时。 | int |
| fullBackupWindowHours | 给定日期的时间窗口的持续时间,在此期间可以进行完整备份。 1-23 小时。 | int |
| logBackupFrequency | 日志备份的频率。 5-60 分钟。 | int |
| 密码 | 备份时加密的密码。 | 字符串 |
| retentionPeriod | 备份的保留期:1-90 天。 | int |
| storageAccessKey | 将备份到的存储帐户密钥。 | 字符串 |
| storageAccountUrl | 将备份到的存储帐户 URL。 | 字符串 |
| storageContainerName | 将备份到的存储容器名称。 | 字符串 |
AutoPatchingSettings
| Name | Description | Value |
|---|---|---|
| additionalVmPatch | 要在 SQL 虚拟机上启用或启用的其他修补程序。 | 'MicrosoftUpdate' 'NotSet' |
| dayOfWeek | 应用修补程序的一周中的一天。 | 'Everyday' 'Friday' 'Monday' 'Saturday' 'Sunday' 'Thursday' 'Tuesday' 'Wednesday' |
| 启用 | 在 SQL 虚拟机上启用或禁用自动修补。 | bool |
| maintenanceWindowDuration | 修补的持续时间。 | int |
| maintenanceWindowStartingHour | 开始修补的一天中的一小时。 本地 VM 时间。 | int |
KeyVaultCredentialSettings
| Name | Description | Value |
|---|---|---|
| azureKeyVaultUrl | Azure Key Vault URL。 | 字符串 |
| credentialName | 凭据名称。 | 字符串 |
| 启用 | 启用或禁用密钥保管库凭据设置。 | bool |
| servicePrincipalName | 用于访问密钥保管库的服务主体名称。 | 字符串 |
| servicePrincipalSecret | 用于访问密钥保管库的服务主体名称机密。 | 字符串 |
ResourceIdentity
| Name | Description | Value |
|---|---|---|
| 类型 | 标识类型。 将此设置为“SystemAssigned”,以便自动为资源创建和分配 Azure Active Directory 主体。 | 'None' 'SystemAssigned' 'SystemAssigned,UserAssigned' 'UserAssigned' |
Schedule
| Name | Description | Value |
|---|---|---|
| dayOfWeek | 运行评估的一周中的一天。 | 'Friday' 'Monday' 'Saturday' 'Sunday' 'Thursday' 'Tuesday' 'Wednesday' |
| 启用 | 在 SQL 虚拟机上启用或禁用评估计划。 | bool |
| monthlyOccurrence | 在一个月内发生 DayOfWeek 日期以安排评估。 采用值:1,2,3,4 和 -1。 对月份的最后一天使用 -1 OfWeek 日期 | int |
| startTime | 以 HH:mm 格式表示的一天时间。例如17:30 | 字符串 |
| weeklyInterval | 计划 2 个评估运行之间的周数。 从 1-6 获取值 | int |
ServerConfigurationsManagementSettings
| Name | Description | Value |
|---|---|---|
| additionalFeaturesServerConfigurations | 其他 SQL 功能设置。 | AdditionalFeaturesServerConfigurations |
| azureAdAuthenticationSettings | Azure AD 身份验证设置。 | AADAuthenticationSettings |
| sqlConnectivityUpdateSettings | SQL 连接类型设置。 | SqlConnectivityUpdateSettings |
| sqlInstanceSettings | SQL 实例设置。 | SQLInstanceSettings |
| sqlStorageUpdateSettings | SQL 存储更新设置。 | SqlStorageUpdateSettings |
| sqlWorkloadTypeUpdateSettings | SQL 工作负荷类型设置。 | SqlWorkloadTypeUpdateSettings |
SqlConnectivityUpdateSettings
| Name | Description | Value |
|---|---|---|
| connectivityType | SQL Server 连接选项。 | 'LOCAL' 'PRIVATE' 'PUBLIC' |
| 移植 | SQL Server 端口。 | int |
| sqlAuthUpdatePassword | SQL Server sysadmin 登录密码。 | 字符串 |
| sqlAuthUpdateUserName | 要创建的 SQL Server sysadmin 登录名。 | 字符串 |
SQLInstanceSettings
| Name | Description | Value |
|---|---|---|
| 排序规则 | SQL Server 排序规则。 | 字符串 |
| isIfiEnabled | SQL Server IFI。 | bool |
| isLpimEnabled | SQL Server LPIM。 | bool |
| isOptimizeForAdHocWorkloadsEnabled | SQL Server 针对 Adhoc 工作负载进行优化。 | bool |
| maxDop | SQL Server MAXDOP。 | int |
| maxServerMemoryMB | SQL Server 最大内存。 | int |
| minServerMemoryMB | SQL Server 最小内存。 | int |
SQLStorageSettings
| Name | Description | Value |
|---|---|---|
| defaultFilePath | SQL Server 默认文件路径 | 字符串 |
| luns | 磁盘的逻辑单元号。 | int[] |
| useStoragePool | 使用存储池生成驱动器(如果为 true 或未提供) | bool |
SqlStorageUpdateSettings
| Name | Description | Value |
|---|---|---|
| diskConfigurationType | 要应用于 SQL Server 的磁盘配置。 | 'ADD' 'EXTEND' 'NEW' |
| diskCount | 虚拟机磁盘计数。 | int |
| startingDeviceId | 要更新的第一个磁盘的设备 ID。 | int |
SQLTempDbSettings
| Name | Description | Value |
|---|---|---|
| dataFileCount | SQL Server tempdb 数据文件计数 | int |
| dataFileSize | SQL Server tempdb 数据文件大小 | int |
| dataGrowth | SQL Server tempdb 数据文件自动增长大小 | int |
| defaultFilePath | SQL Server 默认文件路径 | 字符串 |
| logFileSize | SQL Server tempdb 日志文件大小 | int |
| logGrowth | SQL Server tempdb 日志文件自动增长大小 | int |
| luns | 磁盘的逻辑单元号。 | int[] |
| persistFolder | SQL Server tempdb persist 文件夹选项 | bool |
| persistFolderPath | SQL Server tempdb 保留文件夹位置 | 字符串 |
| useStoragePool | 使用存储池生成驱动器(如果为 true 或未提供) | bool |
SqlVirtualMachineProperties
| Name | Description | Value |
|---|---|---|
| assessmentSettings | SQL 最佳做法评估设置。 | AssessmentSettings |
| autoBackupSettings | SQL Server 的自动备份设置。 | AutoBackupSettings |
| autoPatchingSettings | 自动修补设置,用于将关键安全更新应用到 SQL 虚拟机。 | AutoPatchingSettings |
| enableAutomaticUpgrade | 启用 Sql IaaS 扩展代理的自动升级。 | bool |
| keyVaultCredentialSettings | 密钥保管库凭据设置。 | KeyVaultCredentialSettings |
| leastPrivilegeMode | SQL IaaS 代理最低特权模式。 | 'Enabled' 'NotSet' |
| serverConfigurationsManagementSettings | SQL Server 配置管理设置。 | ServerConfigurationsManagementSettings |
| sqlImageOffer | SQL 映像产品/服务。 示例包括 SQL2016-WS2016、SQL2017-WS2016。 | 字符串 |
| sqlImageSku | SQL Server 版本类型。 | 'Developer' 'Enterprise' 'Express' 'Standard' 'Web' |
| sqlManagement | SQL Server 管理类型。 注意:不再使用此参数。 API 会自动检测 Sql 管理,避免使用它。 | 'Full' 'LightWeight' 'NoAgent' |
| sqlServerLicenseType | SQL Server 许可证类型。 | 'AHUB' 'DR' 'PAYG' |
| sqlVirtualMachineGroupResourceId | 此 SQL 虚拟机所属的 SQL 虚拟机组的 ARM 资源 ID 或将成为其中的一部分。 | 字符串 |
| storageConfigurationSettings | 存储配置设置。 | StorageConfigurationSettings |
| virtualMachineIdentitySettings | 用于 Sql IaaS 扩展配置的虚拟机标识详细信息。 | VirtualMachineIdentity |
| virtualMachineResourceId | 从 SQL 市场映像创建的基础虚拟机的 ARM 资源 ID。 | 字符串 |
| wsfcDomainCredentials | 用于为 SQL 可用性组设置 Windows Server 故障转移群集的域凭据。 | WsfcDomainCredentials |
| wsfcStaticIp | 用于为 SQL 可用性组设置 Windows Server 故障转移群集的域凭据。 | 字符串 |
SqlWorkloadTypeUpdateSettings
| Name | Description | Value |
|---|---|---|
| sqlWorkloadType | SQL Server 工作负荷类型。 | 'DW' 'GENERAL' 'OLTP' |
StorageConfigurationSettings
| Name | Description | Value |
|---|---|---|
| diskConfigurationType | 要应用于 SQL Server 的磁盘配置。 | 'ADD' 'EXTEND' 'NEW' |
| enableStorageConfigBlade | 在 Azure 门户中启用 SQL IaaS 代理存储配置边栏选项卡。 | bool |
| sqlDataSettings | SQL Server 数据存储设置。 | SQLStorageSettings |
| sqlLogSettings | SQL Server 日志存储设置。 | SQLStorageSettings |
| sqlSystemDbOnDataDisk | DataPool 上的 SQL Server SystemDb 存储(如果为 true)。 | bool |
| sqlTempDbSettings | SQL Server TempDb 存储设置。 | SQLTempDbSettings |
| storageWorkloadType | 存储工作负荷类型。 | 'DW' 'GENERAL' 'OLTP' |
TrackedResourceTags
| Name | Description | Value |
|---|
VirtualMachineIdentity
| Name | Description | Value |
|---|---|---|
| resourceId | 标识的 ARM 资源 ID。 仅当选择了 UserAssigned 标识时才是必需的。 | 字符串 |
| 类型 | 虚拟机的标识类型。 指定“无”以选择退出托管标识。 | 'None' 'SystemAssigned' 'UserAssigned' |
WsfcDomainCredentials
| Name | Description | Value |
|---|---|---|
| clusterBootstrapAccountPassword | 群集启动帐户密码。 | 字符串 |
| clusterOperatorAccountPassword | 群集操作员帐户密码。 | 字符串 |
| sqlServiceAccountPassword | SQL 服务帐户密码。 | 字符串 |
用法示例
Azure 快速入门模板
以下 Azure 快速入门模板 部署此资源类型。
| Template | Description |
|---|---|
|
使用现有 SQL 虚拟机 部署 SQL Always ON 设置 |
使用现有 SQL 虚拟机部署 SQL Always ON 安装程序。 虚拟机应已加入现有域,并且必须运行 SQL Server 的企业版本。 |
|
具有性能优化存储设置的 SQL Server VM |
在 PremiumSSD 上创建具有性能优化存储设置的 SQL Server 虚拟机 |
| 在 UltraSSD 上 |
使用 UltraSSD for SQL 日志文件创建具有性能优化存储设置的 SQL Server 虚拟机 |
Terraform (AzAPI 提供程序)资源定义
可以使用目标操作部署 sqlVirtualMachines 资源类型:
有关每个 API 版本中已更改属性的列表,请参阅 更改日志。
资源格式
若要创建 Microsoft.SqlVirtualMachine/sqlVirtualMachines 资源,请将以下 Terraform 添加到模板。
resource "azapi_resource" "symbolicname" {
type = "Microsoft.SqlVirtualMachine/sqlVirtualMachines@2023-10-01"
name = "string"
parent_id = "string"
identity {
type = "string"
identity_ids = [
"string"
]
}
location = "string"
tags = {
{customized property} = "string"
}
body = {
properties = {
assessmentSettings = {
enable = bool
runImmediately = bool
schedule = {
dayOfWeek = "string"
enable = bool
monthlyOccurrence = int
startTime = "string"
weeklyInterval = int
}
}
autoBackupSettings = {
backupScheduleType = "string"
backupSystemDbs = bool
daysOfWeek = [
"string"
]
enable = bool
enableEncryption = bool
fullBackupFrequency = "string"
fullBackupStartTime = int
fullBackupWindowHours = int
logBackupFrequency = int
password = "string"
retentionPeriod = int
storageAccessKey = "string"
storageAccountUrl = "string"
storageContainerName = "string"
}
autoPatchingSettings = {
additionalVmPatch = "string"
dayOfWeek = "string"
enable = bool
maintenanceWindowDuration = int
maintenanceWindowStartingHour = int
}
enableAutomaticUpgrade = bool
keyVaultCredentialSettings = {
azureKeyVaultUrl = "string"
credentialName = "string"
enable = bool
servicePrincipalName = "string"
servicePrincipalSecret = "string"
}
leastPrivilegeMode = "string"
serverConfigurationsManagementSettings = {
additionalFeaturesServerConfigurations = {
isRServicesEnabled = bool
}
azureAdAuthenticationSettings = {
clientId = "string"
}
sqlConnectivityUpdateSettings = {
connectivityType = "string"
port = int
sqlAuthUpdatePassword = "string"
sqlAuthUpdateUserName = "string"
}
sqlInstanceSettings = {
collation = "string"
isIfiEnabled = bool
isLpimEnabled = bool
isOptimizeForAdHocWorkloadsEnabled = bool
maxDop = int
maxServerMemoryMB = int
minServerMemoryMB = int
}
sqlStorageUpdateSettings = {
diskConfigurationType = "string"
diskCount = int
startingDeviceId = int
}
sqlWorkloadTypeUpdateSettings = {
sqlWorkloadType = "string"
}
}
sqlImageOffer = "string"
sqlImageSku = "string"
sqlManagement = "string"
sqlServerLicenseType = "string"
sqlVirtualMachineGroupResourceId = "string"
storageConfigurationSettings = {
diskConfigurationType = "string"
enableStorageConfigBlade = bool
sqlDataSettings = {
defaultFilePath = "string"
luns = [
int
]
useStoragePool = bool
}
sqlLogSettings = {
defaultFilePath = "string"
luns = [
int
]
useStoragePool = bool
}
sqlSystemDbOnDataDisk = bool
sqlTempDbSettings = {
dataFileCount = int
dataFileSize = int
dataGrowth = int
defaultFilePath = "string"
logFileSize = int
logGrowth = int
luns = [
int
]
persistFolder = bool
persistFolderPath = "string"
useStoragePool = bool
}
storageWorkloadType = "string"
}
virtualMachineIdentitySettings = {
resourceId = "string"
type = "string"
}
virtualMachineResourceId = "string"
wsfcDomainCredentials = {
clusterBootstrapAccountPassword = "string"
clusterOperatorAccountPassword = "string"
sqlServiceAccountPassword = "string"
}
wsfcStaticIp = "string"
}
}
}
属性值
Microsoft.SqlVirtualMachine/sqlVirtualMachines
| Name | Description | Value |
|---|---|---|
| 标识 | 请勿使用。 此值将弃用。 服务器的 Azure Active Directory 标识。 | ResourceIdentity |
| 位置 | 资源所在的地理位置 | string (必需) |
| name | 资源名称 | string Constraints: 最小长度 = 1 最大长度 = 64 模式 = ^((?!_)[^\\/"'\[\]:|<>+=;,?*@&]{1,64}(?<![.-]))$ (必需) |
| parent_id | 要向其应用此扩展资源的资源的 ID。 | string (必需) |
| properties | 资源属性。 | SqlVirtualMachineProperties |
| tags | 资源标记 | 标记名称和值的字典。 |
| 类型 | 资源类型 | "Microsoft.SqlVirtualMachine/sqlVirtualMachines@2023-10-01" |
AADAuthenticationSettings
| Name | Description | Value |
|---|---|---|
| clientId | 要查询Microsoft图形 API 的托管标识的客户端 ID。 空字符串必须用于系统分配的托管标识 | 字符串 |
AdditionalFeaturesServerConfigurations
| Name | Description | Value |
|---|---|---|
| isRServicesEnabled | 启用或禁用 R 服务(SQL 2016 及更高版本)。 | bool |
AssessmentSettings
| Name | Description | Value |
|---|---|---|
| 启用 | 启用或禁用 SQL 虚拟机上的 SQL 最佳做法评估功能。 | bool |
| runImmediately | 立即在 SQL 虚拟机上运行 SQL 最佳做法评估。 | bool |
| schedule | 计划 SQL 最佳做法评估。 | Schedule |
AutoBackupSettings
| Name | Description | Value |
|---|---|---|
| backupScheduleType | 备份计划类型。 | 'Automated' 'Manual' |
| backupSystemDbs | 包括或排除自动备份中的系统数据库。 | bool |
| daysOfWeek | 当 FullBackupFrequency 设置为“每周”时,备份的一周中的天数。 | 包含任一项的字符串数组: 'Friday' 'Monday' 'Saturday' 'Sunday' 'Thursday' 'Tuesday' 'Wednesday' |
| 启用 | 在 SQL 虚拟机上启用或禁用自动回退。 | bool |
| enableEncryption | 启用或禁用 SQL 虚拟机上备份的加密。 | bool |
| fullBackupFrequency | 完整备份的频率。 在这两种情况下,完整备份将在下一个计划的时间范围内开始。 | 'Daily' 'Weekly' |
| fullBackupStartTime | 给定日期的开始时间,在此期间可以进行完整备份。 0-23 小时。 | int |
| fullBackupWindowHours | 给定日期的时间窗口的持续时间,在此期间可以进行完整备份。 1-23 小时。 | int |
| logBackupFrequency | 日志备份的频率。 5-60 分钟。 | int |
| 密码 | 备份时加密的密码。 | 字符串 |
| retentionPeriod | 备份的保留期:1-90 天。 | int |
| storageAccessKey | 将备份到的存储帐户密钥。 | 字符串 |
| storageAccountUrl | 将备份到的存储帐户 URL。 | 字符串 |
| storageContainerName | 将备份到的存储容器名称。 | 字符串 |
AutoPatchingSettings
| Name | Description | Value |
|---|---|---|
| additionalVmPatch | 要在 SQL 虚拟机上启用或启用的其他修补程序。 | 'MicrosoftUpdate' 'NotSet' |
| dayOfWeek | 应用修补程序的一周中的一天。 | 'Everyday' 'Friday' 'Monday' 'Saturday' 'Sunday' 'Thursday' 'Tuesday' 'Wednesday' |
| 启用 | 在 SQL 虚拟机上启用或禁用自动修补。 | bool |
| maintenanceWindowDuration | 修补的持续时间。 | int |
| maintenanceWindowStartingHour | 开始修补的一天中的一小时。 本地 VM 时间。 | int |
KeyVaultCredentialSettings
| Name | Description | Value |
|---|---|---|
| azureKeyVaultUrl | Azure Key Vault URL。 | 字符串 |
| credentialName | 凭据名称。 | 字符串 |
| 启用 | 启用或禁用密钥保管库凭据设置。 | bool |
| servicePrincipalName | 用于访问密钥保管库的服务主体名称。 | 字符串 |
| servicePrincipalSecret | 用于访问密钥保管库的服务主体名称机密。 | 字符串 |
ResourceIdentity
| Name | Description | Value |
|---|---|---|
| 类型 | 标识类型。 将此设置为“SystemAssigned”,以便自动为资源创建和分配 Azure Active Directory 主体。 | 'None' 'SystemAssigned' 'SystemAssigned,UserAssigned' 'UserAssigned' |
Schedule
| Name | Description | Value |
|---|---|---|
| dayOfWeek | 运行评估的一周中的一天。 | 'Friday' 'Monday' 'Saturday' 'Sunday' 'Thursday' 'Tuesday' 'Wednesday' |
| 启用 | 在 SQL 虚拟机上启用或禁用评估计划。 | bool |
| monthlyOccurrence | 在一个月内发生 DayOfWeek 日期以安排评估。 采用值:1,2,3,4 和 -1。 对月份的最后一天使用 -1 OfWeek 日期 | int |
| startTime | 以 HH:mm 格式表示的一天时间。例如17:30 | 字符串 |
| weeklyInterval | 计划 2 个评估运行之间的周数。 从 1-6 获取值 | int |
ServerConfigurationsManagementSettings
| Name | Description | Value |
|---|---|---|
| additionalFeaturesServerConfigurations | 其他 SQL 功能设置。 | AdditionalFeaturesServerConfigurations |
| azureAdAuthenticationSettings | Azure AD 身份验证设置。 | AADAuthenticationSettings |
| sqlConnectivityUpdateSettings | SQL 连接类型设置。 | SqlConnectivityUpdateSettings |
| sqlInstanceSettings | SQL 实例设置。 | SQLInstanceSettings |
| sqlStorageUpdateSettings | SQL 存储更新设置。 | SqlStorageUpdateSettings |
| sqlWorkloadTypeUpdateSettings | SQL 工作负荷类型设置。 | SqlWorkloadTypeUpdateSettings |
SqlConnectivityUpdateSettings
| Name | Description | Value |
|---|---|---|
| connectivityType | SQL Server 连接选项。 | 'LOCAL' 'PRIVATE' 'PUBLIC' |
| 移植 | SQL Server 端口。 | int |
| sqlAuthUpdatePassword | SQL Server sysadmin 登录密码。 | 字符串 |
| sqlAuthUpdateUserName | 要创建的 SQL Server sysadmin 登录名。 | 字符串 |
SQLInstanceSettings
| Name | Description | Value |
|---|---|---|
| 排序规则 | SQL Server 排序规则。 | 字符串 |
| isIfiEnabled | SQL Server IFI。 | bool |
| isLpimEnabled | SQL Server LPIM。 | bool |
| isOptimizeForAdHocWorkloadsEnabled | SQL Server 针对 Adhoc 工作负载进行优化。 | bool |
| maxDop | SQL Server MAXDOP。 | int |
| maxServerMemoryMB | SQL Server 最大内存。 | int |
| minServerMemoryMB | SQL Server 最小内存。 | int |
SQLStorageSettings
| Name | Description | Value |
|---|---|---|
| defaultFilePath | SQL Server 默认文件路径 | 字符串 |
| luns | 磁盘的逻辑单元号。 | int[] |
| useStoragePool | 使用存储池生成驱动器(如果为 true 或未提供) | bool |
SqlStorageUpdateSettings
| Name | Description | Value |
|---|---|---|
| diskConfigurationType | 要应用于 SQL Server 的磁盘配置。 | 'ADD' 'EXTEND' 'NEW' |
| diskCount | 虚拟机磁盘计数。 | int |
| startingDeviceId | 要更新的第一个磁盘的设备 ID。 | int |
SQLTempDbSettings
| Name | Description | Value |
|---|---|---|
| dataFileCount | SQL Server tempdb 数据文件计数 | int |
| dataFileSize | SQL Server tempdb 数据文件大小 | int |
| dataGrowth | SQL Server tempdb 数据文件自动增长大小 | int |
| defaultFilePath | SQL Server 默认文件路径 | 字符串 |
| logFileSize | SQL Server tempdb 日志文件大小 | int |
| logGrowth | SQL Server tempdb 日志文件自动增长大小 | int |
| luns | 磁盘的逻辑单元号。 | int[] |
| persistFolder | SQL Server tempdb persist 文件夹选项 | bool |
| persistFolderPath | SQL Server tempdb 保留文件夹位置 | 字符串 |
| useStoragePool | 使用存储池生成驱动器(如果为 true 或未提供) | bool |
SqlVirtualMachineProperties
| Name | Description | Value |
|---|---|---|
| assessmentSettings | SQL 最佳做法评估设置。 | AssessmentSettings |
| autoBackupSettings | SQL Server 的自动备份设置。 | AutoBackupSettings |
| autoPatchingSettings | 自动修补设置,用于将关键安全更新应用到 SQL 虚拟机。 | AutoPatchingSettings |
| enableAutomaticUpgrade | 启用 Sql IaaS 扩展代理的自动升级。 | bool |
| keyVaultCredentialSettings | 密钥保管库凭据设置。 | KeyVaultCredentialSettings |
| leastPrivilegeMode | SQL IaaS 代理最低特权模式。 | 'Enabled' 'NotSet' |
| serverConfigurationsManagementSettings | SQL Server 配置管理设置。 | ServerConfigurationsManagementSettings |
| sqlImageOffer | SQL 映像产品/服务。 示例包括 SQL2016-WS2016、SQL2017-WS2016。 | 字符串 |
| sqlImageSku | SQL Server 版本类型。 | 'Developer' 'Enterprise' 'Express' 'Standard' 'Web' |
| sqlManagement | SQL Server 管理类型。 注意:不再使用此参数。 API 会自动检测 Sql 管理,避免使用它。 | 'Full' 'LightWeight' 'NoAgent' |
| sqlServerLicenseType | SQL Server 许可证类型。 | 'AHUB' 'DR' 'PAYG' |
| sqlVirtualMachineGroupResourceId | 此 SQL 虚拟机所属的 SQL 虚拟机组的 ARM 资源 ID 或将成为其中的一部分。 | 字符串 |
| storageConfigurationSettings | 存储配置设置。 | StorageConfigurationSettings |
| virtualMachineIdentitySettings | 用于 Sql IaaS 扩展配置的虚拟机标识详细信息。 | VirtualMachineIdentity |
| virtualMachineResourceId | 从 SQL 市场映像创建的基础虚拟机的 ARM 资源 ID。 | 字符串 |
| wsfcDomainCredentials | 用于为 SQL 可用性组设置 Windows Server 故障转移群集的域凭据。 | WsfcDomainCredentials |
| wsfcStaticIp | 用于为 SQL 可用性组设置 Windows Server 故障转移群集的域凭据。 | 字符串 |
SqlWorkloadTypeUpdateSettings
| Name | Description | Value |
|---|---|---|
| sqlWorkloadType | SQL Server 工作负荷类型。 | 'DW' 'GENERAL' 'OLTP' |
StorageConfigurationSettings
| Name | Description | Value |
|---|---|---|
| diskConfigurationType | 要应用于 SQL Server 的磁盘配置。 | 'ADD' 'EXTEND' 'NEW' |
| enableStorageConfigBlade | 在 Azure 门户中启用 SQL IaaS 代理存储配置边栏选项卡。 | bool |
| sqlDataSettings | SQL Server 数据存储设置。 | SQLStorageSettings |
| sqlLogSettings | SQL Server 日志存储设置。 | SQLStorageSettings |
| sqlSystemDbOnDataDisk | DataPool 上的 SQL Server SystemDb 存储(如果为 true)。 | bool |
| sqlTempDbSettings | SQL Server TempDb 存储设置。 | SQLTempDbSettings |
| storageWorkloadType | 存储工作负荷类型。 | 'DW' 'GENERAL' 'OLTP' |
TrackedResourceTags
| Name | Description | Value |
|---|
VirtualMachineIdentity
| Name | Description | Value |
|---|---|---|
| resourceId | 标识的 ARM 资源 ID。 仅当选择了 UserAssigned 标识时才是必需的。 | 字符串 |
| 类型 | 虚拟机的标识类型。 指定“无”以选择退出托管标识。 | 'None' 'SystemAssigned' 'UserAssigned' |
WsfcDomainCredentials
| Name | Description | Value |
|---|---|---|
| clusterBootstrapAccountPassword | 群集启动帐户密码。 | 字符串 |
| clusterOperatorAccountPassword | 群集操作员帐户密码。 | 字符串 |
| sqlServiceAccountPassword | SQL 服务帐户密码。 | 字符串 |
用法示例
Terraform 示例
部署 Microsoft 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 "vm_admin_password" {
type = string
description = "The administrator password for the SQL virtual machine"
sensitive = true
}
resource "azapi_resource" "resourceGroup" {
type = "Microsoft.Resources/resourceGroups@2020-06-01"
name = var.resource_name
location = var.location
}
resource "azapi_resource" "virtualNetwork" {
type = "Microsoft.Network/virtualNetworks@2022-07-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = {
properties = {
addressSpace = {
addressPrefixes = [
"10.0.0.0/16",
]
}
}
}
schema_validation_enabled = false
lifecycle {
ignore_changes = [body.properties.subnets]
}
}
resource "azapi_resource" "networkSecurityGroup" {
type = "Microsoft.Network/networkSecurityGroups@2024-05-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = azapi_resource.resourceGroup.location
body = {
properties = {
securityRules = [{
name = "MSSQLRule"
properties = {
access = "Allow"
destinationAddressPrefix = "*"
destinationAddressPrefixes = []
destinationPortRange = "1433"
destinationPortRanges = []
direction = "Inbound"
priority = 1001
protocol = "Tcp"
sourceAddressPrefix = "167.220.255.0/25"
sourceAddressPrefixes = []
sourcePortRange = "*"
sourcePortRanges = []
}
}]
}
}
}
resource "azapi_resource" "subnet" {
type = "Microsoft.Network/virtualNetworks/subnets@2022-07-01"
parent_id = azapi_resource.virtualNetwork.id
name = var.resource_name
body = {
properties = {
addressPrefix = "10.0.0.0/24"
networkSecurityGroup = {
id = azapi_resource.networkSecurityGroup.id
}
}
}
}
resource "azapi_resource" "publicIPAddress" {
type = "Microsoft.Network/publicIPAddresses@2024-05-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = azapi_resource.resourceGroup.location
body = {
properties = {
ddosSettings = {
protectionMode = "VirtualNetworkInherited"
}
idleTimeoutInMinutes = 4
ipTags = []
publicIPAddressVersion = "IPv4"
publicIPAllocationMethod = "Dynamic"
}
sku = {
name = "Basic"
tier = "Regional"
}
}
}
resource "azapi_resource" "networkInterface" {
type = "Microsoft.Network/networkInterfaces@2024-05-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = azapi_resource.resourceGroup.location
body = {
properties = {
disableTcpStateTracking = false
dnsSettings = {
dnsServers = []
}
enableAcceleratedNetworking = false
enableIPForwarding = false
ipConfigurations = [
{
type = "Microsoft.Network/networkInterfaces/ipConfigurations"
name = "testconfiguration1"
properties = {
privateIPAddressVersion = "IPv4"
privateIPAllocationMethod = "Dynamic"
publicIPAddress = {
id = azapi_resource.publicIPAddress.id
}
subnet = {
id = azapi_resource.subnet.id
}
primary = true
privateIPAddress = "10.0.0.4"
}
}
]
nicType = "Standard"
auxiliaryMode = "None"
auxiliarySku = "None"
}
}
}
resource "azapi_resource" "virtualMachine" {
type = "Microsoft.Compute/virtualMachines@2024-07-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = azapi_resource.resourceGroup.location
body = {
properties = {
osProfile = {
adminUsername = "testadmin"
adminPassword = var.vm_admin_password
allowExtensionOperations = true
computerName = "winhost01"
secrets = []
windowsConfiguration = {
timeZone = "Pacific Standard Time"
enableAutomaticUpdates = true
patchSettings = {
patchMode = "AutomaticByOS"
assessmentMode = "ImageDefault"
}
provisionVMAgent = true
}
}
storageProfile = {
dataDisks = []
imageReference = {
offer = "SQL2017-WS2016"
publisher = "MicrosoftSQLServer"
sku = "SQLDEV"
version = "latest"
}
osDisk = {
diskSizeGB = 127
managedDisk = {
storageAccountType = "Premium_LRS"
}
name = "acctvm-250116171212663925OSDisk"
osType = "Windows"
writeAcceleratorEnabled = false
caching = "ReadOnly"
createOption = "FromImage"
deleteOption = "Detach"
}
}
hardwareProfile = {
vmSize = "Standard_F2s"
}
networkProfile = {
networkInterfaces = [
{
properties = {
primary = false
}
id = azapi_resource.networkInterface.id
}
]
}
}
}
}
resource "azapi_resource" "sqlvirtualMachine" {
type = "Microsoft.SqlVirtualMachine/sqlVirtualMachines@2023-10-01"
parent_id = azapi_resource.resourceGroup.id
name = azapi_resource.virtualMachine.name
location = azapi_resource.virtualMachine.location
body = {
properties = {
sqlServerLicenseType = "PAYG"
virtualMachineResourceId = azapi_resource.virtualMachine.id
enableAutomaticUpgrade = true
leastPrivilegeMode = "Enabled"
sqlImageOffer = "SQL2017-WS2016"
sqlImageSku = "Developer"
sqlManagement = "Full"
}
}
}
部署 Microsoft SQL 虚拟机的 sqlbestpractices评估示例。
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 "admin_password" {
type = string
description = "The administrator password for the virtual machine"
sensitive = true
}
resource "azapi_resource" "resourceGroup" {
type = "Microsoft.Resources/resourceGroups@2020-06-01"
name = var.resource_name
location = var.location
}
resource "azapi_resource" "virtualNetwork" {
type = "Microsoft.Network/virtualNetworks@2022-07-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = {
properties = {
addressSpace = {
addressPrefixes = [
"10.0.0.0/16",
]
}
}
}
schema_validation_enabled = false
lifecycle {
ignore_changes = [body.properties.subnets]
}
}
resource "azapi_resource" "networkSecurityGroup" {
type = "Microsoft.Network/networkSecurityGroups@2024-05-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = azapi_resource.resourceGroup.location
body = {
properties = {
securityRules = [{
name = "MSSQLRule"
properties = {
access = "Allow"
destinationAddressPrefix = "*"
destinationAddressPrefixes = []
destinationPortRange = "1433"
destinationPortRanges = []
direction = "Inbound"
priority = 1001
protocol = "Tcp"
sourceAddressPrefix = "167.220.255.0/25"
sourceAddressPrefixes = []
sourcePortRange = "*"
sourcePortRanges = []
}
}]
}
}
}
resource "azapi_resource" "subnet" {
type = "Microsoft.Network/virtualNetworks/subnets@2022-07-01"
parent_id = azapi_resource.virtualNetwork.id
name = var.resource_name
body = {
properties = {
addressPrefix = "10.0.0.0/24"
networkSecurityGroup = {
id = azapi_resource.networkSecurityGroup.id
}
}
}
}
resource "azapi_resource" "publicIPAddress" {
type = "Microsoft.Network/publicIPAddresses@2024-05-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = azapi_resource.resourceGroup.location
body = {
properties = {
ddosSettings = {
protectionMode = "VirtualNetworkInherited"
}
idleTimeoutInMinutes = 4
ipTags = []
publicIPAddressVersion = "IPv4"
publicIPAllocationMethod = "Dynamic"
}
sku = {
name = "Basic"
tier = "Regional"
}
}
}
resource "azapi_resource" "networkInterface" {
type = "Microsoft.Network/networkInterfaces@2024-05-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = azapi_resource.resourceGroup.location
body = {
properties = {
disableTcpStateTracking = false
dnsSettings = {
dnsServers = []
}
enableAcceleratedNetworking = false
enableIPForwarding = false
ipConfigurations = [
{
type = "Microsoft.Network/networkInterfaces/ipConfigurations"
name = "testconfiguration1"
properties = {
privateIPAddressVersion = "IPv4"
privateIPAllocationMethod = "Dynamic"
publicIPAddress = {
id = azapi_resource.publicIPAddress.id
}
subnet = {
id = azapi_resource.subnet.id
}
primary = true
privateIPAddress = "10.0.0.4"
}
}
]
nicType = "Standard"
auxiliaryMode = "None"
auxiliarySku = "None"
}
}
}
resource "azapi_resource" "virtualMachine" {
type = "Microsoft.Compute/virtualMachines@2024-07-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = azapi_resource.resourceGroup.location
body = {
properties = {
osProfile = {
adminUsername = "testadmin"
adminPassword = var.admin_password
allowExtensionOperations = true
computerName = "winhost01"
secrets = []
windowsConfiguration = {
timeZone = "Pacific Standard Time"
enableAutomaticUpdates = true
patchSettings = {
patchMode = "AutomaticByOS"
assessmentMode = "ImageDefault"
}
provisionVMAgent = true
}
}
storageProfile = {
dataDisks = []
imageReference = {
offer = "SQL2017-WS2016"
publisher = "MicrosoftSQLServer"
sku = "SQLDEV"
version = "latest"
}
osDisk = {
diskSizeGB = 127
managedDisk = {
storageAccountType = "Premium_LRS"
}
name = "acctvm-250116171212663925OSDisk"
osType = "Windows"
writeAcceleratorEnabled = false
caching = "ReadOnly"
createOption = "FromImage"
deleteOption = "Detach"
}
}
hardwareProfile = {
vmSize = "Standard_F2s"
}
networkProfile = {
networkInterfaces = [
{
properties = {
primary = false
}
id = azapi_resource.networkInterface.id
}
]
}
}
}
}
resource "azapi_resource" "extension" {
type = "Microsoft.Compute/virtualMachines/extensions@2024-07-01"
parent_id = azapi_resource.virtualMachine.id
name = "AzureMonitorWindowsAgent"
location = "westeurope"
body = {
properties = {
autoUpgradeMinorVersion = true
enableAutomaticUpgrade = true
publisher = "Microsoft.Azure.Monitor"
suppressFailures = false
type = "AzureMonitorWindowsAgent"
typeHandlerVersion = "1.0"
}
}
}
resource "azapi_resource" "workspace" {
type = "Microsoft.OperationalInsights/workspaces@2020-08-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = azapi_resource.resourceGroup.location
body = {
properties = {
features = {
disableLocalAuth = false
enableLogAccessUsingOnlyResourcePermissions = true
legacy = 0
searchVersion = 1
}
publicNetworkAccessForIngestion = "Enabled"
publicNetworkAccessForQuery = "Enabled"
retentionInDays = 30
sku = {
name = "PerGB2018"
}
workspaceCapping = {
dailyQuotaGb = -1
}
}
}
}
resource "azapi_resource" "table" {
type = "Microsoft.OperationalInsights/workspaces/tables@2023-09-01"
parent_id = azapi_resource.workspace.id
name = "SqlAssessment_CL"
body = {
properties = {
schema = {
name = "SqlAssessment_CL"
columns = [
{
name = "TimeGenerated"
type = "datetime"
},
{
type = "string"
name = "RawData"
}
]
}
}
}
}
resource "azapi_resource" "dataCollectionEndpoint" {
type = "Microsoft.Insights/dataCollectionEndpoints@2022-06-01"
parent_id = azapi_resource.resourceGroup.id
name = "${var.location}-DCE-1"
location = azapi_resource.resourceGroup.location
body = {
properties = {
networkAcls = {
publicNetworkAccess = "Enabled"
}
}
}
}
resource "azapi_resource" "dataCollectionRule" {
type = "Microsoft.Insights/dataCollectionRules@2022-06-01"
parent_id = azapi_resource.resourceGroup.id
name = "${azapi_resource.workspace.output.properties.customerId}_${azapi_resource.resourceGroup.location}_DCR_1"
location = azapi_resource.resourceGroup.location
body = {
properties = {
streamDeclarations = {
Custom-SqlAssessment_CL = {
columns = [
{
name = "TimeGenerated"
type = "datetime"
},
{
type = "string"
name = "RawData"
}
]
}
}
dataCollectionEndpointId = azapi_resource.dataCollectionEndpoint.id
dataFlows = [
{
outputStream = "Custom-SqlAssessment_CL"
streams = [
"Custom-SqlAssessment_CL"
]
transformKql = "source"
destinations = [
azapi_resource.workspace.name
]
}
]
dataSources = {
logFiles = [
{
filePatterns = [
"C:\\Windows\\System32\\config\\systemprofile\\AppData\\Local\\Microsoft SQL Server IaaS Agent\\Assessment\\*.csv"
]
format = "text"
name = "Custom-SqlAssessment_CL"
settings = {
text = {
recordStartTimestampFormat = "ISO 8601"
}
}
streams = [
"Custom-SqlAssessment_CL"
]
}
]
}
description = ""
destinations = {
logAnalytics = [
{
name = azapi_resource.workspace.name
workspaceResourceId = azapi_resource.workspace.id
}
]
}
}
}
depends_on = [azapi_resource.table]
}
resource "azapi_resource" "dataCollectionRuleAssociation" {
type = "Microsoft.Insights/dataCollectionRuleAssociations@2022-06-01"
parent_id = azapi_resource.virtualMachine.id
name = "${azapi_resource.workspace.output.properties.customerId}_${azapi_resource.resourceGroup.location}_DCRA_1"
body = {
properties = {
dataCollectionRuleId = azapi_resource.dataCollectionRule.id
}
}
}
resource "azapi_resource" "sqlvirtualMachine" {
type = "Microsoft.SqlVirtualMachine/sqlVirtualMachines@2023-10-01"
parent_id = azapi_resource.resourceGroup.id
name = azapi_resource.virtualMachine.name
location = azapi_resource.virtualMachine.location
body = {
properties = {
sqlServerLicenseType = "PAYG"
virtualMachineResourceId = azapi_resource.virtualMachine.id
enableAutomaticUpgrade = true
leastPrivilegeMode = "Enabled"
sqlImageOffer = "SQL2017-WS2016"
sqlImageSku = "Developer"
sqlManagement = "Full"
assessmentSettings = {
enable = true
runImmediately = false
schedule = {
dayOfWeek = "Monday"
enable = true
startTime = "00:00"
weeklyInterval = 1
}
}
}
}
depends_on = [
azapi_resource.dataCollectionRuleAssociation,
azapi_resource.extension,
]
}