Home / Data Platform / Warehouses

Data PlatformTroubleshootingIntermediate

Synapse serverless SQL OPENROWSET errors: file cannot be opened, access denied, UTF-8 warnings and truncation

Fix the common Synapse serverless SQL OPENROWSET failures over ADLS Gen2, including missing files, 403s, storage firewalls, credentials, UTF-8 collation warnings and conversion errors.

Deepak Bhardwaj8 min read

Applies toAzure Synapse Analytics serverless SQL pool, ADLS Gen2, Parquet, CSV and Delta files

Symptom

A query or view in the Synapse serverless SQL pool (<workspace>-ondemand.sql.azuresynapse.net) that reads the lake with OPENROWSET fails, or returns wrong data, with one of these:

  • File 'https://<account>.dfs.core.windows.net/...' cannot be opened because it does not exist or it is used by another process.
  • Content of directory on path '...' cannot be listed.
  • Potential conversion error while reading VARCHAR column '...' from UTF8 encoded text.
  • Bulk load data conversion error (truncation) for row N, column M or Error handling external file: 'Max errors count reached'.

The "cannot be opened" message is misleading. Most of the time the file exists and the problem is access.

Quick map

Message / behaviour Likely cause Fix
Cannot be opened / cannot be listed, works for an admin Caller has no data-plane role or ACL on the path Grant Storage Blob Data Reader or ACLs (section 2)
Fails for everyone, including admins Storage firewall blocks Synapse Resource instance rule (section 3)
Fails only through a view or external table used by an app Credential on the data source missing or wrong Database scoped credential (section 4)
Fails once during a load, then works Files rewritten while the query ran Read a stable folder, or use Delta (section 5)
UTF-8 warning, garbled characters Database collation isn't UTF-8 UTF-8 collation (section 6)
Truncation / conversion error Inferred or declared type too small, bad rows in CSV Explicit WITH schema (section 7)

1. Reproduce with the smallest query

Connect to the serverless endpoint as the failing identity and read one file directly, without views or external data sources:

SELECT TOP 10 *
FROM OPENROWSET(
    BULK 'https://mydatalake.dfs.core.windows.net/curated/sales/2026/11/14/part-0000.parquet',
    FORMAT = 'PARQUET'
) AS r;

Then the whole folder with a wildcard:

SELECT COUNT(*)
FROM OPENROWSET(
    BULK 'https://mydatalake.dfs.core.windows.net/curated/sales/2026/11/*/*.parquet',
    FORMAT = 'PARQUET'
) AS r;

If the single file works and the folder doesn't, look at section 5 or at ACLs on a sub-folder. If neither works, check whose identity is used: Entra ID logins pass their own identity through to storage. SQL logins can only use a server or database scoped credential.

SELECT SUSER_SNAME() AS login_name, ORIGINAL_LOGIN() AS original_login;

2. Grant the caller access to the data

With Entra pass-through, the user or service principal running the query needs read on storage. Having rights in Synapse isn't enough.

STORAGE_ID=$(az storage account show -n mydatalake -g rg-data --query id -o tsv)

az role assignment create \
  --assignee <user-or-group-object-id> \
  --role "Storage Blob Data Reader" \
  --scope "$STORAGE_ID/blobServices/default/containers/curated"

Owner or Contributor on the storage account doesn't grant data access. You need a Storage Blob Data * role. Role assignments can take several minutes to apply.

If you use POSIX ACLs instead of RBAC, the identity needs execute (--x) on every folder from the container root down, plus read and execute (r-x) on the target folder and read on the files:

az storage fs access show -p sales/2026/11 -f curated \
  --account-name mydatalake --auth-mode login

Tip

A folder created after the ACL was set only inherits it if a default ACL exists on the parent. "Yesterday's partition works, today's doesn't" is usually a missing default ACL.

3. Storage firewall blocks the workspace

If Public network access on the storage account is set to selected networks, serverless SQL needs an exception. Add a resource instance rule for the Synapse workspace:

WS_ID=$(az synapse workspace show -n mysynapse -g rg-data --query id -o tsv)

az storage account network-rule add \
  --account-name mydatalake -g rg-data \
  --resource-id "$WS_ID" \
  --tenant-id <tenant-id>

az storage account network-rule list --account-name mydatalake -g rg-data \
  --query resourceAccessRules

With a managed virtual network workspace, use a managed private endpoint to the storage dfs (and blob) sub-resources and approve it on the storage side. Check the current Synapse networking documentation for which combination your workspace supports.

4. Views and external tables: fix the credential

Apps often connect with a SQL login, or you want queries to use the workspace managed identity instead of each user's identity. That needs a database scoped credential on the external data source.

-- In the user database, not master
CREATE MASTER KEY ENCRYPTION BY PASSWORD = '<strong-password>';

CREATE DATABASE SCOPED CREDENTIAL WorkspaceIdentity
WITH IDENTITY = 'Managed Identity';

CREATE EXTERNAL DATA SOURCE CuratedLake
WITH (
    LOCATION = 'https://mydatalake.dfs.core.windows.net/curated',
    CREDENTIAL = WorkspaceIdentity
);

-- The caller needs permission to use the credential
GRANT REFERENCES ON DATABASE SCOPED CREDENTIAL::WorkspaceIdentity TO [app_reader];

Then grant the workspace managed identity Storage Blob Data Reader on the container, the same way as in section 2.

For SAS credentials, IDENTITY = 'SHARED ACCESS SIGNATURE' and the SECRET is the token without the leading ?. An expired SAS produces the same "cannot be opened" error. Check the se= expiry in the token.

Find which credential a data source uses:

SELECT ds.name, ds.location, c.name AS credential_name, c.credential_identity
FROM sys.external_data_sources ds
LEFT JOIN sys.database_scoped_credentials c ON ds.credential_id = c.credential_id;

5. Files changing while you read them

Serverless SQL lists the files when the query starts. If a Spark or ADF job overwrites or deletes files in that folder during the query, it fails with "cannot be opened" or can return mixed old and new data.

  • Write to a new folder (.../load_id=20261115T0200/) and switch readers once the load has finished, rather than overwriting in place.
  • Prefer Delta tables (FORMAT = 'DELTA' pointing at the table root) so readers see a committed snapshot. Serverless supports a subset of Delta reader features. Check the current docs before enabling newer table features such as deletion vectors on tables that serverless reads.
  • Exclude temporary files (_temporary, _SUCCESS, .crc) by using a file pattern like *.parquet instead of **.

6. UTF-8 conversion warnings

Parquet and Delta strings are UTF-8. If the database's default collation isn't a UTF-8 collation, non-ASCII characters can be mangled and you get the "Potential conversion error" warning.

SELECT name, collation_name FROM sys.databases;

-- Fix for new objects in a database you own
ALTER DATABASE CURRENT COLLATE Latin1_General_100_BIN2_UTF8;

Or declare it per column:

SELECT *
FROM OPENROWSET(
    BULK 'sales/2026/11/*/*.parquet',
    DATA_SOURCE = 'CuratedLake',
    FORMAT = 'PARQUET'
) WITH (
    order_id     BIGINT,
    customer     VARCHAR(200) COLLATE Latin1_General_100_BIN2_UTF8,
    amount       DECIMAL(18,2)
) AS r;

Warning

Don't change collation on the master database. Create a user database for your views and set the collation there.

7. Truncation and conversion errors

Without a WITH clause, serverless infers types. Strings often come back as VARCHAR(8000), which is slow, and CSV inference can guess too-small types from the first rows. See what it infers:

EXEC sp_describe_first_result_set N'
SELECT * FROM OPENROWSET(
    BULK ''sales/2026/11/14/*.csv'', DATA_SOURCE = ''CuratedLake'',
    FORMAT = ''CSV'', PARSER_VERSION = ''2.0'', HEADER_ROW = TRUE
) AS r';

For CSV, declare the schema and handle bad rows deliberately:

SELECT *
FROM OPENROWSET(
    BULK 'landing/orders/2026/11/14/*.csv',
    DATA_SOURCE = 'CuratedLake',
    FORMAT = 'CSV',
    PARSER_VERSION = '2.0',
    HEADER_ROW = TRUE,
    FIELDTERMINATOR = ',',
    FIELDQUOTE = '"'
) WITH (
    order_id   BIGINT,
    note       VARCHAR(4000) COLLATE Latin1_General_100_BIN2_UTF8,
    amount     DECIMAL(18,2)
) AS r;

If one value is wider than declared, widen that column, or find the row with a filter on r.filepath() and the key. Look at the source file encoding too: files that aren't UTF-8 are best converted upstream. CODEPAGE and DATAFILETYPE exist but are not supported by every parser version, so check the docs for your parser version.

Prevent it next time

  • Grant storage access to Entra groups, not individuals, and set default ACLs on parent folders so new partitions inherit them.
  • Put every view on an explicit WITH schema with UTF-8 collation, so changes in the inferred types upstream don't break consumers.
  • Have loaders write to new folders or Delta tables, never overwrite folders that serverless reads.
  • Keep a smoke-test query per external data source in your monitoring (a scheduled SELECT TOP 1), run as the application identity, so an expired SAS or a firewall change pages you before a dashboard user notices.