为什么 azure 的 CloudBlockBlob.Uri.AbsoluteUri 返回 HTTPS: 作为 blobls url?
var account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
// create container
Storage = account.CreateCloudBlobClient();
Container = Storage.GetContainerReference("container");
Container.CreateIfNotExist();
// configure for public access
var permissions = Container.GetPermissions();
permissions.PublicAccess = BlobContainerPublicAccessType.Container;
Container.SetPermissions(permissions);
...
CloudBlockBlob blob = Storage.GetBlockBlobReference(blobname);
blob.UploadFromStream(file.InputStream);
url = blob.Uri.AbsoluteUri;
//url returns: https://myazureacct.blob.core.windows.net/...
我可以使用 http://myazureacct 访问资源....但为什么 AbsoluteUri 返回 https?
var account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
// create container
Storage = account.CreateCloudBlobClient();
Container = Storage.GetContainerReference("container");
Container.CreateIfNotExist();
// configure for public access
var permissions = Container.GetPermissions();
permissions.PublicAccess = BlobContainerPublicAccessType.Container;
Container.SetPermissions(permissions);
...
CloudBlockBlob blob = Storage.GetBlockBlobReference(blobname);
blob.UploadFromStream(file.InputStream);
url = blob.Uri.AbsoluteUri;
//url returns: https://myazureacct.blob.core.windows.net/...
I can access the resource with http://myazureacct.... but why is AbsoluteUri returning https?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Uri 是由库使用底层连接字符串/客户端创建的 - 我猜测您的“DataConnectionString”包含“UseHttps=true” - 因此库正在使用(和生成)的 url 是 HTTPs。
在比这稍深一点的层面上,您可以使用 http 或 https 访问 blob 存储服务 - 就像您也可以访问表和队列存储一样。如果您在单个 Azure 数据中心内工作,或者如果您正在处理非敏感数据,那么您可以自由使用 http - 否则为了安全起见,请首选 https。
The Uri is created by the library using the underlying connection string/client - and I'm guessing that your "DataConnectionString" contains "UseHttps=true" - hence why the url's the library is using (and producing) are HTTPs.
At a slightly deeper level than that, you can access the blob storage service using http or https - just as you can access table and queue storage too. If you're working within a single Azure data center, or if you are working with non-sensitive data, then you are free to use http - otherwise https is preferred for your security.