View on GitHub

SqlBuildManager

SQL Build Manager is an all-in-one database management tool to easily update your fleet SQL Server databases - from one to tens of thousands.

Setting Up an Azure Environment


The simplest way to provision all Azure resources is using the Azure Developer CLI (azd). This approach uses Bicep templates in the /infra folder for Infrastructure as Code deployment.

Prerequisites

Steps

  1. Open a terminal at the repository root (where azure.yaml is located)
  2. Login to Azure:
    azd auth login
    az login
    
  3. Initialize the environment (first time only):
    azd init
    

    You will be prompted for:

    • Environment name - This becomes the resource prefix (3-10 characters, lowercase)
    • Azure subscription - Select your target subscription
    • Azure location - Select the region for deployment
  4. Provision the resources:
    azd up
    

What happens during azd up

Pre-provision Hook (scripts/preprovision.ps1)

Infrastructure Deployment (infra/main.bicep)

Creates the following Azure resources with the environment name as prefix:

Post-provision Hook (scripts/postprovision.ps1)

Configuration Parameters

You can customize the deployment by setting environment variables before running azd up:

# Deployment toggles
azd env set DEPLOY_BATCH_ACCOUNT true       # Deploy Azure Batch (default: true)
azd env set DEPLOY_CONTAINER_REGISTRY true  # Deploy ACR (default: true)
azd env set DEPLOY_CONTAINERAPP_ENV true    # Deploy Container Apps (default: true)
azd env set DEPLOY_AKS true                 # Deploy AKS (default: true)

# Database settings
azd env set TEST_DB_COUNT_PER_SERVER 10     # Test databases per server (default: 10)

# Post-provision options
azd env set BUILD_BATCH_PACKAGES true       # Build and upload Batch packages
azd env set BUILD_CONTAINER_IMAGES true     # Build and push Docker images
azd env set GENERATE_MI_SETTINGS true       # Generate settings files (default: true)

# Security options
azd env set USE_PRIVATE_ENDPOINT false      # Use private endpoints (default: false)

Output Files

After successful deployment, the following files are generated in src/TestConfig:


Notes on Unit Testing

NOTE: There are currently some concurrency issues with the unit tests. You may get some failures in a full run that will then succeed after running aain, selecting only the failed tests

There are three types of Tests included in the solution:

  1. True unit tests with no external dependency - found in the ~UnitTest.csproj projects
  2. Those that are dependent on a local SQLEXPRESS database - found in the ~.Dependent.UnitTest.csproj projects. If you want to be able to run the database dependent tests, you will need to install SQL Express as per the next section.
    IMPORTANT: If running the SQLEXPRESS dependent tests for the first time on your local machine, you need to run the tests in the SqlSync.SqlBuild.Dependent.UnitTest.csproj first. This project has the scripts to create the necessary SQLEXPRESS databases.
  3. Integration tests that leverage Azure resources for Batch and Kubernetes. These are found in the SqlBuildManager.Console.ExternalTest.csproj project. To run these tests, first run create_azure_resources.ps1 with the -testDatabaseCount value >1 (the default is 10). This will create the necessary resources and test config files (in /src/TestConfig folder) needed to run the tests.

SQL Express

In order to get some of the unit tests to succeed, you need to have a local install of SQLExpress. You can find the installer from here [https://www.microsoft.com/en-us/sql-server/sql-server-editions-express] (https://www.microsoft.com/en-us/sql-server/sql-server-editions-express). You should be able to leverage the basic install.


Visual Studio Installer Project

For Visual Studio 2015 and beyond, you will need to install an extension to load the installer project (.vdproj)

Visual Studio 2022

https://marketplace.visualstudio.com/items?itemName=VisualStudioClient.MicrosoftVisualStudio2022InstallerProjects

Visual Studio 2017 and 2019

https://marketplace.visualstudio.com/items?itemName=VisualStudioClient.MicrosoftVisualStudio2017InstallerProjects

Visual Studio 2015

https://visualstudiogallery.msdn.microsoft.com/f1cc3f3e-c300-40a7-8797-c509fb8933b9

If you are having trouble with the installer project loading try disable extension “Microsoft Visual Studio Installer Projects”, reenable, then reload the projects.