.netazure-blob-storageoledboledbconnectionoledbexception

Can I specify Azure Blob File as Data Source in the OleDB connection string?


I am very new to OleDB stuff. I am just making changes to someone else's .NET project, and they're using OleDB when creating a data report file.

Currently, a local data file is being passed to the OleDB as a data source (part of the OleDB connection string). So the connection string looks something like this: "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\SomeFolder\SomeFile;..."

However, I need to have the Data Source be a file I have in my Azure Blob. What I tried is setting the connection string's Data Source to something like: https://azure-storageacc-name.blob.core.windows.net/blobcontainername/myfile.xlsx, but when I try to pass a connection string having this Data Source, I get an error when I try to open oleDBConnection: System.Data.OleDb.OleDbException: 'Failure creating file.'

connection = new OleDbConnection(connectionString);
                connection.Open() //<-- WHERE THE ERROR OCCURS;

Does somebody know if it is possible to pass a connection string to oleDB where Data Source is an Azure Blob source? If yes, how would I do it? Thanks!


Solution

  • AFAIK, we can't use Azure Blob has a Data Source of OleDB. As per Ms-Doc we can use Excel workbook and Database in OleDB.

    By default, if we want to make use of Azure blob, we need to have access to the blob with either SAS URL or Connection String. In OleDB we cannot access in a data source.

    Configure the data source to connect OleDB which meet the provider prerequisites.

    For the above selected provider ensure that creds are secured, and the connection is created and retained during the runtime.

    Refer MSDN forum discussion for the related issue.