winterishere
winterishere

Reputation: 389

Azure data lake query acceleration error - One or more errors occurred. (XML specified is not syntactically valid

I am trying to filter data from azure storage account using ADLS query. Using Azure Data Lake Storage Gen2. Not able to filter data and get the result in. Been stuck on this issue, even Microsoft support is not able to crack this issue. Any help is greatly appreciated.

Tutorial Link: https://www.c-sharpcorner.com/article/azure-data-lake-storage-gen2-query-acceleration/

Solution - .Net Core 3.1 Console App

Error: One or more errors occurred. (XML specified is not syntactically valid.) Status: 400 (XML specified is not syntactically valid.)

        private static async Task MainAsync()
    {
        var connectionString = "DefaultEndpointsProtocol=https;AccountName=gfsdlstestgen2;AccountKey=0AOkFckONVYkTh9Kpr/VRozBrhWYrLoH7y0mW5wrw==;EndpointSuffix=core.windows.net";
        var blobServiceClient = new BlobServiceClient(connectionString);
        var containerClient = blobServiceClient.GetBlobContainerClient("test");

        await foreach (var blobItem in containerClient.GetBlobsAsync(BlobTraits.Metadata, BlobStates.None, "ds_measuringpoint.json"))
        {
            var blobClient = containerClient.GetBlockBlobClient(blobItem.Name);

            var options = new BlobQueryOptions
            {
                InputTextConfiguration = new BlobQueryJsonTextOptions(),
                OutputTextConfiguration = new BlobQueryJsonTextOptions()
            };

            var result = await blobClient.QueryAsync(@"SELECT * FROM BlobStorage WHERE measuringpointid = 547", options);

            var jsonString = await new StreamReader(result.Value.Content).ReadToEndAsync();

            Console.WriteLine(jsonString);
            Console.ReadLine();
        }

Upvotes: 0

Views: 259

Answers (2)

tuseau
tuseau

Reputation: 1403

Old question, but I had this issue and its because BlobQueryJsonTextOptions needs the RecordSeparator specified, eg:

        OutputTextConfiguration = new BlobQueryJsonTextOptions
        {
            RecordSeparator = "\n"
        }

Thanks Microsoft for your excellent and helpful error handling /s

Upvotes: 1

winterishere
winterishere

Reputation: 389

After looking every where and testing almost all variations of ADLS query for .net Microsoft support mentioned

Azure.Storage.Blobs version 12.10 is broken version. We had to downgrade to 12.8.0

Downgrading this package to 12.8.0 worked.

Upvotes: 0

Related Questions