Import database when policy "Azure SQL DB should avoid using GRS backup" is enforced

Published 12-06-2020 03:43 PM 1,667 Views
Microsoft

Symptoms:

Creating or importing database failed due to violation of policy “Azure SQL DB should avoid using GRS backup”

When creating database, you should specify the backup storage to be used, while the default is GRS (Globally redundant storage) and it violates the policy.

While importing database either using Azure Portal, RestAPI, SSMS or SQLPackage you cannot specify the backup storage as it’s not implemented yet.

This cause the import operation to fail with the following exception:

Configuring backup storage account type to 'Standard_RAGRS' failed during Database create or update.

 

Solution:

You can either

  • create the database with local backup storage and then import to existing database.
  • Use ARM Template to do both create the database with local backup storage and import the bacpac file.

 

Examples:

Option (A)

  1. Create the database with Azure Portal or by using T-SQL

CREATE DATABASE ImportedDB WITH BACKUP_STORAGE_REDUNDANCY = 'ZONE';

  1. Import the database using SSMS or SQLPackage

Option (B)

 

You may use ARM template to create database with specific backup storage and import the database at the same time.

This can be done with ARM template by using the extension named “import”

Add the following Json to your ARM template to your database resource section and make sure you provide the values for the parameters or set the values hardcoded in the template

The needed information is:

Storage Account key to access the bacpac file

Bacpac file URL

Azure SQL Server Admin Username

Azure SQL Server Admin Password

 

 

 

 

 

"resources": [
                {
                    "type": "extensions",
                    "apiVersion": "2014-04-01",
                    "name": "Import",
                    "dependsOn": [
                        "[resourceId('Microsoft.Sql/servers/databases', parameters('ServerName'), parameters('databaseName'))]"
                    ],
                    "properties": {
                        "storageKeyType": "StorageAccessKey",
                        "storageKey": "[parameters('storageAccountKey')]",
                        "storageUri": "[parameters('bacpacUrl')]",
                        "administratorLogin": "[parameters('adminUser')]",
                        "administratorLoginPassword": "[parameters('adminPassword')]",
                        "operationMode": "Import"
                    }
                }
            ]

 

 

 

 

 

 

%3CLINGO-SUB%20id%3D%22lingo-sub-1960857%22%20slang%3D%22en-US%22%3EImport%20database%20when%20policy%20%22Azure%20SQL%20DB%20should%20avoid%20using%20GRS%20backup%22%20is%20enforced%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1960857%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3ESymptoms%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ECreating%20or%20importing%20database%20failed%20due%20to%20violation%20of%20policy%20%E2%80%9CAzure%20SQL%20DB%20should%20avoid%20using%20GRS%20backup%E2%80%9D%3C%2FP%3E%0A%3CP%3EWhen%20creating%20database%2C%20you%20should%20specify%20the%20backup%20storage%20to%20be%20used%2C%20while%20the%20default%20is%20GRS%20(Globally%20redundant%20storage)%20and%20it%20violates%20the%20policy.%3C%2FP%3E%0A%3CP%3EWhile%20importing%20database%20either%20using%20Azure%20Portal%2C%20RestAPI%2C%20SSMS%20or%20SQLPackage%20you%20cannot%20specify%20the%20backup%20storage%20as%20it%E2%80%99s%20not%20implemented%20yet.%3C%2FP%3E%0A%3CP%3EThis%20cause%20the%20import%20operation%20to%20fail%20with%20the%20following%20exception%3A%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EConfiguring%20backup%20storage%20account%20type%20to%20'Standard_RAGRS'%20failed%20during%20Database%20create%20or%20update.%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ESolution%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EYou%20can%20either%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Ecreate%20the%20database%20with%20local%20backup%20storage%20and%20then%20import%20to%20existing%20database.%3C%2FLI%3E%0A%3CLI%3EUse%20ARM%20Template%20to%20do%20both%20create%20the%20database%20with%20local%20backup%20storage%20and%20import%20the%20bacpac%20file.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EExamples%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EOption%20(A)%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3ECreate%20the%20database%20with%20Azure%20Portal%20or%20by%20using%20T-SQL%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3ECREATE%20DATABASE%20ImportedDB%20WITH%20BACKUP_STORAGE_REDUNDANCY%20%3D%20'ZONE'%3B%3C%2FP%3E%0A%3COL%20start%3D%222%22%3E%0A%3CLI%3EImport%20the%20database%20using%20SSMS%20or%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-database-support-blog%2Fusing-sqlpackage-to-import-or-export-sql-server-and-azure-sql-db%2Fba-p%2F368861%22%20target%3D%22_blank%22%3ESQLPackage%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EOption%20(B)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3EYou%20may%20use%20ARM%20template%20to%20create%20database%20with%20specific%20backup%20storage%20and%20import%20the%20database%20at%20the%20same%20time.%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3EThis%20can%20be%20done%20with%20ARM%20template%20by%20using%20the%20extension%20named%20%E2%80%9Cimport%E2%80%9D%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3EAdd%20the%20following%20Json%20to%20your%20ARM%20template%20to%20your%20database%20resource%20section%20and%20make%20sure%20you%20provide%20the%20values%20for%20the%20parameters%20or%20set%20the%20values%20hardcoded%20in%20the%20template%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3EThe%20needed%20information%20is%3A%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3EStorage%20Account%20key%20to%20access%20the%20bacpac%20file%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3EBacpac%20file%20URL%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3EAzure%20SQL%20Server%20Admin%20Username%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3EAzure%20SQL%20Server%20Admin%20Password%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-30px%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%22resources%22%3A%20%5B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22type%22%3A%20%22extensions%22%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22apiVersion%22%3A%20%222014-04-01%22%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22name%22%3A%20%22Import%22%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22dependsOn%22%3A%20%5B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22%5BresourceId('Microsoft.Sql%2Fservers%2Fdatabases'%2C%20parameters('ServerName')%2C%20parameters('databaseName'))%5D%22%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%5D%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22properties%22%3A%20%7B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22storageKeyType%22%3A%20%22StorageAccessKey%22%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%22storageKey%22%3A%20%22%5Bparameters('storageAccountKey')%5D%22%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22storageUri%22%3A%20%22%5Bparameters('bacpacUrl')%5D%22%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22administratorLogin%22%3A%20%22%5Bparameters('adminUser')%5D%22%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22administratorLoginPassword%22%3A%20%22%5Bparameters('adminPassword')%5D%22%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22operationMode%22%3A%20%22Import%22%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%5D%0A%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Version history
Last update:
‎Dec 06 2020 03:51 PM
Updated by: