AzureFile服務(wù)(2):使用Powershell開發(fā)管理

使用Powershell創(chuàng)建文件共享

 

創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供沙市網(wǎng)站建設(shè)、沙市做網(wǎng)站、沙市網(wǎng)站設(shè)計、沙市網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計與制作、沙市企業(yè)網(wǎng)站模板建站服務(wù),10多年沙市做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。

Azure的文件存儲結(jié)構(gòu)如下所示,最基本的文件存儲包含存儲賬號,文件共享,在文件共享下面你可以建立文件目錄,上傳文件:

Azure File 服務(wù)(2):使用Powershell開發(fā)管理

在開始使用Powershell創(chuàng)建文件共享之前,你需要獲得Azure的賬號,安裝powershell,配置你的賬號,請參考我以前的博客,在此不再贅述。

  1. 首先,創(chuàng)建Azure storage account,需要設(shè)置你的storage賬號的名稱,以及你的存儲賬號是創(chuàng)建在那個region,比如中國東部:

    $StorageAccountName="mystorageacctfile"

    $Location="China East"

    New-AzureStorageAccount –StorageAccountName $StorageAccountName -Location $Location

     

    Azure File 服務(wù)(2):使用Powershell開發(fā)管理

     

  2. 通過命令得到你的當(dāng)前存儲賬號的key,設(shè)置你的當(dāng)前訂閱,和當(dāng)前訂閱的存儲賬號:

    #得到存儲的key值

    Get-AzureStorageKey -StorageAccountName $StorageAccountName

    #設(shè)置當(dāng)前訂閱的默認存儲

    Set-AzureSubscription -CurrentStorageAccountName $StorageAccountName -SubscriptionId $SubscriptionID

     

  3. 通過Powershell來創(chuàng)建Azure file 的文件存儲

    #獲得Azure存儲的上下文

    $ctx=New-AzureStorageContext $StorageAccountName $StorageAccountKey

     

    #創(chuàng)建Azure file共享服務(wù)

    $share = New-AzureStorageShare $filesharename -Context $ctx

     

    #列出當(dāng)前Azure文件共享服務(wù)

    Get-AzureStorageShare -Context $ctx -Name $filesharename

     

    Azure File 服務(wù)(2):使用Powershell開發(fā)管理

    Azure File 服務(wù)(2):使用Powershell開發(fā)管理

     

  4. 登陸到Azure的portal上,你可以看到已經(jīng)配置好的存儲賬號和文件服務(wù):

    Azure File 服務(wù)(2):使用Powershell開發(fā)管理

  5. 如果你希望你的文件服務(wù)實現(xiàn)跨地區(qū)的冗余,你可以在配置項進行配置:

     

    Azure File 服務(wù)(2):使用Powershell開發(fā)管理

  6. 到目前為止文件共享服務(wù)已經(jīng)創(chuàng)建完畢了,那么我們使用Powershell來使用文件共享服務(wù),包括創(chuàng)建目錄,上傳一個文件,列出文件:

    #創(chuàng)建文件共享目錄

    New-AzureStorageDirectory -Share $share -Path logs

     

    #上傳一個文件到文件共享目錄

    Set-AzureStorageFileContent -Share $share -Source d:\hdinsight.publishsettings -Path logs

     

    # 列出目錄下的所有文件

    Get-AzureStorageFile -Share $share -Path logs | Get-AzureStorageFile

     

    # List all your files

    Get-AzureStorageFile -Share $share -Path logs | Get-AzureStorageFile

    Azure File 服務(wù)(2):使用Powershell開發(fā)管理

     

    Azure File 服務(wù)(2):使用Powershell開發(fā)管理

     

  7. 和其他存儲類似,你可以使用powershell在File和File之間,F(xiàn)ile和Blob之間進行拷貝:

    Start-AzureStorageFileCopy -SrcShareName $filesharename -SrcFilePath "logs/hdinsight.publishsettings" -DestShareName $filesharenamenew -DestFilePath "logs/hdinsight.publishsettings" -Context $ctx -DestContext $ctx

     

    所有相關(guān)測試腳本已經(jīng)更新到了github,你可以下載源代碼測試:

    https://github.com/kingliantop/azurelabs/blob/master/storage/StorageFileShare.ps1

網(wǎng)頁題目:AzureFile服務(wù)(2):使用Powershell開發(fā)管理
文章地址:http://bm7419.com/article28/pcipjp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化、企業(yè)建站面包屑導(dǎo)航、做網(wǎng)站微信公眾號、服務(wù)器托管

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運營