Console app to migrate MSSQL export into Azure Cosmos DB and containerized Blazor server app to browse the new database and create excel exports. The apps are automatically deployed via Azure DevOps Pipeline CI.
Technologies used in this project:
- ASP.NET Core 6.0, C# 10, Blazor Application using minimal hosting model
- .NET to JavaScript streaming via DotNetStreamReference
- .Net 6 Core Console Application
Azure Resources:
- Cosmos DB
- Container Registry
- Container Instance with environment variables and managed identity.
- KeyVault
NuGet Packages:
- Microsoft.Azure.Cosmos
- Azure.Identity
- Azure.Extensions.AspNetCore.Configuration.Secrets
- NPOI
Automatic deployment of Azure DevOps Project, Service Endpoints, and Pipeline.
Steps to reproduce:
- Setup the DevOps project by running the setdevopsproj.sh script. Update the script variables to fit your environment. This script requires the extension azure-devops, will run completely unattended if you set the AZURE_DEVOPS_EXT_GITHUB_PAT variable before running the script or by entering the GitHub Pat in the script and uncommenting this line:
#export AZURE_DEVOPS_EXT_GITHUB_PAT=enter-github-pat-here
The setdevopsproj.sh script creates a DevOps project, two Service Endpoints (one for Azure, another for GitHub) and a Pipeline.
-
Clone your copy of the repository onto a computer running Microsoft SQL Server.
-
Execute the PowerShell SQLRestoreExport.ps1 script from the .\dbmigrate\Files directory. This script does the following:
- Downloads the WideWorldImporters from https://github.com/Microsoft/sql-server-samples,
- Restores the database into the local MSSQL server, and
- Exports 5 StockItem-related tables using the
bcp
command.
-
Commit the new report files.
Committing the report files will trigger the execution of the pipeline.
The pipeline will:
- Make sure all the Azure resources are in place,
- compile the dbmigrate console program and import the MSSQL reports into CosmosDB,
- compile the cosmosdbviewer Blazor application,
- upload its container to the Container Registry, and
- create a container instance from the image.
This blog details each step and some of the features of dbmigrate and comsosdbviewer programs, including how to authenticate using the managed identity of the application container instance to an Azure KeyVault to retrieve the Cosmos DB connection string.
There is also a YouTube 8 minute video that demonstrates an entire run of the process.
Enjoy
😃