zoukankan      html  css  js  c++  java
  • Azure File SMB3.0文件共享服务(2)

    使用Powershell创建文件共享

    Azure的文件存储结构如下所示,最基本的文件存储包含存储账号,文件共享,在文件共享下面你可以建立文件目录,上传文件:

    在开始使用Powershell创建文件共享之前,你需要获得Azure的账号,安装powershell,配置你的账号,请参考我以前的博客,在此不再赘述。

    1. 首先,创建Azure storage account,需要设置你的storage账号的名称,以及你的存储账号是创建在那个region,比如中国东部:

      $StorageAccountName="mystorageacctfile"

      $Location="China East"

      New-AzureStorageAccount –StorageAccountName $StorageAccountName -Location $Location

    2. 通过命令得到你的当前存储账号的key,设置你的当前订阅,和当前订阅的存储账号:

      #得到存储的key值

      Get-AzureStorageKey -StorageAccountName $StorageAccountName

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

      Set-AzureSubscription -CurrentStorageAccountName $StorageAccountName -SubscriptionId $SubscriptionID

    3. 通过Powershell来创建Azure file 的文件存储

      #获得Azure存储的上下文

      $ctx=New-AzureStorageContext $StorageAccountName $StorageAccountKey

      #创建Azure file共享服务

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

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

      Get-AzureStorageShare -Context $ctx -Name $filesharename

    4. 登陆到Azure的portal上,你可以看到已经配置好的存储账号和文件服务:

    5. 如果你希望你的文件服务实现跨地区的冗余,你可以在配置项进行配置:

    6. 到目前为止文件共享服务已经创建完毕了,那么我们使用Powershell来使用文件共享服务,包括创建目录,上传一个文件,列出文件:

      #创建文件共享目录

      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

    7. 和其他存储类似,你可以使用Powershell在File和File之间,File和Blob之间进行拷贝:

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

      所有相关测试脚本已经更新到了github,你可以下载源代码测试:

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

  • 相关阅读:
    js 数据格式化
    js 获取URL中参数
    微信公众平台JSSDK开发
    js 日期格式化及日期增减
    一句话的设计模式
    微信小程序开源项目库汇总
    bash 配置文件
    centos 设置时间为北京时间
    数据库一般数据的查询操作
    linux tmux 工具使用 tmux.conf 文件
  • 原文地址:https://www.cnblogs.com/cloudapps/p/5481185.html
Copyright © 2011-2022 走看看