Azure file SMB3.0 files sharing Service (2)

Source: Internet
Author: User
Tags hdinsight

Create a file share using PowerShell

The file storage structure of Azure is as follows, the most basic file storage contains the storage account, file sharing, under the file share you can create a file directory, upload files:

650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/845013/201605/845013-20160511110910484-234548762. PNG "style=" border:0px; "/>

Before you start using PowerShell to create a file share, you need to get an Azure account, install PowerShell, and configure your account, please refer to my previous blog, and don't repeat it here.

  1. First, to create an Azure storage account, you need to set the name of your storage, and your storage account is created in that region, such as eastern China:

    $StorageAccountName =" Mystorageacctfile "

    $Location = "China East"

    new-azurestorageaccount– Storageaccountname $StorageAccountName-location $Location

     

    650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/845013/201605/ 845013-20160511110912093-760846771.png "style=" border:0px; "/>

     

  2. Get your current storage account key by command, set your current subscription, and the current subscription's storage account:

    #得到存储的key值

    Get-azurestoragekey-storageaccountname $StorageAccountName

    #设置当前订阅的默认存储

    Set-azuresubscription-currentstorageaccountname $StorageAccountName-subscriptionid $SubscriptionID

  3. Create a file store for Azure file via PowerShell

    #获得Azure存储的上下文

    $ctx =new-azurestoragecontext $StorageAccountName $StorageAccountKey

    #创建Azure File Sharing Service

    $share = New-azurestorageshare $filesharename-context $ctx

    #列出当前Azure文件共享服务

    Get-azurestorageshare-context $ctx-name $filesharename

    650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/845013/201605/845013-20160511110913702-79872954. PNG "style=" border:0px; "/>

    650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/845013/201605/845013-20160511110915140-1662595912. PNG "style=" border:0px; "/>

  4. Log in to Azure portal and you can see the configured storage account and file services:

    650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/845013/201605/845013-20160511110916515-1734284368. PNG "style=" border:0px; "/>

  5. If you want your file service to implement cross-region redundancy, you can configure the configuration item:

    650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/845013/201605/845013-20160511110917530-1941186477. PNG "style=" border:0px; "/>

  6. So far the file sharing service has been created, so we use PowerShell to use the file sharing service, including creating directories, uploading a file, listing files:

    #创建文件共享目录

    New-azurestoragedirectory-share $share-path Logs

    #上传一个文件到文件共享目录

    Set-azurestoragefilecontent-share $share-source D:\hdinsight.publishsettings-Path logs

    # list all files in directory

    Get-azurestoragefile-share $share-path Logs | Get-azurestoragefile

    # List all your files

    Get-azurestoragefile-share $share-path Logs | Get-azurestoragefile

    650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/845013/201605/845013-20160511110918937-1759927941. PNG "style=" border:0px; "/>

    650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/845013/201605/845013-20160511110921171-1377759530. PNG "style=" border:0px; "/>

  7. Like other stores, you can use PowerShell to copy between file and file, file and blob:

    Start-azurestoragefilecopy-srcsharename $filesharename-srcfilepath "Logs/hdinsight.publishsettings"- Destsharename $filesharenamenew-destfilepath "logs/hdinsight.publishsettings"-context $ctx-destcontext $ctx

    All relevant test scripts have been updated to GitHub and you can download the source code test:

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


Azure file SMB3.0 files sharing Service (2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.