Ali Chaudry
Ali Chaudry

Reputation: 31

How to attach .MDF file to Azure SQL Server programmatically c#

I have a .MDF file in my local directory, I need to attach it in Azure SQL Server using C# code just like I attached it in a local SQL Server using the server.AttachDatabase function.

Upvotes: 1

Views: 1198

Answers (1)

Mike Ubezzi
Mike Ubezzi

Reputation: 1027

This is unsupported in Azure SQL Logical Server. You can export a .bacpac/.bak file from a local (on-premise) instance and restore the .bacpac file to Azure SQL Database Logical Server, and the .bak file can be restored to an Azure SQL Managed Instance. These are all PaaS offerings for Azure SQL Database. You can, however, execute that same C# code to attach an .mdf file to an Azure SQL Server deployed to an Azure VM. This is an Azure SQL Server IaaS option, which is a full-featured SQL Server deployment: Choose the right SQL Server option in Azure - PaaS or IaaS

Upvotes: 3

Related Questions