美文网首页
上传文件到Azure

上传文件到Azure

作者: Grom_Li | 来源:发表于2019-06-17 10:24 被阅读0次

    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
    

    相关文章

      网友评论

          本文标题:上传文件到Azure

          本文链接:https://www.haomeiwen.com/subject/qwvofctx.html