如何在 Azure 资源管理器 (ARM) 模板中指定通用目的:Azure SQL 数据库(Microsoft.Sql/managedInstances 资源)的无服务器层?
{“resources”: [{..., “sku”: {..., “tier”: ???}}]} 的适当值是多少
简而言之,我如何使用基础设施即代码来提供无服务器数据库?
如何在 Azure 资源管理器 (ARM) 模板中指定通用目的:Azure SQL 数据库(Microsoft.Sql/managedInstances 资源)的无服务器层?
{“resources”: [{..., “sku”: {..., “tier”: ???}}]} 的适当值是多少
简而言之,我如何使用基础设施即代码来提供无服务器数据库?
这是一个模板(template.json):
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"collation": {
"type": "string"
},
"databaseName": {
"type": "string"
},
"tier": {
"type": "string"
},
"skuName": {
"type": "string"
},
"maxSizeBytes": {
"type": "int"
},
"serverName": {
"type": "string"
},
"serverLocation": {
"type": "string"
},
"sampleName": {
"type": "string",
"defaultValue": ""
},
"zoneRedundant": {
"type": "bool",
"defaultValue": false
},
"licenseType": {
"type": "string",
"defaultValue": ""
},
"readScaleOut": {
"type": "string",
"defaultValue": "Disabled"
},
"numberOfReplicas": {
"type": "int",
"defaultValue": 0
},
"minCapacity": {
"type": "string",
"defaultValue": ""
},
"autoPauseDelay": {
"type": "string",
"defaultValue": ""
},
"databaseTags": {
"type": "object",
"defaultValue": {}
},
"enableADS": {
"type": "bool",
"defaultValue": false
},
"enableVA": {
"type": "bool",
"defaultValue": false
}
},
"resources": [
{
"condition": "[parameters('enableVA')]",
"apiVersion": "2016-01-01",
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageName')]",
"location": "[parameters('serverLocation')]",
"sku": {
"name": "Standard_LRS"
},
"kind": "Storage",
"properties": {}
},
{
"type": "Microsoft.Sql/servers/databases",
"apiVersion": "2017-10-01-preview",
"location": "[parameters('serverLocation')]",
"tags": "[parameters('databaseTags')]",
"name": "[concat(parameters('serverName'), '/', parameters('databaseName'))]",
"properties": {
"collation": "[parameters('collation')]",
"maxSizeBytes": "[parameters('maxSizeBytes')]",
"sampleName": "[parameters('sampleName')]",
"zoneRedundant": "[parameters('zoneRedundant')]",
"licenseType": "[parameters('licenseType')]",
"readScale": "[parameters('readScaleOut')]",
"readReplicaCount": "[parameters('numberOfReplicas')]",
"minCapacity": "[parameters('minCapacity')]",
"autoPauseDelay": "[parameters('autoPauseDelay')]"
},
"sku": {
"name": "[parameters('skuName')]",
"tier": "[parameters('tier')]"
}
},
{
"condition": "[parameters('enableADS')]",
"apiVersion": "2017-03-01-preview",
"type": "Microsoft.Sql/servers/securityAlertPolicies",
"name": "[concat(parameters('serverName'), '/Default')]",
"dependsOn": [
"[concat('Microsoft.Sql/servers/', parameters('serverName'), '/databases/', parameters('databaseName'))]"
],
"properties": {
"state": "Enabled",
"disabledAlerts": [],
"emailAddresses": [],
"emailAccountAdmins": true
}
},
{
"condition": "[parameters('enableVA')]",
"apiVersion": "2018-06-01-preview",
"type": "Microsoft.Sql/servers/vulnerabilityAssessments",
"name": "[concat(parameters('serverName'), '/Default')]",
"properties": {
"storageContainerPath": "[if(parameters('enableVA'), concat(reference(variables('storageName'), '2018-02-01').primaryEndpoints.blob, 'vulnerability-assessment'), '')]",
"storageAccountAccessKey": "[if(parameters('enableVA'), listKeys(variables('storageName'), '2018-02-01').keys[0].value, '')]",
"recurringScans": {
"isEnabled": true,
"emailSubscriptionAdmins": true,
"emails": []
}
},
"dependsOn": [
"[concat('Microsoft.Sql/servers/', parameters('serverName'), '/databases/', parameters('databaseName'))]",
"[concat('Microsoft.Storage/storageAccounts/', variables('storageName'))]",
"[concat('Microsoft.Sql/servers/', parameters('serverName'), '/securityAlertPolicies/Default')]"
]
}
],
"variables": {
"subscriptionId": "[subscription().subscriptionId]",
"resourceGroupName": "[resourceGroup().name]",
"uniqueStorage": "[uniqueString(variables('subscriptionId'), variables('resourceGroupName'), parameters('serverLocation'))]",
"storageName": "[tolower(concat('sqlva', variables('uniqueStorage')))]"
}
}
这是模板的参数文件(parameters.json):
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"collation": {
"value": "SQL_Latin1_General_CP1_CI_AS"
},
"databaseName": {
"value": "MorilloServerless"
},
"tier": {
"value": "GeneralPurpose"
},
"skuName": {
"value": "GP_S_Gen5_1"
},
"maxSizeBytes": {
"value": 34359738368
},
"sampleName": {
"value": ""
},
"serverLocation": {
"value": "eastus2"
},
"serverName": {
"value": "morillo"
},
"zoneRedundant": {
"value": false
},
"licenseType": {
"value": "LicenseIncluded"
},
"readScaleOut": {
"value": "Disabled"
},
"numberOfReplicas": {
"value": 0
},
"minCapacity": {
"value": "0.5"
},
"autoPauseDelay": {
"value": "60"
},
"databaseTags": {
"value": {}
},
"enableADS": {
"value": false
},
"enableVA": {
"value": false
}
}
}
查看 SKUName 以了解如何指定无服务器数据库。