【问题标题】:Azure CloudDrive HTTPS UriAzure CloudDrive HTTPS Uri
【发布时间】:2012-09-20 22:12:10
【问题描述】:

来自this MSDN article 表示用于连接存储帐户的连接字符串必须是HTTP 而不是HTTPS

当我使用这个构造函数时:

public CloudDrive (
    Uri uri,
    StorageCredentials credentials
)

这是否意味着页面 blob 的 Uri 也必须是 HTTP 而不是 HTTPS?对于哪个参数(或两者一起)适合“连接字符串”描述,我有点困惑。

这个场景在开发模拟器中似乎不容易测试。

【问题讨论】:

    标签: azure azure-storage azure-blob-storage azure-clouddrive


    【解决方案1】:

    页面 blob 的URI认为是连接字符串的服务器部分)表示存储帐户的命名空间 + 容器 + blobcredentials 代表用户/密码,与 URI 一起构成 Azure 云存储服务的连接字符串。

    假设您使用的是本地模拟器,URI 将始终是 HTTP。

    CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
    

    部署到 Azure 时,URI 方案将为 whatever you assign it in the service configurationServiceDefinition.csdef / ServiceConfiguration.Cloud.cscfg)。

    CloudStorageAccount storageAccount = CloudStorageAccount.FromConfigurationSetting("CloudDrive.DataConnectionString");
    

    您只想将CloudDrive.DataConnectionString 分配给DefaultEndpointsProtocol=http如果省略,则为默认值,但您可以明确)。

    ServiceDefinition.csdef

    <ServiceDefinition>
      <WebRole>
        <!-- .... -->
        <ConfigurationSettings>
          <Setting name="CloudDrive.DataConnectionString" />
        </ConfigurationSettings>
      </WebRole>
    </ServiceDefinition>
    

    ServiceConfiguration.Cloud.cscfg

    <ServiceConfiguration>
      <Role>
        <ConfigurationSettings>
         <Setting name="CloudDrive.DataConnectionString" value="DefaultEndpointsProtocol=http;AccountName=YOURNAMESPACE;AccountKey=YOURKEY" />
        </ConfigurationSettings>
      </Role>
    </ServiceConfiguration>
    

    【讨论】:

    • 我所有的连接字符串都必须是 Https,所以使用该构造函数的正确方法似乎是确保 uri 部分是 http:CloudStorageAccount httpsAccount = ...;var blobUri = httpsAccount.GetContainerReference("mycontainer").GetPageBlobReference("myblob").Uri;var httpBlobUri = new UriBuilder(blobUri){Scheme ="http", Port = 80}.Uri;CloudDrive cloudDrive = new CloudDrive(httpBlobUri, httpsAccount.Credentials);跨度>
    • 为什么需要将连接字符串全部定义为 HTTPS?您可以定义多个连接字符串 - 只需使用非 HTTPS 连接字符串进行CloudDrive 交互。支持 HTTPS 时 - 您无需构建/重新发布,只需更改运行配置即可。
    • 不幸的是,这部分超出了我的控制范围,我只是在假设接收到 https 连接字符串的情况下工作。我将尝试我之前的评论,将 uri 重建为 http 而不是 https。
    猜你喜欢
    • 2011-03-12
    • 2010-10-30
    • 1970-01-01
    • 1970-01-01
    • 2019-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多