简体   繁体   中英

Connection to Azure Storage Analytics via C#

I am using http://msdn.microsoft.com/en-us/library/windowsazure/hh343262.aspx as a reference.

That page says

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

And further on it says

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

Now on this page http://msdn.microsoft.com/en-us/library/windowsazure/ee772878.aspx it gives an example:

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

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

Question: If the blobs are stored at http://accountname.blob.core.windows.net/ $logs then what do I make the blobEndPoint?

What do I put as the GetContainerReference("") ? I do not know the name of the container, I am new to Azure.

Thanks, Andrew

What do I put as the GetContainerReference("") ?

You would put $logs there. so your code would be:

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

Following screenshot shows how the blobs are stored in $logs directory

在此处输入图片说明

Essentially it is $logs / [blob|queue|table] / YYYY / MM / DD / HH00 / blob file . The blob file is a sequential file of 6 characters length starting from 000000 . Since you don't know the name of the blob, I would recommend that you do a List Blobs operation first to get all the blobs. To limit the number of blobs, you could do a prefix based search as well. For example, let's say you want to find all log entries for blobs for 2013-08-15 you would need to pass blob/2013/08/15 as blob prefix when you are listing blobs.

UPDATE:

However, please note that storage analytics are not enabled by default. You would need to enable it first. The screenshot I pasted below is from Azure Management Studio from Cerebrata ( http://www.cerebrata.com ). You can use that tool to enable storage analytics. They also have a free tool to configure analytics which you can download from here: http://blog.cerebrata.com/articles/2011/08/11/cerebrata-windows-azure-storage-analytics-configuration-utility-a-free-utility-to-configure-windows-azure-storage-analytics/ . First, please enable storage analytics, wait for sometime for this container to get created and then execute your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM