简体   繁体   中英

Can't create an external data source from Azure Blob Storage Container to Azure Sql Database Hyperscale

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:

生成存储 SAS

Should I use something different? Does it even works?

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

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?

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