Hi @IAA Dashboard,
The "Access is Denied" error (Operating system error code 5) you're encountering during the BULK INSERT
operation from Azure Blob Storage into Azure SQL Database is most commonly caused by either firewall restrictions on the storage account or issues with the credentials used to access the blob. One of the first things to check is the firewall configuration on your Azure Storage Account. In the Azure Portal, go to the storage account’s Networking section and verify that public network access is enabled. For troubleshooting, set it temporarily to allow access from all networks. If the setting restricts access to selected networks and the Azure SQL Database is not explicitly allowed, the database won’t be able to reach the blob, resulting in the access denied error.
You mentioned that files have been successfully loaded into Azure SQL from blob storage using PowerShell for over 2 years, and the process only recently started failing. This strongly suggests a change in the storage account’s network settings, token expiry, or a rotation of storage keys that may have gone unnoticed.
Next, verify that the external data source used in your BULK INSERT
statement is configured correctly with a valid Shared Access Signature (SAS) token or Storage Account Key. If you're using a SAS token, make sure it has not expired and contains the appropriate permissions at minimum, read(r
) and list (l
). Also, ensure the file path is accurate, including correct casing and the exact folder structure, since blob paths are case-sensitive.
It’s also important to clarify that adding the database name in the INSERT INTO
clause of your BULK INSERT
statement, as suggested in a previous response, is unnecessary and unrelated to this specific error. The problem is not with SQL syntax but rather with file access. Additionally, the suggested syntax (insert into ... from 'file.csv' with (...)
) is incorrect. The proper syntax is:
BULK INSERT schema.table FROM 'filename' WITH (DATA_SOURCE = 'source_name', ...);
If you’ve already found a solution to this problem, we encourage you to share it with the community. Your experience could help others facing a similar issue.
If anything is unclear or if you need further help, feel free to add a comment below.
Also, please click “Accept Answer” if this helped, so others can find the solution more easily.