Skip to content

Commit

Permalink
- *UPDATED:* Now targets .NET 8.0
Browse files Browse the repository at this point in the history
- *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
  • Loading branch information
mmckechney committed Dec 1, 2023
1 parent 7c51110 commit 78ee834
Show file tree
Hide file tree
Showing 52 changed files with 623 additions and 245 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
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# 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

### 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/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")]
8 changes: 4 additions & 4 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 Down Expand Up @@ -36,10 +36,10 @@ 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
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup>
<NoWarn>1701;1702;NU1608</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<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
157 changes: 156 additions & 1 deletion src/SqlBuildManager.Console.UnitTest/CommandLineArgsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,161 @@ public void Duplicate_ArgumentCheck_Test()
}
}
}


[TestMethod]
public void WorkerInit_success_with_keyfile()
{
var tmpJsonFile = Path.GetTempFileName();
var tmpSecretFile = Path.GetTempFileName();
try
{

File.WriteAllBytes(tmpJsonFile, Properties.Resources.batch_settings_encrypted);
File.WriteAllText(tmpSecretFile, Properties.Resources.settingsfilekey);
var cmdLine = new CommandLineArgs();
cmdLine.SettingsFileKey = tmpSecretFile;
cmdLine.SettingsFile = tmpJsonFile;
(bool success, cmdLine) = Worker.Init(cmdLine, false);

Assert.IsTrue(success);
Assert.IsTrue(cmdLine.Decrypted);
Assert.IsTrue(cmdLine.AuthenticationArgs.Password.EndsWith("="));
}
finally
{
if (File.Exists(tmpJsonFile))
File.Delete(tmpJsonFile);

if (File.Exists(tmpSecretFile))
File.Delete(tmpSecretFile);
}
}

[TestMethod]
public void WorkerInit_fail_with_bad_keyfile()
{
var tmpJsonFile = Path.GetTempFileName();
var tmpSecretFile = Path.GetTempFileName();
try
{

File.WriteAllBytes(tmpJsonFile, Properties.Resources.batch_settings_encrypted);
File.WriteAllText(tmpSecretFile, "QDQE@Q!EQQEQD#EQ#DQ#DQ#D#DQ#DQ");
var cmdLine = new CommandLineArgs();
cmdLine.SettingsFileKey = tmpSecretFile;
cmdLine.SettingsFile = tmpJsonFile;
(bool success, cmdLine) = Worker.Init(cmdLine, false);

Assert.IsFalse(success);
Assert.IsFalse(cmdLine.Decrypted);
}
finally
{
if (File.Exists(tmpJsonFile))
File.Delete(tmpJsonFile);

if (File.Exists(tmpSecretFile))
File.Delete(tmpSecretFile);
}

}

[TestMethod]
public void WorkerInit_success_with_keystring()
{
var tmpJsonFile = Path.GetTempFileName();
try
{

File.WriteAllBytes(tmpJsonFile, Properties.Resources.batch_settings_encrypted);
var cmdLine = new CommandLineArgs();
cmdLine.SettingsFileKey = Properties.Resources.settingsfilekey;
cmdLine.SettingsFile = tmpJsonFile;
(bool success, cmdLine) = Worker.Init(cmdLine, false);

Assert.IsTrue(success);
Assert.IsTrue(cmdLine.Decrypted);
Assert.IsTrue(cmdLine.AuthenticationArgs.Password.EndsWith("="));
}
finally
{
if (File.Exists(tmpJsonFile))
File.Delete(tmpJsonFile);
}

}

[TestMethod]
public void WorkerInit_decrypt_success_and_keyvault_fail()
{
var tmpJsonFile = Path.GetTempFileName();
try
{

File.WriteAllBytes(tmpJsonFile, Properties.Resources.batch_settings_encrypted);
var cmdLine = new CommandLineArgs();
cmdLine.SettingsFileKey = Properties.Resources.settingsfilekey;
cmdLine.SettingsFile = tmpJsonFile;
cmdLine.KeyVaultName = "doesnotexistawtgfs";
(bool success, cmdLine) = Worker.Init(cmdLine, false);

Assert.IsFalse(success);
Assert.IsTrue(cmdLine.Decrypted);
Assert.IsTrue(cmdLine.AuthenticationArgs.Password.EndsWith("="));
}
finally
{
if (File.Exists(tmpJsonFile))
File.Delete(tmpJsonFile);
}

}
[TestMethod]
public void WorkerInit_fail_with_bad_keystring()
{
var tmpJsonFile = Path.GetTempFileName();
try
{

File.WriteAllBytes(tmpJsonFile, Properties.Resources.batch_settings_encrypted);
var cmdLine = new CommandLineArgs();
cmdLine.SettingsFileKey = "XXXXX";
cmdLine.SettingsFile = tmpJsonFile;
(bool success, cmdLine) = Worker.Init(cmdLine, false);
Assert.IsFalse(success);
Assert.IsFalse(cmdLine.Decrypted);
}
finally
{
if (File.Exists(tmpJsonFile))
File.Delete(tmpJsonFile);
}

}

[TestMethod]
public void WorkerInit_fail_with_missing_keystring()
{
var tmpJsonFile = Path.GetTempFileName();
try
{

File.WriteAllBytes(tmpJsonFile, Properties.Resources.batch_settings_encrypted);
var cmdLine = new CommandLineArgs();
cmdLine.SettingsFile = tmpJsonFile;
(bool success, cmdLine) = Worker.Init(cmdLine, false);

Assert.IsFalse(success);
Assert.IsFalse(cmdLine.Decrypted);
}
finally
{
if (File.Exists(tmpJsonFile))
File.Delete(tmpJsonFile);
}

}


}
}
Loading

0 comments on commit 78ee834

Please sign in to comment.