【问题标题】:Display Blobs/Photos stored in Azure-storage in Xamarin Mobile Application在 Xamarin 移动应用程序中显示存储在 Azure 存储中的 Blob/照片
【发布时间】:2019-10-15 15:13:33
【问题描述】:

尝试开发一个 Xamarin Forms 移动应用程序,该应用程序通过 api 显示存储在 Azure-Storage 容器中的 blob。

当前流程是这样的 API > Azure-Storage Blob > 在 Xamarin 移动应用程序中显示。

使用存储帐户密钥连接到 Azure 存储。

问题是,当容器上的公共访问设置设置为“私有”时,Blob 不会显示在移动应用程序中。 如果容器公共访问设置设置为“blob”,则照片将显示在 xamarin 移动应用中。

照片用于说明目的。Photo of issue

代码如下。

string storageConnectionString 
Environment.GetEnvironmentVariable("storageconnectionstring");

CloudStorageAccount storageAccount;
if (CloudStorageAccount.TryParse(storageConnectionString, out 
storageAccount))
{
// If the connection string is valid, proceed with operations against 
Blob storage here.
...
}
else
{
//Error
}
[enter image description here][1]CloudBlobClient cloudBlobClient = storageAccount.CreateCloudBlobClient();

如何在移动应用程序中显示 blob 的同时将容器设为私有?

【问题讨论】:

  • 您似乎遗漏了很多有关如何访问 blob 数据和显示图像的相关代码。如果我们看不到您在做什么,我们就无法告诉您出了什么问题

标签: c# azure xamarin.forms azure-blob-storage azure-web-app-service


【解决方案1】:

我认为您可能使用了错误类型的 Azure blob 存储连接。

您需要使用共享密钥。

shared key authentication with azure blob storage

您需要生成一个新的共享访问签名。

create a new SAS

我希望这会为您指明正确的方向。

【讨论】:

    【解决方案2】:

    非常感谢@justjoshin 的帮助。

    SAS 就是答案。从那里您可以生成一个 SAS 令牌,即使容器是私有的,您也可以将其附加在 blob url 之后以显示它。

    希望这对其他人有帮助。

    最好的

    【讨论】:

      猜你喜欢
      • 2020-06-22
      • 2014-01-13
      • 2021-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-30
      • 1970-01-01
      • 2019-05-15
      相关资源
      最近更新 更多