Skip to content

Commit

Permalink
Dotnet8 (#435)
Browse files Browse the repository at this point in the history
- *UPDATED:* Now targets .NET 8.0
- *UPDATED:* Simplified data object classes and regenerated typed DataSet classes
- *UPDATED:* Docker base set to .NET Runtime 8.0 and .NET SDK to 8.0
- *REMOVED:* Removed fall back Settings File Key generation from machine value. Now must be provided via `--settingsfilekey` argument or `sbm-settingsfilekey` Environment variable
- *ADDED:* `--settingsfilekey` is no longer required when a Key Vault Name is provided. This will bypass any settings file decryption and only retrieve the secrets directly from Key Vault
  • Loading branch information
mmckechney authored Dec 13, 2023
1 parent 7c51110 commit 1e6612d
Show file tree
Hide file tree
Showing 88 changed files with 883 additions and 748 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ on:
- cron: '37 9 * * 2'

env:
DOTNET_VERSION: 'net7.0'
DOTNET_FRAMEWORK_VERSION: '7.x'
DOTNET_VERSION: 'net8.0'
DOTNET_FRAMEWORK_VERSION: '8.x'

jobs:
analyze:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/container-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
context: "{{defaultContext}}:src"
platforms: linux/amd64,linux/arm64
push: true
provenance: false
tags: |
ghcr.io/${{ github.repository_owner }}/sqlbuildmanager:${{ steps.date.outputs.date }}
ghcr.io/${{ github.repository_owner }}/sqlbuildmanager:latest-vNext
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dotnetcore-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:
- master

env:
DOTNET_VERSION: 'net7.0'
DOTNET_FRAMEWORK_VERSION: '7.x'
DOTNET_VERSION: 'net8.0'
DOTNET_FRAMEWORK_VERSION: '8.x'

jobs:
build:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# SQL Build Manager Change Log

### Version 15.6.0
- *UPDATED:* Now targets .NET 8.0
- *UPDATED:* Simplified data object classes and regenerated typed DataSet classes
- *UPDATED:* Docker base set to .NET Runtime 8.0 and .NET SDK to 8.0
- *REMOVED:* Removed fall back Settings File Key generation from machine value. Now must be provided via `--settingsfilekey` argument or `sbm-settingsfilekey` Environment variable
- *ADDED:* `--settingsfilekey` is no longer required when a Key Vault Name is provided. This will bypass any settings file decryption and only retrieve the secrets directly from Key Vault

### Version 15.5.0
- *NEW:* For muti-database target builds, you can now specify custom concurrency tag. Previously, the only concurrency differentitor was by SQL Server Name. Please see the docs on [Concurrency](/docs/concurrency_options.md) and [Database targeting options](docs/override_options.md) to understand how to use this new feature.
- *UPDATED:* DACPAC creation timeouts now set to the value of `--defaultscripttimeout`. Previously, it was using the default settings.
Expand Down
42 changes: 42 additions & 0 deletions scripts/templates/-mi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"AuthenticationArgs": {
"AuthenticationType": "Password"
},
"ConnectionArgs": {
"KeyVaultName": "sbm235keyvault",
"ServiceBusTopicConnectionString": "0WzwQWxjx4WQa5rJTbSb/kPl0YBdfitD73Q1lt/4rX065uiufICp5kSzwrMGSahu139FfgGpCmxpJPDRporxKACd\u002BiaCtwFSmIOAIgcBwfMgC38eoXI/qp2Y9uHG51b97UgdJ9gQXUduMFiAsEh8vxwaije1ZpBFuqNcCu66XOcviiIAq233GFP6UkL89o394LJQqCcsX22QMLEdQOTwXUMYBq5Hz7/46dHhuyaryKIusN3gtrETZiyHrmjF2kLx",
"StorageAccountName": "sbm235storage"
},
"ContainerAppArgs": {
"EnvironmentName": "sbm235containerappenv",
"SubscriptionId": "0d901325-d643-4db7-ae90-58b4e3834629",
"ResourceGroup": "sbm235-rg",
"Location": "South Central US",
"MaxContainerCount": 10
},
"ContainerRegistryArgs": {
"RegistryServer": "sbm235containerregistry.azurecr.io",
"ImageName": "sqlbuildmanager",
"ImageTag": "latest-vNext",
"RegistryUserName": "sbm235containerregistry"
},
"EventHubArgs": {
"ResourceGroup": "sbm235-rg",
"SubscriptionId": "0d901325-d643-4db7-ae90-58b4e3834629",
"Logging": [
"EssentialOnly",
"ScriptErrors"
]
},
"IdentityArgs": {
"IdentityName": "sbm235identity",
"ClientId": "837e7b19-7a0c-4820-9df6-7b6913e4380a",
"ResourceGroup": "sbm235-rg",
"SubscriptionId": "0d901325-d643-4db7-ae90-58b4e3834629",
"TenantId": "16b3c013-d300-468d-ac64-7eda0820b6d3"
},
"Concurrency": 10,
"ConcurrencyType": "Count",
"TimeoutRetryCount": 0,
"DefaultScriptTimeout": 500
}
39 changes: 39 additions & 0 deletions scripts/templates/.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"AuthenticationArgs": {
"AuthenticationType": "Password"
},
"ConnectionArgs": {
"KeyVaultName": "sbm235keyvault",
"ServiceBusTopicConnectionString": "0WzwQWxjx4WQa5rJTbSb/kPl0YBdfitD73Q1lt/4rX065uiufICp5kSzwrMGSahu139FfgGpCmxpJPDRporxKACd\u002BiaCtwFSmIOAIgcBwfMgC38eoXI/qp2Y9uHG51b97UgdJ9gQXUduMFiAsEh8vxwaije1ZpBFuqNcCu66XOcviiIAq233GFP6UkL89o394LJQqCcsX22QMLEdQOTwXUMYBq5Hz7/46dHhuyaryKIusN3gtrETZiyHrmjF2kLx",
"StorageAccountName": "sbm235storage"
},
"ContainerAppArgs": {
"EnvironmentName": "sbm235containerappenv",
"SubscriptionId": "0d901325-d643-4db7-ae90-58b4e3834629",
"ResourceGroup": "sbm235-rg",
"Location": "South Central US",
"MaxContainerCount": 10
},
"ContainerRegistryArgs": {
"RegistryServer": "sbm235containerregistry.azurecr.io",
"ImageName": "sqlbuildmanager",
"ImageTag": "latest-vNext",
"RegistryUserName": "sbm235containerregistry"
},
"EventHubArgs": {
"ResourceGroup": "sbm235-rg",
"SubscriptionId": "0d901325-d643-4db7-ae90-58b4e3834629",
"Logging": [
"EssentialOnly",
"ScriptErrors"
]
},
"IdentityArgs": {
"SubscriptionId": "0d901325-d643-4db7-ae90-58b4e3834629",
"TenantId": "16b3c013-d300-468d-ac64-7eda0820b6d3"
},
"Concurrency": 10,
"ConcurrencyType": "Count",
"TimeoutRetryCount": 0,
"DefaultScriptTimeout": 500
}
2 changes: 1 addition & 1 deletion scripts/templates/Batch/build_and_upload_batch.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $frameworkTarget = Invoke-Expression -Command (Join-Path $scriptDir ..\get_targe

Write-Host "Target Framework: $frameworkTarget" -ForegroundColor DarkGreen

Write-Output "Using Batch Account: $batchAcctName" -ForegroundColor DarkGreen
Write-Host "Using Batch Account: $batchAcctName" -ForegroundColor DarkGreen

$winenv =@{
ApplicationName = "SqlBuildManagerWindows"
Expand Down
20 changes: 10 additions & 10 deletions scripts/templates/Modules/database.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module identityResource 'identity.bicep' = {


// SQL Server 'A' resources
resource sqlserverAResource 'Microsoft.Sql/servers@2021-02-01-preview' = {
resource sqlserverAResource 'Microsoft.Sql/servers@2021-11-01' = {
name: '${sqlserverNameVar}-a'
location: location

Expand All @@ -67,7 +67,7 @@ resource sqlserverAResource 'Microsoft.Sql/servers@2021-02-01-preview' = {
}
}

resource sqlserverAFirewallRule 'Microsoft.Sql/servers/firewallRules@2021-02-01-preview' = if(currentIpAddress != '') {
resource sqlserverAFirewallRule 'Microsoft.Sql/servers/firewallRules@2021-11-01' = if(currentIpAddress != '') {
parent: sqlserverAResource
name: '${sqlserverNameVar}A_AllowIp'
properties: {
Expand All @@ -76,7 +76,7 @@ resource sqlserverAFirewallRule 'Microsoft.Sql/servers/firewallRules@2021-02-01-
}
}

resource sqlserverA_VnetRule 'Microsoft.Sql/servers/virtualNetworkRules@2022-11-01-preview' = [for subnet in subnetNamesArray:{
resource sqlserverA_VnetRule 'Microsoft.Sql/servers/virtualNetworkRules@2021-11-01' = [for subnet in subnetNamesArray:{
parent: sqlserverAResource
name: '${sqlserverNameVar}A_${subnet}'
properties: {
Expand All @@ -86,7 +86,7 @@ resource sqlserverA_VnetRule 'Microsoft.Sql/servers/virtualNetworkRules@2022-11-
}
}]

resource sqlserverAResource_Pool 'Microsoft.Sql/servers/elasticPools@2021-02-01-preview' = {
resource sqlserverAResource_Pool 'Microsoft.Sql/servers/elasticPools@2021-11-01' = {
parent: sqlserverAResource
name: '${sqlpoolNameVar}-a'
location: location
Expand All @@ -105,7 +105,7 @@ resource sqlserverAResource_Pool 'Microsoft.Sql/servers/elasticPools@2021-02-01-
}
}

resource sqlserverAResourceDatabase 'Microsoft.Sql/servers/databases@2021-02-01-preview' = [for i in range(1,testDbCountPerServer):{
resource sqlserverAResourceDatabase 'Microsoft.Sql/servers/databases@2021-11-01' = [for i in range(1,testDbCountPerServer):{
parent: sqlserverAResource
name: 'SqlBuildTest${i}'
location: location
Expand All @@ -128,7 +128,7 @@ resource sqlserverAResourceDatabase 'Microsoft.Sql/servers/databases@2021-02-01-


// SQL Server 'B' resources
resource sqlserverBResource 'Microsoft.Sql/servers@2021-02-01-preview' = {
resource sqlserverBResource 'Microsoft.Sql/servers@2021-11-01' = {
name: '${sqlserverNameVar}-b'
location: location
properties: {
Expand All @@ -145,7 +145,7 @@ resource sqlserverBResource 'Microsoft.Sql/servers@2021-02-01-preview' = {
}
}
}
resource sqlserverBFirewallRule 'Microsoft.Sql/servers/firewallRules@2021-02-01-preview' = if(currentIpAddress != '') {
resource sqlserverBFirewallRule 'Microsoft.Sql/servers/firewallRules@2021-11-01' = if(currentIpAddress != '') {
parent: sqlserverBResource
name: '${sqlserverNameVar}B_AllowIp'
properties: {
Expand All @@ -154,7 +154,7 @@ resource sqlserverBFirewallRule 'Microsoft.Sql/servers/firewallRules@2021-02-01-
}
}

resource sqlserverB_VnetRule 'Microsoft.Sql/servers/virtualNetworkRules@2022-11-01-preview' = [for subnet in subnetNamesArray:{
resource sqlserverB_VnetRule 'Microsoft.Sql/servers/virtualNetworkRules@2021-11-01' = [for subnet in subnetNamesArray:{
parent: sqlserverBResource
name: '${sqlserverNameVar}B_${subnet}'
properties: {
Expand All @@ -164,7 +164,7 @@ resource sqlserverB_VnetRule 'Microsoft.Sql/servers/virtualNetworkRules@2022-11-
}
}]

resource sqlserverBResource_Pool 'Microsoft.Sql/servers/elasticPools@2021-02-01-preview' = {
resource sqlserverBResource_Pool 'Microsoft.Sql/servers/elasticPools@2021-11-01' = {
parent: sqlserverBResource
name: '${sqlpoolNameVar}-b'
location: location
Expand All @@ -183,7 +183,7 @@ resource sqlserverBResource_Pool 'Microsoft.Sql/servers/elasticPools@2021-02-01-
}
}

resource sqlserverBResource_Database 'Microsoft.Sql/servers/databases@2021-02-01-preview' = [for i in range(1,testDbCountPerServer):{
resource sqlserverBResource_Database 'Microsoft.Sql/servers/databases@2021-11-01' = [for i in range(1,testDbCountPerServer):{
parent: sqlserverBResource
name: 'SqlBuildTest${i}'
location: location
Expand Down
2 changes: 1 addition & 1 deletion scripts/templates/create_azure_resources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ if($shouldDeploy)
############################################################################################
# Storage Account, Event Hub and Service Bus Topic, Key Vault, Identity and RBAC Assignments
############################################################################################
$ipAddress = (Invoke-WebRequest ifconfig.me/ip).Content.Trim()
$ipAddress = (Invoke-WebRequest https://api.ipify.org/?format=text).Content.Trim()
Write-Host "Using IP Address: $ipAddress" -ForegroundColor Green

$userIdGuid = az ad signed-in-user show -o tsv --query id
Expand Down
12 changes: 9 additions & 3 deletions scripts/templates/key_file_names.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ if($false -eq (Test-Path $path))
{
New-Item -Path $path -ItemType Directory
}
$resolvedPath = Resolve-Path $path

$keyFile = Resolve-Path (Join-Path $path "settingsfilekey.txt")
$keyFile = (Join-Path $resolvedPath "settingsfilekey.txt")
if($false -eq (Test-Path $keyFile))
{
Write-Host "Writing new key file $keyFile" -ForegroundColor DarkGreen
Expand All @@ -19,8 +20,8 @@ if($false -eq (Test-Path $keyFile))
$settingsFileKey | Set-Content -Path $keyFile
}

$unFile = Resolve-Path (Join-Path $path "un.txt")
$pwFile = Resolve-Path (Join-Path $path "pw.txt")
$unFile = (Join-Path $resolvedPath "un.txt")
$pwFile = (Join-Path $resolvedPath "pw.txt")

if(Test-Path $unFile)
{
Expand Down Expand Up @@ -48,6 +49,11 @@ if([string]::IsNullOrWhiteSpace($sqlUserName))

if([string]::IsNullOrWhiteSpace($sqlPassword))
{
Write-Host "Generating new SQL Password" -ForegroundColor DarkGreen
$AESKey = New-Object Byte[] 32
[Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($AESKey)
$sqlPassword = [System.Convert]::ToBase64String($AESKey);

Write-Host "Writing new password file" -ForegroundColor DarkGreen
Write-Host "Saving content of $pwFile" -ForegroundColor DarkGreen
$sqlPassword | Set-Content -Path $pwFile
Expand Down
4 changes: 2 additions & 2 deletions src/AssemblyVersioning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
// 2) Update the installer version to match the AssemblyVersion below.
// These can be found in SqlBuildManager.Setup -> Organize Your Setup -> General Information

[assembly: AssemblyVersion("15.5.1")]
[assembly: AssemblyFileVersion("15.5.1")]
[assembly: AssemblyVersion("15.6.0")]
[assembly: AssemblyFileVersion("15.6.0")]
12 changes: 6 additions & 6 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/runtime:7.0 AS base
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src


Expand All @@ -30,16 +30,16 @@ COPY ["SqlSync.SqlBuild/SqlSync.SqlBuild.csproj", "SqlSync.SqlBuild/SqlSync.SqlB
RUN true
COPY ["SqlBuildManager.ScriptHandling/SqlBuildManager.ScriptHandling.csproj", "SqlBuildManager.ScriptHandling/"]

RUN true
RUN dotnet restore "SqlBuildManager.Console/sbm.csproj"
#RUN true
#RUN dotnet restore "SqlBuildManager.Console/sbm.csproj"


COPY . .
WORKDIR "/src/SqlBuildManager.Console"
RUN dotnet build "sbm.csproj" --configuration Release -f net7.0 -o /app/build -r linux-x64 --self-contained
#RUN dotnet build "sbm.csproj" --configuration Release -f net8.0 -o /app/build -r linux-x64 --self-contained

FROM build AS publish
RUN dotnet publish "sbm.csproj" --configuration Release -f net7.0 -o /app/publish -r linux-x64 --self-contained
RUN dotnet publish "sbm.csproj" --configuration Release -f net8.0 -o /app/publish -r linux-x64 --self-contained

FROM base AS final
WORKDIR /app
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Deterministic>false</Deterministic>
Expand Down Expand Up @@ -60,9 +60,9 @@
</ItemGroup>
<ItemGroup>

<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
Expand Down
55 changes: 55 additions & 0 deletions src/SqlBuildManager.Console.ExternalTest/BatchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1964,5 +1964,60 @@ public async Task CreateBatchPool_Success(string settingsFile, string settingsFi
}
}



[DataRow("run", "TestConfig/settingsfile-batch-windows-queue-keyvault.json", ConcurrencyType.Tag, 2)]
[DataRow("run", "TestConfig/settingsfile-batch-linux-queue-keyvault.json", ConcurrencyType.Tag, 2)]
[DataRow("run", "TestConfig/settingsfile-batch-windows-queue-keyvault-mi.json", ConcurrencyType.Tag, 2)]
[DataRow("run", "TestConfig/settingsfile-batch-linux-queue-keyvault-mi.json", ConcurrencyType.Tag, 2)]
[DataRow("runthreaded", "TestConfig/settingsfile-batch-windows-queue-keyvault.json", ConcurrencyType.MaxPerTag, 5)]
[DataTestMethod]
public void Batch_Queue_SBMSource_KeyVault_NoSettingsFileKey_Success(string batchMethod, string settingsFile, ConcurrencyType concurType, int concurrency)
{
settingsFile = Path.GetFullPath(settingsFile);
string sbmFileName = Path.GetFullPath("SimpleSelect.sbm");
if (!File.Exists(sbmFileName))
{
File.WriteAllBytes(sbmFileName, Properties.Resources.SimpleSelect);
}
string jobName = GetUniqueBatchJobName("batch-sbm-tag");
int startingLine = LogFileCurrentLineCount();

var args = new string[]{
"batch", "enqueue",
"--settingsfile", settingsFile,
"--override" , overrideWithTagFilePath,
"--concurrencytype", concurType.ToString(),
"--jobname", jobName};

RootCommand rootCommand = CommandLineBuilder.SetUp();
Task<int> val = rootCommand.InvokeAsync(args);
val.Wait();
var result = val.Result;

var logFileContents = ReleventLogFileContents(startingLine);
Assert.AreEqual(0, result, StandardExecutionErrorMessage(logFileContents));

args = new string[]{
"--loglevel", "debug",
"batch", batchMethod,
"--settingsfile", settingsFile,
"--override", overrideWithTagFilePath,
"--packagename", sbmFileName,
"--concurrencytype", concurType.ToString(),
"--concurrency", concurrency.ToString(),
"--jobname", jobName,
"--unittest",
"--monitor",
"--stream" };


val = rootCommand.InvokeAsync(args);
val.Wait();
result = val.Result;

logFileContents = ReleventLogFileContents(startingLine);
Assert.AreEqual(0, result, StandardExecutionErrorMessage(logFileContents));
}
}
}
Loading

0 comments on commit 1e6612d

Please sign in to comment.