1

I have uploaded a single file (BlockBlob) to a container in the Azure BlobStorage

This is the path: https://myStorageName.blob.core.windows.net/myContainerName/myFolder.Name/myFileName.json

I want to load this file into a table within Azure Sql Database

If I create a SAS to the file, things works perfectly. However I am failing to generate a single SAS that can access multiple files inside a container.

Here is the code that works:

CREATE DATABASE SCOPED CREDENTIAL TemporaryBlobSCredential
 WITH IDENTITY = 'SHARED ACCESS SIGNATURE',
 SECRET = 'sp=......................'

CREATE EXTERNAL DATA SOURCE TemporaryBlobDataSource
 WITH ( TYPE = BLOB_STORAGE,
       LOCATION = 'https://<myStorageName>.blob.core.windows.net/<myContainerName>',
       CREDENTIAL= TemporaryBlobSCredential);

create table <tableName>
(JsonData varchar(max))
 
BULK INSERT <tableName>
FROM '<myFolder.Name>/<myFileName>.json'
WITH (DATA_SOURCE = 'TemporaryBlobDataSource');
 

If I generate a SAS that has ALL the permissions (SECRET = '?sv=......') it won't work:

Generating Storage SAS

Should I use something different? Does it even works?

2 Answers 2

2

This document says:

Warning

The SAS key value might begin with a '?' (question mark). When you use the SAS key, you must remove the leading '?'. Otherwise your efforts might be blocked.

I notice in your working code there is no ‘?’ but there is in your SAS token which doesn’t work. Can you double check this small difference isn’t the problem?

Sign up to request clarification or add additional context in comments.

Comments

2

I just tried to run the code which you shared and it is very similar to what is pasted here . if you scroll up on the page , the "Applies to" does not call out synapse / SQL DW . Are you sure that you are using Synapse ? BULK INERT is not supported in SQL pool .

Anyways if you are using Synapse generally we can use the COPY INTO command but in your case we have JSON format which is not support . I think you can use Azure datafactory

1 Comment

You are right. Multitasking doesn't always work. I have just edited the question, but Greg were already right.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.