【问题标题】:Azure Blob Indexer ConnectionString SharedAccessSignatureAzure Blob 索引器 ConnectionString SharedAccessSignature
【发布时间】:2016-02-18 03:49:11
【问题描述】:

我正在尝试使用 Azure 搜索 Blob 索引器的预览版。使用完整连接字符串配置索引器时,索引器成功通过(除了我的其他问题中提到的问题)。

我想要做的是限制索引器使用 SharedAccessSignature 而不是完整的 ConnectionString。

我在查询索引器状态时收到的 (status.LastResult.ErrorMessage) 消息如下:

The remote server returned an error: (403) Forbidden.

我可以使用以下示例代码重现这一点:

    static void Main(string[] args)
    {
        var SASToken = ConfigurationManager.AppSettings["SASToken"];
        var endpoint = ConfigurationManager.AppSettings["BlobEndpoint"];

        var sasToken = Encoding.UTF8.GetString(Convert.FromBase64String(SASToken));
        var conn = $"BlobEndpoint={endpoint};SharedAccessSignature={sasToken};";
        var csa = CloudStorageAccount.Parse(conn);
        var blobClient = csa.CreateCloudBlobClient();
        var container = blobClient.GetContainerReference("main");

        // This throws an Error, 403 forbidden, as the SAS may not access the Container
        // none theless the indexer can still list blobs ...
        var exists = container.Exists();

        // ... as used here..
        var blobs = container.ListBlobs("documentArchive", true).ToList();
        foreach(var blob in blobs.OfType<CloudBlockBlob>())
        {
            var ms = new MemoryStream();
            blob.DownloadToStreamAsync(ms).Wait();
            var data = ms.ToArray();
            Console.WriteLine(blob.StorageUri);
        }
    }

我的假设是 Azure 搜索索引器检查容器是否存在,获取异常然后停止。我认为这种限制是不必要且令人困惑的,因为仍然可以正确枚举和索引 blob。

【问题讨论】:

  • 如何创建共享访问签名?
  • 另外,您可以分享您在共享访问签名中包含的权限吗?
  • @GauravMantri 我明天会检查,但我认为它具有容器级别的所有权限(rwdl、读取、写入、删除、列表),明天早上会确认。同时,我认为 Eugene Shvets 确切地知道为什么这不起作用;)无论如何,谢谢!
  • 嗨,我检查了 sp 字段有 rwdl,所以所有权限都可以修改容器中的 blob。

标签: azure azure-cognitive-search


【解决方案1】:

目前不支持使用 SAS URI 作为 blob 数据源凭据。这是我们的雷达,请投票给this UserVoice suggestion,以帮助我们优先考虑这项工作。谢谢!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-09
    • 2015-05-21
    • 2017-04-18
    • 1970-01-01
    • 2017-09-22
    • 2020-03-03
    • 1970-01-01
    • 2018-04-30
    相关资源
    最近更新 更多