Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fbeltrao/sql-filestream-to-storage-migration
Tool to migrate SQL FileStream content to an Azure Storage
https://github.com/fbeltrao/sql-filestream-to-storage-migration
azure azure-storage dotnet-core sql sqlazure
Last synced: 3 days ago
JSON representation
Tool to migrate SQL FileStream content to an Azure Storage
- Host: GitHub
- URL: https://github.com/fbeltrao/sql-filestream-to-storage-migration
- Owner: fbeltrao
- License: mit
- Created: 2018-06-27T09:20:17.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-06-28T10:07:00.000Z (over 6 years ago)
- Last Synced: 2024-11-09T03:52:56.087Z (6 days ago)
- Topics: azure, azure-storage, dotnet-core, sql, sqlazure
- Language: C#
- Size: 107 KB
- Stars: 16
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SQL Server FileStream to Azure Storage
A simple .NET Core 2.1 tool to help you migrate your [SQL Server FileStream](https://docs.microsoft.com/en-us/sql/relational-databases/blob/filestream-sql-server?view=sql-server-2017) contents to an Azure SQL database and Azure Blob Storage.![](./images/sql-filestream-to-storage-migration.png "SQL Server FileStream to Azure Storage")
## Getting started
- Visual Studio 2017, .NET Core 2.1
- Azure SQL Database
- Azure Blob Storage account
- Replace the necessary database and storage connection strings in [appsettings.json](src/FileStreamToAzureStorageMigrator/appsettings.json)```json
{
"source": {
"sqlServerDatabaseConnectionString": "<-- replace with SQL Server connection string -->",
"filesStreamInfoCsvFile": "filestream.csv"
},
"destination": {
"azureSqlDatabaseConnectionString": "<-- replace with Azure SQL connection string -->",
"azureBlobStorageConnectionString": "<-- replace with Azure Blob Storage connection string -->"
}
}
```
- Go to the command line, to the directory where you cloned the repo:
```csharp
> dotnet restore
> dotnet build src/FileStreamToAzureStorageMigrator.sln
> dotnet run --project src/FileStreamToAzureStorageMigrator/FileStreamToAzureStorageMigrator.csproj
```- It all starts [here](/src/FileStreamToAzureStorageMigrator/Program.cs) in 2 easy steps
```csharp
class Program
{
public static IConfiguration Configuration { get; set; }
static async Task Main(string[] args)
{
InitializeConfiguration();string sourceSqlServerDatabaseConnectionString = Configuration["source:sqlServerDatabaseConnectionString"];
string destinationAzureSqlDatabaseConnectionString = Configuration["destination:azureSqlDatabaseConnectionString"];
string destinationAzureBlobStorageConnectionString = Configuration["destination:azureBlobStorageConnectionString"];
string filesStreamInfoCsvFile = Configuration["source:filesStreamInfoCsvFile"];// Step 1: copy the file contents to Blob Storage
var sqlServerToAzureBlobStorage = new SqlServerToAzureBlobStorage(sourceSqlServerDatabaseConnectionString, destinationAzureBlobStorageConnectionString, filesStreamInfoCsvFile);
await sqlServerToAzureBlobStorage.CopyDataAsync();// Step 2: copy the files metadata (table) to Azure SQL
var filesMetadataToAzureSql = new CsvFilesMetadataToAzureSql(destinationAzureSqlDatabaseConnectionString, filesStreamInfoCsvFile);
await filesMetadataToAzureSql.CopyDataAsync();
}///
/// Configuration initialization
///
private static void InitializeConfiguration()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json");Configuration = builder.Build();
}}
```- You can also adjust:
- The [FileStreamFile.cs](/src/FileStreamToAzureStorageMigrator/FileStreamFile.cs) class with the desired file metadata, to be migrated to the Azure SQL database table
- The [SqlServerToAzureBlobStorage.cs](/src/FileStreamToAzureStorageMigrator/SqlServerToAzureBlobStorage.cs) SQL queries in this class with the queries you need to fetch from you SQL Server database
### Contributors
[@damirkusar](https://github.com/damirkusar), [@DjolePetrovic](https://github.com/DjolePetrovic), [@jonathandbailey](https://github.com/jonathandbailey), [@meinradweiss](https://github.com/meinradweiss), [@fbeltrao](https://github.com/fbeltrao) and [@CarlosSardo](https://github.com/carlossardo)