简体   繁体   中英

How to import Excel files into SQL Server with Azure services

Currently I have a web app that imports Excel files, parses them (using openXML) then imports the data into SQL Server. The user does not need to predefine the Excel template as long as he sends the file in the same order of the database table he wants to insert it, if a value is not compatible with a column type, the system generates a log error file which basically says: "Excel Address -> A1, Value -> XXXXX (string), Expected -> (Date yyyy/mm/dd).

On parsing the file I check if the formats are compatible with the db table

I want to migrate this service to the cloud, specifically azure since I use Visual Studio to develop and the integrations facilitate the job. However I'm a little lost on the multiple services and if its possible to even do this kind of work.

I would like to store the files in Azure Blob storage then send to Data Lake(?) to import the data to a SQL Server database, is this possible? Are these the services I should use?

The simplest (and probably cheapest) solution I can think of given these constraints would be to upload to an Azure Function. Your Azure Function can then perform the parsing and insert records into the SQL database. It can also return an HTTP error code and message if the parsing cannot complete due to data errors.

The downside of Azure Functions is runtime constraints. If you are pushing so much data that you run into those constraints, you could spin up an Azure WebApp to do the same thing.

Can't you just create your tables in Azure SQL and then change your current web application to connect to Azure SQL instead of your on-premise SQL Server?

Azure SQL is basically a SQL Server in the cloud with a few differences (nowadays the on-premise versions also contains most of the Azure features).

If you are lucky you would just need to change your connection string:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM