Skip to content

Commit 43d4b74

Browse files
authored
Merge pull request #14145 from rohitnayakmsft/patch-3
Updated Importing data from a file in Azure blob storage
2 parents 47c4339 + fa234c7 commit 43d4b74

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

docs/t-sql/statements/bulk-insert-transact-sql.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,24 @@ WITH ( TYPE = BLOB_STORAGE,
487487
, CREDENTIAL= MyAzureBlobStorageCredential --> CREDENTIAL is not required if a blob is configured for public (anonymous) access!
488488
);
489489

490+
BULK INSERT Sales.Invoices
491+
FROM 'inv-2017-12-08.csv'
492+
WITH (DATA_SOURCE = 'MyAzureBlobStorage');
493+
```
494+
Another way to access the storage account is via [Managed Identity](https://docs.microsoft.com/azure/active-directory/managed-identities-azure-resources/overview). To do this follow the [Steps 1 thru 3](https://docs.microsoft.com/azure/sql-database/sql-database-vnet-service-endpoint-rule-overview?toc=/azure/sql-data-warehouse/toc.json&bc=/azure/sql-data-warehouse/breadcrumb/toc.json#steps) to configure SQL Database to access Storage via Managed Identity, after which you can implement code sample as below
495+
```sql
496+
--> Optional - a MASTER KEY is not required if a DATABASE SCOPED CREDENTIAL is not required because the blob is configured for public (anonymous) access!
497+
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'YourStrongPassword1';
498+
GO
499+
--> Change to using Managed Identity instead of SAS key
500+
CREATE DATABASE SCOPED CREDENTIAL msi_cred WITH IDENTITY = 'Managed Identity';
501+
GO
502+
CREATE EXTERNAL DATA SOURCE MyAzureBlobStorage
503+
WITH ( TYPE = BLOB_STORAGE,
504+
LOCATION = 'https://****************.blob.core.windows.net/curriculum'
505+
, CREDENTIAL= msi_cred --> CREDENTIAL is not required if a blob is configured for public (anonymous) access!
506+
);
507+
490508
BULK INSERT Sales.Invoices
491509
FROM 'inv-2017-12-08.csv'
492510
WITH (DATA_SOURCE = 'MyAzureBlobStorage');

0 commit comments

Comments
 (0)