【问题标题】:Connection to Azure Storage Analytics via C#通过 C# 连接到 Azure 存储分析
【发布时间】:2013-08-29 15:33:26
【问题描述】:

我使用http://msdn.microsoft.com/en-us/library/windowsazure/hh343262.aspx 作为参考。

那个页面说

"The $logs container is located in the blob namespace of the storage account, 
for example: http://<accountname>.blob.core.windows.net/$logs"

上面还说

"you can use the ListBlobs method to access the blobs in the $logs container."

现在在这个页面http://msdn.microsoft.com/en-us/library/windowsazure/ee772878.aspx 上给出了一个例子:

CloudBlobClient blobClient = 
    new CloudBlobClient(blobEndpoint, 
                        new StorageCredentialsAccountAndKey("accountName", "key"));

CloudBlobContainer container = blobClient.GetContainerReference("myblobs");

问题:如果 blob 存储在 http://accountname.blob.core.windows.net/$logs,那么我该如何设置 blobEndPoint?

我应该把什么作为 GetContainerReference("") ?我不知道容器的名称,我是 Azure 的新手。

谢谢, 安德鲁

【问题讨论】:

    标签: c# azure azure-storage


    【解决方案1】:

    我应该把什么作为 GetContainerReference("") ?

    你可以把$logs放在那里。所以你的代码是:

    CloudBlobContainer container = blobClient.GetContainerReference("$logs");
    

    以下屏幕截图显示了 blob 如何存储在 $logs 目录中

    本质上是$logs / [blob|queue|table] / YYYY / MM / DD / HH00 / blob file。 Blob 文件是从000000 开始的6 characters length 的顺序文件。由于您不知道 blob 的名称,我建议您先执行List Blobs 操作以获取所有 blob。要限制 blob 的数量,您也可以执行基于 prefix 的搜索。例如,假设您要查找 blobs2013-08-15 的所有日志条目,您需要在列出 blob 时将 blob/2013/08/15 作为 blob 前缀传递。

    更新:

    但是,请注意默认情况下不启用存储分析。您需要先启用它。我在下面粘贴的屏幕截图来自 Cerebrata (http://www.cerebrata.com) 的 Azure Management Studio。您可以使用该工具来启用存储分析。他们还有一个免费工具来配置分析,您可以从这里下载:http://blog.cerebrata.com/articles/2011/08/11/cerebrata-windows-azure-storage-analytics-configuration-utility-a-free-utility-to-configure-windows-azure-storage-analytics/。首先,请启用存储分析,等待该容器创建完成,然后执行您的代码。

    【讨论】:

    • 谢谢 - 我尝试了以下方法: CloudBlobContainer container = blobClient.GetContainerReference("$logs");当我尝试调用 container.ListBlobs() 时,我收到一个异常,说容器不存在。如何查看确实存在哪些容器?
    • 啊,我明白了。我认为您尚未启用存储分析。你需要先这样做。请参阅我的更新回复。 HTH。
    • 最后一件事 Gaurav - 如何根据 StartTime、EndTime、LogType 等元数据查询 blob? msdn.microsoft.com/en-us/library/windowsazure/hh343262.aspx说可以查询但不说怎么查询
    • 我查看了链接,我认为它不正确。据我所知,blob 元数据不可查询,即您无法根据元数据获取 blob。让我了解更多。
    • 这是我收到的回复:You can’t filter on a metadata value. What the below I believe is intended to mean is that when you list the blobs you can get the metadata as part of the listing. The metadata will tell you the time range of the logs in each blog. You can then use this information to decide which blobs you want to look in for a particular time frame for the given hour.HTH。
    猜你喜欢
    • 2016-02-18
    • 1970-01-01
    • 2021-07-22
    • 1970-01-01
    • 1970-01-01
    • 2020-02-29
    • 1970-01-01
    • 2023-03-12
    • 2022-08-03
    相关资源
    最近更新 更多