Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure Blob存储-$logs容器中的ListBlob_Azure_Azure Storage Blobs - Fatal编程技术网

Azure Blob存储-$logs容器中的ListBlob

Azure Blob存储-$logs容器中的ListBlob,azure,azure-storage-blobs,Azure,Azure Storage Blobs,我们有一个azure blob存储,并启用了日志记录。 我可以使用管理门户查看这些日志并下载blob。 但现在我正试图使用客户端api列出这些日志。 大致如下: let account = new CloudStorageAccount(credentials, true) let client = account.CreateCloudBlobClient() let container = client.GetContainerReference "$logs" container.List

我们有一个azure blob存储,并启用了日志记录。 我可以使用管理门户查看这些日志并下载blob。 但现在我正试图使用客户端api列出这些日志。 大致如下:

let account = new CloudStorageAccount(credentials, true)
let client = account.CreateCloudBlobClient()
let container = client.GetContainerReference "$logs"
container.ListBlobs()
但这会抛出一个web异常代码
400错误请求
。 我可以。但是,请列出此客户端上其他容器中的blob。 我知道我需要为此容器进行身份验证,但我正在使用凭据的主访问密钥。 那么为什么我不能得到$logs块呢


谢谢

正如我在上面的评论中提到的,您需要使用最新版本的存储客户端库,您可以从Nuget获得该库:

以下是示例代码:

open Microsoft.WindowsAzure.Storage
open Microsoft.WindowsAzure.Storage.Auth
open Microsoft.WindowsAzure.Storage.Blob

[<EntryPoint>]
let main argv = 
    let credentials = new StorageCredentials("accountname", "accountkey")
    System.Console.WriteLine(credentials.AccountName)
    let account = new CloudStorageAccount(credentials, true)
    System.Console.WriteLine(account.BlobEndpoint)
    let client = account.CreateCloudBlobClient();
    let container = client.GetContainerReference "$logs"
    System.Console.WriteLine(container.Uri)
    let blobs = container.ListBlobs("", true, BlobListingDetails.All, null, null);
    for blob in blobs do
        System.Console.WriteLine(blob.Uri)
    let response = System.Console.ReadLine()
    0 // return an integer exit code
打开Microsoft.WindowsAzure.Storage
打开Microsoft.WindowsAzure.Storage.Auth
打开Microsoft.WindowsAzure.Storage.Blob
[]
让主argv=
let credentials=new-StorageCredentials(“accountname”、“accountkey”)
System.Console.WriteLine(凭据.帐户名)
let account=新的CloudStorageAccount(凭据,true)
System.Console.WriteLine(account.BlobEndpoint)
让client=account.CreateCloudBlobClient();
让container=client.GetContainerReference“$logs”
System.Console.WriteLine(container.Uri)
让blobs=container.ListBlobs(“”,true,BlobListingDetails.All,null,null);
对于水滴中的水滴,请执行以下操作:
System.Console.WriteLine(blob.Uri)
let response=System.Console.ReadLine()
0//返回整数退出代码
以上代码需要存储客户端库2.0


您只返回一项的原因是,您正在调用没有参数的
ListBlobs
函数。如果查看此处()函数的定义,您将看到可以通过将
useFlatBlobListing
参数指定为true(我在上面的代码中这样做)来获取blob容器中的所有blob。请尝试一下,它将返回blob容器中所有blob的列表

正如我在上面的评论中提到的,您需要使用最新版本的存储客户端库,您可以从Nuget获得该库:

以下是示例代码:

open Microsoft.WindowsAzure.Storage
open Microsoft.WindowsAzure.Storage.Auth
open Microsoft.WindowsAzure.Storage.Blob

[<EntryPoint>]
let main argv = 
    let credentials = new StorageCredentials("accountname", "accountkey")
    System.Console.WriteLine(credentials.AccountName)
    let account = new CloudStorageAccount(credentials, true)
    System.Console.WriteLine(account.BlobEndpoint)
    let client = account.CreateCloudBlobClient();
    let container = client.GetContainerReference "$logs"
    System.Console.WriteLine(container.Uri)
    let blobs = container.ListBlobs("", true, BlobListingDetails.All, null, null);
    for blob in blobs do
        System.Console.WriteLine(blob.Uri)
    let response = System.Console.ReadLine()
    0 // return an integer exit code
打开Microsoft.WindowsAzure.Storage
打开Microsoft.WindowsAzure.Storage.Auth
打开Microsoft.WindowsAzure.Storage.Blob
[]
让主argv=
let credentials=new-StorageCredentials(“accountname”、“accountkey”)
System.Console.WriteLine(凭据.帐户名)
let account=新的CloudStorageAccount(凭据,true)
System.Console.WriteLine(account.BlobEndpoint)
让client=account.CreateCloudBlobClient();
让container=client.GetContainerReference“$logs”
System.Console.WriteLine(container.Uri)
让blobs=container.ListBlobs(“”,true,BlobListingDetails.All,null,null);
对于水滴中的水滴,请执行以下操作:
System.Console.WriteLine(blob.Uri)
let response=System.Console.ReadLine()
0//返回整数退出代码
以上代码需要存储客户端库2.0


您只返回一项的原因是,您正在调用没有参数的
ListBlobs
函数。如果查看此处()函数的定义,您将看到可以通过将
useFlatBlobListing
参数指定为true(我在上面的代码中这样做)来获取blob容器中的所有blob。请尝试一下,它将返回blob容器中所有blob的列表

我试过了,它对我有效。您能告诉我您使用的是什么版本的存储客户端库吗?我同时使用了1.8和2.0,在这两种情况下都能正常工作。在我的机器上是1.7.0。。。嗯。。在哪里更新?:)您可以从下载最新的SDK,也可以从Nuget:引用最新的存储客户端库。哦,我用的是不推荐的StorageClient,现在我用的是最新的DLL。现在ListBlob只返回一项:
https://{storage}.blob.core.windows.net/$logs/blob/
,尽管容器中还有很多blob…将此更改为答案:)我尝试了它,它对我有效。您能告诉我您使用的是什么版本的存储客户端库吗?我同时使用了1.8和2.0,在这两种情况下都能正常工作。在我的机器上是1.7.0。。。嗯。。在哪里更新?:)您可以从下载最新的SDK,也可以从Nuget:引用最新的存储客户端库。哦,我用的是不推荐的StorageClient,现在我用的是最新的DLL。现在listblobs只返回一项:
https://{storage}.blob.core.windows.net/$logs/blob/
,尽管容器中还有很多blobs…将此更改为答案:)非常感谢:)最后我将useFlatBlobListing设置为false,并想知道为什么没有效果…我太好奇那是什么语言了:)非常感谢:)最后我将useFlatBlobListing设置为false,并想知道为什么这没有效果……我只是太好奇那是什么语言了?:)