2016-03-28 29 views
0

SQL Azureデータベースのblobへのエクスポートを開始しようとしています。しかし、異なるアプローチを試してWebを検索した後、私はそれを動作させる方法を見つけることができません。Start-AzureSqlDatabaseExport:オブジェクト参照がオブジェクトのインスタンスに設定されていません

$exportRequest = Start-AzureSqlDatabaseExport -SqlConnectionContext $SqlContext -StorageContainer $Container -DatabaseName 'Users' -BlobName 'autobackupotest.bacpac' -Verbose -Debug 

で結果上記の行:

DEBUG: 2:05:14 PM - StartAzureSqlDatabaseExport begin processing with ParameterSet 'ByContainerObject'. 
WARNING: Client Session Id: '111746f6-65c2-4ba1-b7c6-52a9171ee6-2016-03-28 08:15:58Z' 
WARNING: Client Request Id: 'f20b3326-a6c4-48d7-beb0-6ce7b17585-2016-03-28 11:05:14Z' 
Start-AzureSqlDatabaseExport : Object reference not set to an instance of an object. 
At C:\tests\thirdversion.ps1:29 char:22 
+  $exportRequest = Start-AzureSqlDatabaseExport -SqlConnectionContext $SqlCont ... 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : NotSpecified: (:) [Start-AzureSqlDatabaseExport], NullReferenceException 
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.SqlDatabase.Database.Cmdlet.StartAzureSqlDatabaseExport 

DEBUG: 2:05:19 PM - StartAzureSqlDatabaseExport end processing. 

は、私は、このコマンドレットに使用する変数を検証し、それがnullではありません。このコマンドレットの前に、私は次のコードを使用します:

Import-Module Azure 
Import-Module Azure.Storage 

Get-AzureRmSubscription –SubscriptionName “Production” | Select-AzureRmSubscription 

# Username for Azure SQL Database server 
$ServerLogin = "username" 

# Password for Azure SQL Database server 
$serverPassword = ConvertTo-SecureString "abcd" -AsPlainText -Force 


# Establish credentials for Azure SQL Database Server 
$ServerCredential = new-object System.Management.Automation.PSCredential($ServerLogin, $serverPassword) 

# Create connection context for Azure SQL Database server 
$SqlContext = New-AzureSqlDatabaseServerContext -FullyQualifiedServerName “myspecialsqlserver.database.windows.net” -Credential $ServerCredential 

$StorageContext = New-AzureStorageContext -StorageAccountName 'prodwad' -StorageAccountKey 'xxxxx' 
$Container = Get-AzureStorageContainer -Name 'automateddbbackups' -Context $StorageContext 

$exportRequest = Start-AzureSqlDatabaseExport -SqlConnectionContext $SqlContext -StorageContainer $Container -DatabaseName 'Users' -BlobName 'autobackupotest.bacpac' -Verbose -Debug 

ここで間違っていますか?その例外メッセージは詳細を提供しません。

答えて

2

私はあなたのコードをテストし、それは私の側で正常に動作します。 Get-AzureRmSubscription –SubscriptionName “Production” | Select-AzureRmSubscription前にログインする

実行Login-AzureRmAccount、サブスクリプション生産は、現在のテナントに存在することを確認します。また、ユーザー名、SQLサーバーのパスワード、StorageAccount、StorageAccountKey、ContainerNameがすべて正しいことを確認してください。

関連する問題