Azure Export SQL sample database

Given that Microsoft is devaluing the previous SQL DB export method, they suggested an example here :

$subscriptionId = "YOUR AZURE SUBSCRIPTION ID" Login-AzureRmAccount Set-AzureRmContext -SubscriptionId $subscriptionId # Database to export $DatabaseName = "DATABASE-NAME" $ResourceGroupName = "RESOURCE-GROUP-NAME" $ServerName = "SERVER-NAME" $serverAdmin = "ADMIN-NAME" $serverPassword = "ADMIN-PASSWORD" $securePassword = ConvertTo-SecureString -String $serverPassword -AsPlainText -Force $creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $serverAdmin, $securePassword # Generate a unique filename for the BACPAC $bacpacFilename = $DatabaseName + (Get-Date).ToString("yyyyMMddHHmm") + ".bacpac" # Storage account info for the BACPAC $BaseStorageUri = "https://STORAGE-NAME.blob.core.windows.net/BLOB-CONTAINER-NAME/" $BacpacUri = $BaseStorageUri + $bacpacFilename $StorageKeytype = "StorageAccessKey" $StorageKey = "YOUR STORAGE KEY" $exportRequest = New-AzureRmSqlDatabaseExport -ResourceGroupName $ResourceGroupName -ServerName $ServerName ` -DatabaseName $DatabaseName -StorageKeytype $StorageKeytype -StorageKey $StorageKey -StorageUri $BacpacUri ` -AdministratorLogin $creds.UserName -AdministratorLoginPassword $creds.Password $exportRequest # Check status of the export Get-AzureRmSqlDatabaseImportExportStatus -OperationStatusLink $exportRequest.OperationStatusLink 

I filled in all the credentials, as suggested in their example, and I get this error:

 New-AzureRmSqlDatabaseExport : NotFound: Entity not found to invoke export At C:\Users\bob\Desktop\DBBackupScript.ps1:47 char:18 + ... rtRequest = New-AzureRmSqlDatabaseExport -ResourceGroupName $Resource ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [New-AzureRmSqlDatabaseExport], CloudException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Sql.ImportExport.Cmdlet.NewAzureSqlDatabaseExport 

Does anyone know what I'm doing wrong?

+5
source share
3 answers

The PowerShell script example in your previous question is tested as expected for me.

However, I cannot reproduce the same error message as your attempts to even use a nonexistent resource group, database server, or database.

Important Note:

  • For $serverAdmin and $serverPassword their values ​​must be single, not double quotes, for the script to work
  • Check your AzureRm.Sql module AzureRm.Sql . Work with mine verification 2.5.0
  • Try using -Debug for the New-AzureRmSqlDatabaseExport command line to see the details.
+1
source
+2
source

It looks like the database name is case sensitive when using az sql db export. Fixing a shell in the database and resource group solved this problem in my case.

+2
source

Source: https://habr.com/ru/post/1263685/


All Articles