2016-04-11 16 views
1

Tüm kapsayıcıları ve dosyaları bir hesaptan diğerine otomasyon powershell komut dosyasını kullanarak kopyalamaya çalışıyorum. Komut dosyası düzgün çalışıyor, ancak hedefte çıktı ve dosya göremiyorum.Azure Powershell, maskeleme depolama hesabını başka bir masmavi depolama hesabına kopyalamak için

Bu komut dosyasını, tüm kapsayıcıları ve dosyaları bir masmavi depolama hesabına başka bir depolama hesabına kopyalayarak kapsayıcıları gerektiği gibi oluşturacak şekilde nasıl düzeltebilirim?

#Define the source storage account and context. 
$SourceStorageAccountName = "importantthings" 
$SourceStorageAccountKey = "[mysourcekeyhere]" 
$SourceContext = New-AzureStorageContext -StorageAccountName  
$SourceStorageAccountName -StorageAccountKey $SourceStorageAccountKey 

#Define the destination storage account and context. 
$DestStorageAccountName = "dailybackup" 
$DestStorageAccountKey = "[mydestkeyhere]" 
$DestContext = New-AzureStorageContext -StorageAccountName $DestStorageAccountName -StorageAccountKey $DestStorageAccountKey 
$Containers = Get-AzureStorageContainer -Prefix group -Context $SourceContext 
foreach ($Container in $Containers) { 
     $DestContainer = New-AzureStorageContainer -Name $Container.Name -Context $DestContext -Force #-Permission Off 
     #Get a reference to blobs in the source container. 
     $blob = Get-AzureStorageBlob -Container $Container.Name -Context $SourceContext | Start-CopyAzureStorageBlob -destcontainer $DestContainer.Name #–destblob $blob.name #-srccontainer $Container.Name 
     $blob | Get-AzureStorageBlobCopyState –WaitForComplete 

} 

ilk hata şudur:

New-AzureStorageContainer : The remote server returned an error: (403) Forbidden. HTTP Status Code: 403 - HTTP Error 
Message: Server failed to authenticate the request. Make sure the value of  Authorization header is formed correctly 
including the signature. 
At line:19 char:21 
+ ... Container = New-AzureStorageContainer -Name $Container.Name -Context ... 
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
+ CategoryInfo   : CloseError: (:) [New-AzureStorageContainer], StorageException 
+ FullyQualifiedErrorId : 

StorageException, Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.NewAzureStorageContainerCommand

+0

Tahminimce bazı istisnalar alıyorsunuz ancak kodunuzdaki istisnaları yiyorsunuz. İstisnaları yakalamayı ve bunları kodunuzun yakalama bloğunda çıkarmayı deneyebilir misiniz? –

+0

https://blogs.msdn.microsoft.com/kebab/2013/06/09/an-introduction-to-error-handling-in-powershell/ –

+1

Onun kodunda herhangi bir istisna "yeme" görmüyorum . Lütfen hesap anahtarınızın doğru olduğunu doğrulayın. Ayrıca bilgisayar saatinizin doğru olduğunu kontrol edin! –

cevap

1

Çözüm sağ depolama hesap anahtara sahip sağlamaktır depolama hesabı ile. Aptal bir hata.

İlgili konular