2016-04-15 72 views
0

我想自動執行將許多文件從本地服務器複製到Azure資源管理器存儲帳戶的過程。我已經使用經典存儲帳戶完成了此操作,並且有許多文章可用於使用經典存儲帳戶執行此任務,但我可以找到的有關V2存儲帳戶的所有cmdlet和示例都涉及從一個Azure存儲帳戶複製到另一個帳戶。是否可以這樣做,如果是這樣,我應該使用哪個cmdlet?如何將本地文件複製到Azure存儲(V2)

+0

對於這種行爲,經典的存儲帳戶和ARM部署存儲賬戶是完全一樣的。 –

+0

根據Gaurav的下面的例子,我看到你在說什麼,但我不同意由於他指出的差異,他們完全一樣。下面是一個這樣的示例:https://azure.microsoft.com/zh-CN/documentation/articles/storage-powershell-guide-full/ 無法與V2存儲帳戶一起使用,因爲它在此過程中提前失敗。 – Focker

回答

3

就管理存儲帳戶中的數據而言(例如上載文件),對於兩個V1存儲帳戶都是相同的。區別在於如何管理這些存儲帳戶(如獲取密鑰,重新生成密鑰等)。

您想要用於上傳文件的Cmdlet爲Set-AzureStorageBlobContent。您將首先使用存儲帳戶的名稱和密鑰創建AzureStorageContext,然後使用此Cmdlet上載文件。

從cmdlet幫助:

Get-Help Set-AzureStorageBlobContent -Full 

NAME 
    Set-AzureStorageBlobContent 

SYNOPSIS 
    Upload local file to Azure Storage blob. 

SYNTAX 
    Set-AzureStorageBlobContent [-File] <String> [-Container] <String> [-Blob <String>] [-BlobType <String>] 
    [-Properties <Hashtable>] [-Metadata <Hashtable>] [-Force [<SwitchParameter>]] [-Context <AzureStorageContext>] 
    [-ServerTimeoutPerRequest <Nullable`1[Int32]>] [-ClientTimeoutPerRequest <Nullable`1[Int32]>] 
    [-ConcurrentTaskCount <Nullable`1[Int32]>] [-InformationAction <ActionPreference>] [-InformationVariable <String>] 
    [<CommonParameters>] 

,這裏是一個示例代碼段:

$ctx = New-AzureStorageContext -StorageAccountName "account-name" -StorageAccountKey "account-key" 
Set-AzureStorageBlobContent -File "file-path" -Container "container-name" -Blob "blob-name" -Context $ctx 
+0

感謝Gurav,工作。 – Focker

相關問題