Skip to content

Commit

Permalink
Migrate to .NET 6.0 (#1192)
Browse files Browse the repository at this point in the history
- Update global.json
- Update target frameworks to net6.0
  - Dicom server
  - Dicom cast
  - Scale testing
- Update Azure Functions to v4
- Update docker images
- Update ARM templates
- Address analyzer issues
  - Use AsSpan over Substring
  - Use PascalCase for template placeholders
  - (Ignored) Use logging delegates for performance
  - (Somewhat ignored) Ensure message templates are constant
- Update NuGet packages
- Update healthcare-shared-components due to SQL tooling
  • Loading branch information
wsugarman authored Nov 17, 2021
1 parent 06a8c0b commit 88194df
Show file tree
Hide file tree
Showing 82 changed files with 302 additions and 233 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ dotnet_diagnostic.CA1032.severity = suggestion # Implement standard exception co
dotnet_diagnostic.CA1054.severity = error # URI parameters should not be strings
dotnet_diagnostic.CA1305.severity = suggestion # Specify IFormatProvider
dotnet_diagnostic.CA1716.severity = warning # Identifiers should not match keywords
dotnet_diagnostic.CA1848.severity = none # Do not encourage LoggerMessage delegates in every instance
dotnet_diagnostic.CA2007.severity = suggestion # Do not directly await a Task

# Code Style Rules
Expand All @@ -215,6 +216,7 @@ file_header_template = ---------------------------------------------------------
dotnet_diagnostic.IDE0073.severity = warning

# C++ Files

[*.{cpp,h,in}]
curly_bracket_next_line = true
indent_brace_style = Allman
Expand Down
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ updates:
timezone: "America/Los_Angeles"
open-pull-requests-limit: 30

- package-ecosystem: "nuget"
directory: "/tools/scale-testing"
schedule:
interval: "daily"
time: "09:00"
timezone: "America/Los_Angeles"
open-pull-requests-limit: 30

- package-ecosystem: "docker"
directory: "/"
schedule:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ jobs:
uses: actions/[email protected]
if: ${{ matrix.language == 'csharp' }}

# For Az Func and SQL Code-Gen
- name: 'Setup dotnet 3.1.x'
# SQL Code-Gen (TODO: Delete once shared components moves to .NET 6.0)
- name: 'Setup dotnet 5.x'
uses: actions/[email protected]
if: ${{ matrix.language == 'csharp' }}
with:
dotnet-version: '3.1.x'
dotnet-version: '5.x'

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
8 changes: 0 additions & 8 deletions CredScanSuppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@
"placeholder": "globalAdminServicePrincipal",
"_justification": "Service principal for local testing."
},
{
"placeholder": "Oc+osXvPQ172LU1flk53w6GFM7ixfjk9NELrkLtBt+k0ML585ECReA==",
"_justification": "Master key for Azure Function while using docker-compose."
},
{
"placeholder": "cP0rhNdD/l9Dli+kEPQwupVqfTjksqK0dmMrZo/63mD0u0ezUrRl8Q==",
"_justification": "Function key for Azure Function while using docker-compose."
},
{
"placeholder": "123!@#passforCI#$",
"_justification": "Test admin password for testing SQL server using docker during CI"
Expand Down
20 changes: 6 additions & 14 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project>

<PropertyGroup>
<Authors>Microsoft Health Team</Authors>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<AspNetApiPackageVersion>5.0.0</AspNetApiPackageVersion>
<Authors>Microsoft Health Team</Authors>
<Company>Microsoft Corporation</Company>
<Copyright>Copyright © Microsoft Corporation. All rights reserved.</Copyright>
<Deterministic>true</Deterministic>
Expand All @@ -11,28 +12,19 @@
<FhirServerPackageVersion>2.0.55</FhirServerPackageVersion>
<FoDicomVersion>4.0.8</FoDicomVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<HealthcareSharedPackageVersion>3.2.39</HealthcareSharedPackageVersion>
<HealthcareSharedPackageVersion>3.2.44</HealthcareSharedPackageVersion>
<HighEntropyVA>true</HighEntropyVA>
<Hl7FhirPackageVersion>3.3.0</Hl7FhirPackageVersion>
<Hl7FhirPackageVersion>3.6.0</Hl7FhirPackageVersion>
<LangVersion>Latest</LangVersion>
<NetCoreApp3PackageVersion>3.1.20</NetCoreApp3PackageVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Product>Microsoft Health</Product>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<SdkPackageVersion>5.0.0</SdkPackageVersion>
<SdkPackageVersion>6.0.0</SdkPackageVersion>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>

<Choose>
<When Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PropertyGroup>
<SdkPackageVersion>$(NetCoreApp3PackageVersion)</SdkPackageVersion>
</PropertyGroup>
</When>
</Choose>

<Choose>
<When Condition="$(MSBuildProjectName.Contains('Test'))">
<PropertyGroup>
Expand All @@ -42,7 +34,7 @@
</When>
<Otherwise>
<PropertyGroup>
<AnalysisLevel>5.0</AnalysisLevel>
<AnalysisLevel>6.0</AnalysisLevel>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<IsPackable>true</IsPackable>
</PropertyGroup>
Expand Down
8 changes: 4 additions & 4 deletions Microsoft.Health.Dicom.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Health.Dicom.Func
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Health.Dicom.Metadata", "src\Microsoft.Health.Dicom.Metadata\Microsoft.Health.Dicom.Metadata.csproj", "{1E91CFB9-45D0-4742-A23D-0FF4E2D73A73}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Health.Dicom.Operations", "src\Microsoft.Health.Dicom.Operations\Microsoft.Health.Dicom.Operations.csproj", "{C71E1BDD-2B8E-47F3-8801-AE95F5F39941}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Health.Dicom.Operations", "src\Microsoft.Health.Dicom.Operations\Microsoft.Health.Dicom.Operations.csproj", "{C71E1BDD-2B8E-47F3-8801-AE95F5F39941}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Health.Dicom.Operations.Client", "src\Microsoft.Health.Dicom.Operations.Client\Microsoft.Health.Dicom.Operations.Client.csproj", "{F896C916-144F-412E-B3DE-C9D0D9B8EDD1}"
EndProject
Expand Down Expand Up @@ -147,20 +147,20 @@ Global
{E15123F6-5A28-4D86-A28D-30FCB699B9EE} = {176641B3-297C-4E04-A83D-8F80F80485E8}
{FA0484A7-AA0C-4CC6-A75F-1D6B23DD847D} = {176641B3-297C-4E04-A83D-8F80F80485E8}
{BB88616C-6208-43D0-B9EF-79FC0652A151} = {176641B3-297C-4E04-A83D-8F80F80485E8}
{1E91CFB9-45D0-4742-A23D-0FF4E2D73A73} = {176641B3-297C-4E04-A83D-8F80F80485E8}
{C71E1BDD-2B8E-47F3-8801-AE95F5F39941} = {176641B3-297C-4E04-A83D-8F80F80485E8}
{F896C916-144F-412E-B3DE-C9D0D9B8EDD1} = {176641B3-297C-4E04-A83D-8F80F80485E8}
{3D5D7F69-C766-450A-AA3D-00A50E115E9C} = {176641B3-297C-4E04-A83D-8F80F80485E8}
{3D679950-A578-45AD-AF89-FAF89580375F} = {176641B3-297C-4E04-A83D-8F80F80485E8}
{1E91CFB9-45D0-4742-A23D-0FF4E2D73A73} = {176641B3-297C-4E04-A83D-8F80F80485E8}
{0F57D85C-8FA4-4DBE-BF44-1CA5109125A5} = {176641B3-297C-4E04-A83D-8F80F80485E8}
{DFB41ECC-726C-4DBA-8AD3-17FB0A2546CA} = {8C9A0050-5D22-4398-9F93-DDCD80B3BA51}
{A88DAB6A-BE0E-41BD-AB48-D1156FB6443C} = {176641B3-297C-4E04-A83D-8F80F80485E8}
{ECC018C1-BFA8-44BE-B560-ACB05CA57251} = {176641B3-297C-4E04-A83D-8F80F80485E8}
{BFB96311-9B1A-41C1-ABF1-4F6522660084} = {176641B3-297C-4E04-A83D-8F80F80485E8}
{1D0ECFDA-2AF2-4796-995D-A7C6E18C9CD1} = {8C9A0050-5D22-4398-9F93-DDCD80B3BA51}
{C71E1BDD-2B8E-47F3-8801-AE95F5F39941} = {176641B3-297C-4E04-A83D-8F80F80485E8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E370FB31-CF95-47D1-B1E1-863A77973FF8}
RESX_SortFileContentOnSave = True
SolutionGuid = {E370FB31-CF95-47D1-B1E1-863A77973FF8}
EndGlobalSection
EndGlobal
8 changes: 4 additions & 4 deletions build/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ parameters:

steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
displayName: 'Use .NET sdk'
inputs:
useGlobalJson: true

# For Az Func and SQL Code-Gen
# SQL Code-Gen (TODO: Delete once shared components moves to .NET 6.0)
- task: UseDotNet@2
displayName: 'Use .NET Core 3.1.x SDK'
displayName: 'Use .NET 5.x SDK'
inputs:
version: '3.1.x'
version: '5.x'

- task: DotNetCoreCLI@2
displayName: 'dotnet build $(buildConfiguration)'
Expand Down
4 changes: 2 additions & 2 deletions converter/dicom-cast/build/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Start from the sdk image
FROM mcr.microsoft.com/dotnet/sdk:5.0.402-alpine3.13@sha256:f08db3184fc8fbb12dd4a9d12eb2e3c0a36ca60a4dd13759edde22605fbd00bd AS build
FROM mcr.microsoft.com/dotnet/sdk:6.0.100-alpine3.14@sha256:1d9d66775f0d67cb68af9c7a083d22b576ea96f3f7a6893660d48f536b73e59f AS build

# Set the working directory to where the source is located
WORKDIR /dicom-cast/src
Expand All @@ -12,7 +12,7 @@ RUN dotnet build "./converter/dicom-cast/src/Microsoft.Health.DicomCast.Hosting/
RUN dotnet publish "./converter/dicom-cast/src/Microsoft.Health.DicomCast.Hosting/Microsoft.Health.DicomCast.Hosting.csproj" -c Release -o "/.build" --no-build

# Build the runtime image
FROM mcr.microsoft.com/dotnet/aspnet:5.0.11-alpine3.13@sha256:2b67665d62471d30de99340361d516d4555a9276cb4ff78fb09db784384b1574 AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:6.0.0-alpine3.14@sha256:1c893087b6d9cfe54d025dfeeda385358e79dcedd9a16f6ccdc9e5aa080db0f6 AS runtime

RUN set -x && \
addgroup nonroot && \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ public async Task ProcessAsync(TimeSpan pollIntervalDuringCatchup, CancellationT
if (!(changeFeedEntry.Action == ChangeFeedAction.Create && changeFeedEntry.State == ChangeFeedState.Deleted))
{
await _fhirTransactionPipeline.ProcessAsync(changeFeedEntry, cancellationToken);
_logger.LogInformation("Successfully processed DICOM event with SequenceID: {sequenceId}", changeFeedEntry.Sequence);
_logger.LogInformation("Successfully processed DICOM event with SequenceID: {SequenceId}", changeFeedEntry.Sequence);
}
else
{
_logger.LogInformation("Skip DICOM event with SequenceId {sequenceId} due to deletion before processing creation.", changeFeedEntry.Sequence);
_logger.LogInformation("Skip DICOM event with SequenceId {SequenceId} due to deletion before processing creation.", changeFeedEntry.Sequence);
}
}
catch (Exception ex)
Expand Down Expand Up @@ -114,7 +114,7 @@ await _exceptionStore.WriteExceptionAsync(
errorType,
cancellationToken);

_logger.LogError("Failed to process DICOM event with SequenceID: {sequenceId}, StudyUid: {studyUid}, SeriesUid: {seriesUid}, instanceUid: {instanceUid} and will not be retried further. Continuing to next event.", changeFeedEntry.Sequence, studyUid, seriesUid, instanceUid);
_logger.LogError("Failed to process DICOM event with SequenceID: {SequenceId}, StudyUid: {StudyUid}, SeriesUid: {SeriesUid}, instanceUid: {InstanceUid} and will not be retried further. Continuing to next event.", changeFeedEntry.Sequence, studyUid, seriesUid, instanceUid);
}
else
{
Expand All @@ -127,7 +127,7 @@ await _exceptionStore.WriteExceptionAsync(

await _syncStateService.UpdateSyncStateAsync(newSyncState, cancellationToken);

_logger.LogInformation("Processed DICOM events sequenced {sequenceId}-{maxSequence}.", state.SyncedSequence + 1, maxSequence);
_logger.LogInformation("Processed DICOM events sequenced {SequenceId}-{MaxSequence}.", state.SyncedSequence + 1, maxSequence);

state = newSyncState;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Common primitives and utilities used by Microsoft's DICOM Cast APIs.</Description>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ensure.That" Version="10.1.0" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.18.0" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.19.0" />
<PackageReference Include="Microsoft.Azure.KeyVault" Version="2.3.2" />
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="$(SdkPackageVersion)" />
Expand All @@ -15,7 +15,7 @@
<PackageReference Include="Microsoft.Extensions.Hosting" Version="$(SdkPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="$(SdkPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(SdkPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.18.0" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.19.0" />
<PackageReference Include="Microsoft.Health.Extensions.DependencyInjection" Version="$(HealthcareSharedPackageVersion)" />
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="5.2.9" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public async Task IntializeDataStoreAsync(CloudTableClient client)
CloudTable table = client.GetTableReference(tableName);
if (await table.CreateIfNotExistsAsync())
{
_logger.LogInformation("Created Table named: {0}", tableName);
_logger.LogInformation("Created Table named '{TableName}'", tableName);
}
else
{
_logger.LogInformation("Table {0} already exists", tableName);
_logger.LogInformation("Table '{TableName}' already exists", tableName);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ public async Task WriteRetryableExceptionAsync(ChangeFeedEntry changeFeedEntry,
try
{
await table.ExecuteAsync(operation, cancellationToken);
_logger.LogInformation("Retryable error when processsing changefeed entry: {ChangeFeedSequence} for DICOM instance with StudyUID: {StudyUID}, SeriesUID: {SeriesUID}, InstanceUID: {InstanceUID}. Tried {retryNum} time(s). Waiting {milliseconds} milliseconds . Stored into table: {Table} in table storage.", changeFeedSequence, studyUid, seriesUid, instanceUid, retryNum, nextDelayTimeSpan.TotalMilliseconds, Constants.TransientRetryTableName);
_logger.LogInformation("Retryable error when processsing changefeed entry: {ChangeFeedSequence} for DICOM instance with StudyUID: {StudyUID}, SeriesUID: {SeriesUID}, InstanceUID: {InstanceUID}. Tried {RetryNum} time(s). Waiting {Milliseconds} milliseconds . Stored into table: {Table} in table storage.", changeFeedSequence, studyUid, seriesUid, instanceUid, retryNum, nextDelayTimeSpan.TotalMilliseconds, Constants.TransientRetryTableName);
}
catch
{
_logger.LogInformation("Retryable error when processsing changefeed entry: {ChangeFeedSequence} for DICOM instance with StudyUID: {StudyUID}, SeriesUID: {SeriesUID}, InstanceUID: {InstanceUID}. Tried {retryNum} time(s). Failed to store to table storage.", changeFeedSequence, studyUid, seriesUid, instanceUid, retryNum);
_logger.LogInformation("Retryable error when processsing changefeed entry: {ChangeFeedSequence} for DICOM instance with StudyUID: {StudyUID}, SeriesUID: {SeriesUID}, InstanceUID: {InstanceUID}. Tried {RetryNum} time(s). Failed to store to table storage.", changeFeedSequence, studyUid, seriesUid, instanceUid, retryNum);
throw;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Azure Cosmos DB table storage utilities for Microsoft's DICOM Cast APIs.</Description>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
10 changes: 3 additions & 7 deletions docker/functions/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@

# To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft.com/azure-functions/dotnet:3.0-appservice
FROM mcr.microsoft.com/azure-functions/dotnet:3.3.1@sha256:6b05f6aa60767db3a295064b146f0e5b7a13ef967261085aa723feea3025ed36 AS az-func-runtime
FROM mcr.microsoft.com/azure-functions/dotnet:4.0.1.16816@sha256:2c18c4ca6ad982257e9023161329c38be6d9d494bc48a6aae15ef43cc8f7ea5d AS az-func-runtime
ENV AzureFunctionsJobHost__Logging__Console__IsEnabled=true \
AzureWebJobsScriptRoot=/home/site/wwwroot

# Copy the DICOM Server repository and build the Azure Functions project
# Note: While the latest .NET SDK is used for building, Azure Functions build target requires .NET Core 3.1 to be installed
FROM mcr.microsoft.com/dotnet/sdk:5.0.402-alpine3.13@sha256:f08db3184fc8fbb12dd4a9d12eb2e3c0a36ca60a4dd13759edde22605fbd00bd AS build
FROM mcr.microsoft.com/dotnet/sdk:6.0.100-alpine3.14@sha256:1d9d66775f0d67cb68af9c7a083d22b576ea96f3f7a6893660d48f536b73e59f AS build
ARG BUILD_CONFIGURATION=Release
RUN set -x && \
apk add --no-cache bash && \
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -Channel 3.1 -InstallDir /usr/share/dotnet
WORKDIR /dicom-server
COPY . .
WORKDIR /dicom-server/src/Microsoft.Health.Dicom.Functions
Expand All @@ -24,7 +20,7 @@ RUN dotnet build "Microsoft.Health.Dicom.Functions.csproj" -c $BUILD_CONFIGURATI
# Publish the Azure Functions from the build
FROM build as publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "Microsoft.Health.Dicom.Functions.csproj" -c $BUILD_CONFIGURATION --no-build --framework netcoreapp3.1 -o /home/site/wwwroot
RUN dotnet publish "Microsoft.Health.Dicom.Functions.csproj" -c $BUILD_CONFIGURATION --no-build --framework net6.0 -o /home/site/wwwroot

# Copy the published application
FROM az-func-runtime AS dicom-az-func
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "5.0.402"
"version": "6.0.100"
}
}
Loading

0 comments on commit 88194df

Please sign in to comment.