Troubleshooting BULK INSERT and OPENROWSET issues on Azure SQL Database
Published Jun 03 2019 06:20 AM 11.9K Views
Microsoft

Azure SQL Database (single database and Managed Instance) enables you to load files from Azure Blob Storage. If you experience issues while you are loading files from Azure blob storage, below are some suggestions on steps you can take to troubleshoot and mitigate the issue.

 

  • If you are noticing that a syntax error is returned by BULK INSERT or BULK INSERT check that you are using supported syntax in this statement. As an example, if you are trying to load data via network share path note that this option is not supported in Managed Instance.
  • Make sure that you are using SAS key to access storage. Azure AD identities are currently not supported.
  • If you are getting an error 5 (Access Denied), make sure that you have not denied access to your Azure Blob Storage account using the firewall:Storage firewall.png

 

  • Verify that you have created the EXTERNAL DATA SOURCE with type BLOB_STORAGE targeting the URL of the blob storage where you placed the files that should be restored to your database.
  • Make sure that you are targeting an existing file on Azure blob storage.
  • Script the CREDENTIAL to SQL Server 2017 and try to load the files. If you are troubleshooting the issue on Managed Instance make sure that SQL Server is in the subnet that is within the same VNet as the Managed Instance.
  • Check if your SAS credential placed in the SECRET option of the CREATE DATABASE SCOPED CREDENTIAL statement valid. The most common errors in SAS token parameters are:
    • ? is not removed from the beginning of the SAS token because the Azure portal generates SAS token with the leading ?. Remove this character if you see it.
    • se (expiry date) property is set to some value in the past (note that this is UTC time).
    • st (start date) property is not in the past (note that this is UTC time).
    • sp (permission) property should allow reading the file on the storage account.
    • sip (ip range) remove this parameter if it is present in SAS token.
4 Comments
Co-Authors
Version history
Last update:
‎Aug 03 2022 12:52 AM
Updated by: