Query Blob Content: Query CSV Syntax

Muneeb Mirza 41 Reputation points
2021-07-09T06:57:16.597+00:00

I checked this API https://learn.microsoft.com/en-us/rest/api/storageservices/query-blob-contents and ran it. I was able to get complete CSV file that is stored in Azure Blob Storage.

This API also says we can request with a query

https://myaccount.blob.core.windows.net/mycontainer/myblob?comp=query

I am sending query as

<QueryRequest>
<QueryType>SQL</QueryType>
<Expression>limit 5</Expression>
</QueryRequest>

My blob is a CSV file and link mentioned above says it accepts SQL query, but I am unsure what will be used as table name or how the query will look like.

For example, if I have a csv file named custom_data.csv, suppose it has columns id, name, description, order how can I write a query saying bring me records where

  1. id=123
  2. name like '%john%'

if it is SQL, then what is to be added in FROM, can I get a proper example here?

Thanks.

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,639 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vaibhav Chaudhari 38,686 Reputation points
    2021-07-09T09:39:17.457+00:00

    Try providing complete SQL query like below. If the file is CSV, table name will be "BlobStorage"

    SELECT * FROM BlobStorage LIMIT 5

    See the examples here to use in Expression:

    https://learn.microsoft.com/en-us/azure/storage/blobs/query-acceleration-sql-reference#select-syntax

    ----------

    Please don't forget to Accept Answer and Up-vote if the response helped -- Vaibhav

    1 person found this answer helpful.