Azure 文件存储分为Files和Blob,上传方法也很相似,以下是上传至Blob的方法。
$destinationFolder = ""
$storageShareName = ""
$StorageAccountName = ""
$StorageAccountKey = ""
$ctx = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey -Protocol Https
$directory = Get-AzureStorageContainer -Context $ctx | Where-Object {$_.Name -eq $storageShareName}
if(!$directory){
Write-TestSuiteInfo "Create share folder : $storageShareName"
New-AzureStorageContainer -Name $storageShareName -Permission Off -Context $ctx
}
$directory = Get-AzureStorageContainer -Context $ctx | Where-Object {$_.Name -eq "$storageShareName\$testsuiteFolde"}
if(!$directory){
Write-TestSuiteInfo "Create share folder : $storageShareName\$testsuiteFolde"
New-AzureStorageContainer -Name "$storageShareName\$testsuiteFolde" -Permission Off -Context $ctx
}
#upload file to Azure
Get-ChildItem -Path “D:\TestAzureBlob” -File -Recurse | Set-AzureStorageBlobContent -Container "$storageShareName\$destinationFolder " -Context $ctx
网友评论