Как добавить группы Azure AD с помощью сценария ARM в базу данных SQL Azure - PullRequest
0 голосов
/ 31 мая 2018

Я создаю новый SQL Azure с двумя базами данных и эластичным пулом через скрипт ARM.Это мои сценарии

azure.deploy.ps1

{
  "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "administratorLogin": {
      "type": "string",
      "metadata": {
        "description": "The SQL Server administrator login"
      }
    },
    "administratorLoginPassword": {
      "type": "securestring",
      "metadata": {
        "description": "The SQL Server administrator login password."
      }
    },
    "serverName": {
      "type": "string",
      "metadata": {
        "description": "The SQL Server name."
      }
    },
    "elasticPoolName": {
      "type": "string",
      "metadata": {
        "description": "The Elastic Pool name."
      }
    },
    "edition": {
      "type": "string",
      "defaultValue": "Standard",
      "allowedValues": [
        "Basic",
        "Standard",
        "Premium"
      ],
      "metadata": {
        "description": "The Elastic Pool edition."
      }
    },
    "poolDtu": {
      "type": "int",
      "metadata": {
        "description": "The Elastic Pool DTU."
      }
    },
    "databaseDtuMin": {
      "type": "int",
      "defaultValue": 0,
      "metadata": {
        "description": "The Elastic Pool database DTU min."
      }
    },
    "databaseDtuMax": {
      "type": "int",
      "metadata": {
        "description": "The Elastic Pool database DTU max."
      }
    },
    "databasesNames": {
      "type": "array",
      "defaultValue": [
        "db1",
        "db2"
      ],
      "metadata": {
        "description": "The SQL Databases names."
      }
    },
    "databaseCollation": {
      "type": "string",
      "defaultValue": "SQL_Latin1_General_CP1_CI_AS",
      "metadata": {
        "description": "The SQL Database collation."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
      }
    }
  },
  "variables": {},
  "resources": [
    {
      "apiVersion": "2014-04-01-preview",
      "location": "[parameters('location')]",
      "name": "[parameters('serverName')]",
      "properties": {
        "administratorLogin": "[parameters('administratorLogin')]",
        "administratorLoginPassword": "[parameters('administratorLoginPassword')]",
        "version": "12.0"
      },
      "type": "Microsoft.Sql/servers"
    },
    {
      "apiVersion": "2014-04-01",
      "dependsOn": [
        "[concat('Microsoft.Sql/servers/', parameters('serverName'))]"
      ],
      "location": "[parameters('location')]",
      "name": "[concat(parameters('serverName'), '/', parameters('elasticPoolName'))]",
      "properties": {
        "edition": "[parameters('edition')]",
        "dtu": "[parameters('poolDtu')]",
        "databaseDtuMin": "[parameters('databaseDtuMin')]",
        "databaseDtuMax": "[parameters('databaseDtuMax')]"
      },
      "type": "Microsoft.Sql/servers/elasticPools"
    },
    {
      "type": "Microsoft.Sql/servers/databases",
      "name": "[concat(parameters('serverName'), '/', parameters('databasesNames')[copyIndex()])]",
      "location": "[parameters('location')]",
      "apiVersion": "2014-04-01-preview",
      "dependsOn": [
        "[concat('Microsoft.Sql/servers/', parameters('serverName'))]",
        "[concat('Microsoft.Sql/servers/', parameters('serverName') ,'/elasticpools/', parameters('elasticPoolName'))]"
      ],
      "properties": {
        "collation": "[parameters('databaseCollation')]",
        "requestedServiceObjectiveName": "ElasticPool",
        "elasticPoolName": "[parameters('elasticPoolName')]"
      },
      "copy": {
        "name": "addDatabasesInElasticPool",
        "count": "[length(parameters('databasesNames'))]"
      }
    },
    {
      "apiVersion": "2014-04-01-preview",
      "dependsOn": [
        "[concat('Microsoft.Sql/servers/', parameters('serverName'))]"
      ],
      "location": "[parameters('location')]",
      "name": "[concat(parameters('serverName'), '/', 'AllowAllWindowsAzureIps')]",
      "properties": {
        "endIpAddress": "0.0.0.0",
        "startIpAddress": "0.0.0.0"
      },
      "type": "Microsoft.Sql/servers/firewallrules"
    }
  ]
}

и это файл параметров:

azure.deploy.parameters.ps1

{
  "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "administratorLogin": {
      "value": "bogblogsqldbadmin"
    },
    "serverName": {
      "value": "azrsqlsrv1"
    },
    "elasticPoolName": {
      "value": "azrsqlsrve1"
    },
    "poolDtu": {
      "value": 100
    },
    "databaseDtuMax": {
      "value": 100
    },
    "databasesNames": {
      "value": [ "asqldb11", "asqldb12" ]
    }
  }
}

Я хотел бы использовать Azure AD и группы для аутентификации пользователей в этой базе данных.Я хотел бы добавить эти группы и конфигурацию для использования Azure AD непосредственно в мои сценарии ARM.Как я могу это сделать?Это возможно?

1 Ответ

0 голосов
/ 31 мая 2018

Ниже может помочь пример:

{
    "$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'))]"
                    ]
                }
            ]
        }
    ]
}
...