0

I am looking for an alternative to :

New-AzureRmSqlDatabaseExport

For the purpose of taking Managed Instance Database backup and export it to storage account. The above command, I think supports only SQL Server.

Alberto Morillo
  • 13,893
  • 2
  • 24
  • 30
NaMo
  • 513
  • 1
  • 6
  • 19
  • You seem to be using azure managed database, what is the reason you look for alternative ? I think this is what you're looking for: https://stackoverflow.com/questions/41983010/azure-export-sql-database-example – Orel Eraki Feb 21 '20 at 10:40
  • this throws error that resource not found ```"Microsoft.sql/managedinstances/"``` since this command expects ```"Microsoft.sql/servers/"``` – NaMo Feb 21 '20 at 11:25
  • @NaMo If my answer is helpful for you, you can mark and vote up it as answer. This can be beneficial to other community members. Thank you. – Leon Yue Feb 25 '20 at 06:47

1 Answers1

1

Yes, your're right, Powershell command doesn't support export the Azure SQL managed instance for now, you could reference this document:Export to a BACPAC file using PowerShell:

enter image description here

Besides, the document also gives the other ways:

Exporting a BACPAC of a database from a managed instance using Azure PowerShell is not currently supported. Use SQL Server Management Studio or SQLPackage instead.

  1. Export to a BACPAC file using the SQLPackage utility
  2. Export to a BACPAC file using SQL Server Management Studio (SSMS)

At least, you also can use T-SQL to backup the Azure SQL manage instance to Blob Storage:

First, you would need to store credentials that would be used to access Azure Blob Storage:

CREATE CREDENTIAL [https://myacc.blob.core.windows.net/testcontainer] 
WITH IDENTITY='SHARED ACCESS SIGNATURE' 
, SECRET = 'sv=2014-02-14&sr=c&sig=GV0T9y%2B9%2F9%2FLEIipmuVee3jvYj4WpvBblo%3D&se=2019-06-01T00%2A%3AZ&sp=rwdl';

Once you create a credential, you can backup any database using standard BACKUP T-SQL command:

BACKUP DATABASE tpcc2501 
TO URL = 'https://myacc.blob.core.windows.net/testcontainer/tpcc2501.bak' 
WITH COPY_ONLY 

Reference this Azure blog: Native database backup in Azure SQL Managed Instance.

Hope this helps.

Leon Yue
  • 15,693
  • 1
  • 11
  • 23