gpt4 book ai didi

powershell - Azure Powershell 将 azure 存储帐户复制到另一个 azure 存储帐户

转载 作者:行者123 更新时间:2023-12-03 01:51:24 29 4
gpt4 key购买 nike

我正在尝试使用自动化 powershell 脚本将所有容器和文件从一个帐户复制到另一个帐户。该脚本运行良好,但我在目标处没有看到任何输出和文件。

如何更正此脚本,以便它将一个 Azure 存储帐户上的所有容器和文件复制到另一个存储帐户上,并根据需要创建容器?

#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

}

第一个错误是这样的:

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 :

存储异常,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.NewAzureStorageContainerCommand

最佳答案

解决方案是确保您拥有正确的存储帐户 key 和存储帐户。愚蠢的错误。

关于powershell - Azure Powershell 将 azure 存储帐户复制到另一个 azure 存储帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36555346/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com