【问题标题】:Azure Storage connection string How to implement to applicateAzure存储连接字符串如何实现应用
【发布时间】:2019-06-20 11:02:51
【问题描述】:

我需要从应用程序创建对 Azure 存储的访问权限。应用程序需要存储,将文件放在哪里。下面的这段代码,我试图把应用程序需要路径来存储文件。我做得对吗?如何将它实现到应用程序的 XML 中,然后它开始将文件写入云存储。

<connectionStrings>
    <add name= "DefaultConnection" connectionString="DefaultEndpointsProtocol=https;AccountName=;AccountKey=;/>
</connectionStrings>

【问题讨论】:

  • 您正在开发什么样的应用程序?这是一个 Web 应用程序吗?正如您提到的,您可以将其放在web.config / App.config 上用于普通应用

标签: azure azure-devops azure-storage


【解决方案1】:

例如,请看一下这个doc

在您的 app.config 中,请添加:

<appSettings>
        <add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=account-name;AccountKey=account-key" />
</appSettings>

在您的代码中,请使用:

// Parse the connection string and return a reference to the storage account.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
    CloudConfigurationManager.GetSetting("StorageConnectionString"));

然后你就可以使用天蓝色存储了。

【讨论】:

    【解决方案2】:

    如果您登录到 Azure 上的 Blob 图像存储。它应该默认填充连接字符串。 PFB参考

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-24
      • 2015-12-02
      • 1970-01-01
      • 2018-12-20
      • 2019-12-28
      • 2018-11-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多