Azure导出SQL数据库示例 [英] Azure Export SQL database example

查看:105
本文介绍了Azure导出SQL数据库示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于Microsoft已弃用导出SQL DB的先前方法,因此他们提出了建议的示例

Given Microsoft is deprecating the previous method of exporting a SQL DB they have put up a suggested 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 have filled in all the credentials as suggested in their example and I am getting 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 have any idea what I am doing wrong?

推荐答案

上面问题中的PowerShell脚本示例已经过测试,符合我的预期.

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

但是,即使尝试使用不存在的资源组,数据库服务器或数据库,我也无法重现与您相同的错误消息.

However, I am not able to reproduce the same error message as yours even try to use non-existent resource group, database server or database.

重要提示:

  1. 对于$serverAdmin$serverPassword,它们的值应该用单引号而不是双引号使脚本起作用
  2. 检查您的AzureRm.Sql模块的版本.经过矿山测试的工作是 2.5.0
  3. 尝试在New-AzureRmSqlDatabaseExport命令行中使用 -Debug 来查看详细信息
  1. For $serverAdmin and $serverPassword, their values should be single-quoted instead of double-quoted for the script to work
  2. Check the version of your AzureRm.Sql module. Mine tested working is 2.5.0
  3. Try to use -Debug for your New-AzureRmSqlDatabaseExport command line to see the details

这篇关于Azure导出SQL数据库示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆