9

是否可以将 Active Directory 管理员分配给 ARM 资源模板中的 Azure SQL 实例?我正在尝试自动部署数据库服务器,但我似乎只能指定本地服务器管理凭据。

        "properties": {
            "administratorLogin": "[parameters('databaseAdministratorLogin')]",
            "administratorLoginPassword": "[parameters('databaseAdministratorPassword')]",
            "version": "12.0"
        },

除此之外,似乎没有任何地方可以指定特定的 Azure AD 管理员。

4

2 回答 2

26

Microsoft 联系了我并提供了一个示例资源模板来完成此操作:

{
    "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "SQL Administrator Login": {
            "type": "String"
        },
        "SQL Administrator Password": {
            "type": "SecureString"
        },
        "AAD Admin Login": {
            "type": "String"
        },
        "AAD Admin ObjectID": {
            "type": "String"
        },
        "AAD TenantId": {
            "type": "String"
        },
        "Location (Region)": {
            "type": "String"
        },
        "Server Name": {
            "type": "String"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Sql/servers",
            "name": "[parameters('Server Name')]",
            "apiVersion": "2014-04-01-preview",
            "location": "[parameters('Location (Region)')]",
            "properties": {
                "administratorLogin": "[parameters('SQL Administrator Login')]",
                "administratorLoginPassword": "[parameters('SQL Administrator Password')]",
                "version": "12.0"
            },
            "resources": [
                {
                    "type": "firewallrules",
                    "name": "AllowAllWindowsAzureIps",
                    "apiVersion": "2014-04-01-preview",
                    "location": "[parameters('Location (Region)')]",
                    "properties": {
                        "endIpAddress": "0.0.0.0",
                       "startIpAddress": "0.0.0.0"
                    },
                    "dependsOn": [
                        "[concat('Microsoft.Sql/servers/', parameters('Server Name'))]"
                    ]
                },
                {
                    "type": "administrators",
                    "name": "activeDirectory",
                    "apiVersion": "2014-04-01-preview",
                    "location": "[parameters('Location (Region)')]",
                    "properties": {
                        "administratorType": "ActiveDirectory",
                        "login": "[parameters('AAD Admin Login')]",
                        "sid": "[parameters('AAD Admin ObjectID')]",
                        "tenantId": "[parameters('AAD TenantID')]"
                    },
                    "dependsOn": [
                        "[concat('Microsoft.Sql/servers/', parameters('Server Name'))]"
                    ]
                }
            ]
        }
    ]
}
于 2016-10-14T14:12:08.743 回答
0

修改:由于以下原因,上述内容不会运行:

CloudException:部署模板验证失败:“Microsoft.Sql/servers/administrators”类型在“168”行和“9”列的模板资源“activeDirectory”的段长度不正确。嵌套资源类型必须具有与其资源名称相同的段数。根资源类型的段长度必须比其资源名称大一。有关使用详情,请参阅https://aka.ms/arm-template/#resources

{
  "type": "Microsoft.Sql/servers/administrators",
  "name": "[concat(parameters('servers_tbg_backoffice_name'), '/', 'activeDirectory' )]",
  "apiVersion": "2014-04-01-preview",
  //"location": "[parameters('Location (Region)')]",
  "properties": {
    "administratorType": "ActiveDirectory",
    "login": "[parameters('AAD Admin Login')]",
    "sid": "[parameters('AAD Admin ObjectID')]",
    "tenantId": "[parameters('AAD TenantID')]"
  },
  "dependsOn": [
    "[concat('Microsoft.Sql/servers/', parameters('servers_tbg_backoffice_name'))]"
  ]
},
于 2018-06-29T01:14:30.873 回答