You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Learn how to use Azure SQL Database extensions to import a BACPAC file with Azure Resource Manager templates. Deployment artifacts are any files, in addition to the main template file that are needed to complete a deployment. The BACPAC file is an artifact. In this tutorial, you create a template to deploy an Azure SQL Server, a SQL Database, and import a BACPAC file. For information about deploying Azure virtual machine extensions using Azure Resource Manager templates, see [# Tutorial: Deploy virtual machine extensions with Azure Resource Manager templates](./resource-manager-tutorial-deploy-vm-extensions.md).
12
+
Learn how to use Azure SQL Database extensions to import a BACPAC file with Azure Resource Manager templates. Deployment artifacts are any files, in addition to the main template files that are needed to complete a deployment. The BACPAC file is an artifact. In this tutorial, you create a template to deploy an Azure SQL Server, a SQL Database, and import a BACPAC file. For information about deploying Azure virtual machine extensions using Azure Resource Manager templates, see [# Tutorial: Deploy virtual machine extensions with Azure Resource Manager templates](./resource-manager-tutorial-deploy-vm-extensions.md).
13
13
14
14
This tutorial covers the following tasks:
15
15
@@ -32,22 +32,68 @@ To complete this article, you need:
32
32
```azurecli-interactive
33
33
openssl rand -base64 32
34
34
```
35
+
35
36
Azure Key Vault is designed to safeguard cryptographic keys and other secrets. For more information, see [Tutorial: Integrate Azure Key Vault in Resource Manager Template deployment](./resource-manager-tutorial-use-key-vault.md). We also recommend you to update your password every three months.
36
37
37
38
## Prepare a BACPAC file
38
39
39
-
A BACPAC file is shared in [Github](https://github.com/Azure/azure-docs-json-samples/raw/master/tutorial-sql-extension/SQLDatabaseExtension.bacpac). To create your own, see [Export an Azure SQL database to a BACPAC file](../sql-database/sql-database-export.md). If you choose to publish the file to your own location, you must update the template later in the tutorial.
40
+
A BACPAC file is shared in [GitHub](https://github.com/Azure/azure-docs-json-samples/raw/master/tutorial-sql-extension/SQLDatabaseExtension.bacpac). To create your own, see [Export an Azure SQL database to a BACPAC file](../sql-database/sql-database-export.md). If you choose to publish the file to your own location, you must update the template later in the tutorial.
41
+
42
+
The BACPAC file must be stored in an Azure Storage account before it can be imported using Resource Manager template.
43
+
44
+
1. Open the [Cloud shell](https://shell.azure.com).
45
+
1. Select **Upload/Download files**, and then select **Upload**.
46
+
1. Specify the following URL and then select **Open**.
Write-Host "The storage account key is $storageAccountKey"
80
+
Write-Host "The BACPAC file URL is https://$storageAccountName.blob.core.windows.net/$containerName/$blobName"
81
+
Write-Host "Press [ENTER] to continue ..."
82
+
```
83
+
84
+
1. Write down storage account key and the BACPAC file URL. You need these values when you deploy the template.
40
85
41
86
## Open a Quickstart template
42
87
43
-
The template used in this tutorial is stored in [Github](https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/tutorial-sql-extension/azuredeploy.json).
88
+
The template used in this tutorial is stored in [GitHub](https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/tutorial-sql-extension/azuredeploy.json).
44
89
45
90
1. From Visual Studio Code, select **File**>**Open File**.
There are three resources defined in the template:
@@ -61,89 +107,121 @@ The template used in this tutorial is stored in [Github](https://raw.githubuserc
61
107
62
108
## Edit the template
63
109
64
-
Add two additional resources to the template.
65
-
66
-
* To allow the SQL database extension to import BACPAC files, you need to allow access to Azure services. Add the following JSON to the SQL server definition:
110
+
1. Add two more parameters at the end of the **parameters** section to set the storage account key and the BACPAC URL:
67
111
68
112
```json
69
-
{
70
-
"type": "firewallrules",
71
-
"name": "AllowAllAzureIps",
72
-
"location": "[parameters('location')]",
73
-
"apiVersion": "2015-05-01-preview",
74
-
"dependsOn": [
113
+
"storageAccountKey": {
114
+
"type":"string",
115
+
"metadata":{
116
+
"description": "Specifies the key of the storage account where the BACPAC file is stored."
117
+
}
118
+
},
119
+
"bacpacUrl": {
120
+
"type":"string",
121
+
"metadata":{
122
+
"description": "Specifies the URL of the BACPAC file."
123
+
}
124
+
}
125
+
```
126
+
127
+
Add a comma after **adminPassword**. To format the JSON file from VS Code, press **[SHIFT]+[ALT]+F**.
128
+
129
+
See [Prepare a BACPAC file](#prepare-a-bacpac-file) about getting these two values.
130
+
131
+
1. Add two additional resources to the template.
132
+
133
+
* To allow the SQL database extension to import BACPAC files, you need to allow traffic from Azure services. Add the following firewall rule definition under the SQL server definition:
To understand the resource definition, see the [SQL Database extension reference](https://docs.microsoft.com/azure/templates/microsoft.sql/servers/databases/extensions). The following are some important elements:
182
+
To understand the resource definition, see the [SQL Database extension reference](https://docs.microsoft.com/azure/templates/microsoft.sql/servers/databases/extensions). The following are some important elements:
116
183
117
-
* **dependsOn**: The extension resource must be created after the SQL database has been created.
118
-
* **storageKeyType**: The type of the storage key to use. The value can be either `StorageAccessKey` or `SharedAccessKey`. Because the provided BACPAC file is shared on an Azure Storage account with public access, `SharedAccessKey' is used here.
119
-
* **storageKey**: The storage key to use. If storage key type is SharedAccessKey, it must be preceded with a "?."
120
-
* **storageUri**: The storage uri to use. If you choose not to use the BACPAC file provided, you need to update the values.
121
-
* **administratorLoginPassword**: The password of the SQL administrator. Use a generated password. See [Prerequisites](#prerequisites).
184
+
* **dependsOn**: The extension resource must be created after the SQL database has been created.
185
+
* **storageKeyType**: Specify the type of the storage key to use. The value can be either `StorageAccessKey` or `SharedAccessKey`. Use `StorageAccessKey` in this tutorial.
186
+
* **storageKey**: Specify the key for the storage account where the BACPAC file is stored. If storage key type is SharedAccessKey, it must be preceded with a "?"
187
+
* **storageUri**: Specify the URL of the BACPAC file stored in a storage account.
188
+
* **administratorLoginPassword**: The password of the SQL administrator. Use a generated password. See [Prerequisites](#prerequisites).
Refer to the [Deploy the template](./resource-manager-tutorial-create-templates-with-dependent-resources.md#deploy-the-template) section for the deployment procedure. Use the following PowerShell deployment script instead:
128
195
129
-
```azurepowershell
130
-
$resourceGroupName = Read-Host -Prompt "Enter the Resource Group name"
196
+
```azurepowershell-interactive
197
+
$projectName = Read-Host -Prompt "Enter a project name that is used to generate Azure resource names"
131
198
$location = Read-Host -Prompt "Enter the location (i.e. centralus)"
132
199
$adminUsername = Read-Host -Prompt "Enter the SQL admin username"
133
200
$adminPassword = Read-Host -Prompt "Enter the admin password" -AsSecureString
201
+
$storageAccountKey = Read-Host -Prompt "Enter the storage account key"
202
+
$bacpacUrl = Read-Host -Prompt "Enter the URL of the BACPAC file"
Consider using the same project name as you used when you prepared the bacpac file, so that all the resources are stored within the same resource group. It is easier for managing resource, such as cleaning up the resources. If you use the same project name, you can either remove the **New-AzResourceGroup** command from the script, or answer y or n when you are asked whether you want to update the existing resource group.
218
+
143
219
Use a generated password. See [Prerequisites](#prerequisites).
144
220
145
221
## Verify the deployment
146
222
223
+
To access the SQL server from your client computer, you need to add an additional firewall rule. For more information, see [Create and manage IP firewall rules](../sql-database/sql-database-firewall-configure.md#create-and-manage-ip-firewall-rules).
224
+
147
225
In the portal, select the SQL database from the newly deployed resource group. Select **Query editor (preview)**, and then enter the administrator credentials. You shall see two tables imported into the database:
0 commit comments