From 48fd239c08fe77f37032f4af1449dddc16f75c52 Mon Sep 17 00:00:00 2001 From: odidev <odidev@puresoftware.com> Date: Fri, 24 Mar 2023 10:50:32 +0000 Subject: [PATCH 1/6] Add test support for Amd64 and Arm64 Signed-off-by: odidev <odidev@puresoftware.com> --- ...verlessMicroservices.FunctionApp.Drivers.csproj | 9 +++++---- ...sMicroservices.FunctionApp.Orchestrators.csproj | 13 +++++++------ ...lessMicroservices.FunctionApp.Passengers.csproj | 10 +++++----- ...erverlessMicroservices.FunctionApp.Trips.csproj | 14 ++++++++------ .../ServerlessMicroservices.Models.csproj | 2 +- .../ServerlessMicroservices.Seeder.csproj | 2 +- .../ServerlessMicroservices.Shared.csproj | 2 +- 7 files changed, 28 insertions(+), 24 deletions(-) diff --git a/dotnet/ServerlessMicroservices.FunctionApp.Drivers/ServerlessMicroservices.FunctionApp.Drivers.csproj b/dotnet/ServerlessMicroservices.FunctionApp.Drivers/ServerlessMicroservices.FunctionApp.Drivers.csproj index 30aa239..ba768bd 100644 --- a/dotnet/ServerlessMicroservices.FunctionApp.Drivers/ServerlessMicroservices.FunctionApp.Drivers.csproj +++ b/dotnet/ServerlessMicroservices.FunctionApp.Drivers/ServerlessMicroservices.FunctionApp.Drivers.csproj @@ -1,12 +1,13 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>netcoreapp3.1</TargetFramework> - <AzureFunctionsVersion>v3</AzureFunctionsVersion> + <TargetFramework>net6.0</TargetFramework> + <AzureFunctionsVersion>v4</AzureFunctionsVersion> + <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> </PropertyGroup> <ItemGroup> <!--<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />--> <!--<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.12" />--> - <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" /> + <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\ServerlessMicroservices.Models\ServerlessMicroservices.Models.csproj" /> @@ -24,4 +25,4 @@ <ItemGroup> <Folder Include="Properties\" /> </ItemGroup> -</Project> \ No newline at end of file +</Project> diff --git a/dotnet/ServerlessMicroservices.FunctionApp.Orchestrators/ServerlessMicroservices.FunctionApp.Orchestrators.csproj b/dotnet/ServerlessMicroservices.FunctionApp.Orchestrators/ServerlessMicroservices.FunctionApp.Orchestrators.csproj index 7dccd57..51c6e05 100644 --- a/dotnet/ServerlessMicroservices.FunctionApp.Orchestrators/ServerlessMicroservices.FunctionApp.Orchestrators.csproj +++ b/dotnet/ServerlessMicroservices.FunctionApp.Orchestrators/ServerlessMicroservices.FunctionApp.Orchestrators.csproj @@ -1,12 +1,13 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>netcoreapp3.1</TargetFramework> - <AzureFunctionsVersion>v3</AzureFunctionsVersion> + <TargetFramework>net6.0</TargetFramework> + <AzureFunctionsVersion>v4</AzureFunctionsVersion> + <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> </PropertyGroup> <ItemGroup> - <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.6.0" /> - <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.0.0" /> - <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" /> + <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.6.1" /> + <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage.Queues" Version="5.0.0" /> + <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" /> </ItemGroup> <ItemGroup> <None Update="host.json"> @@ -23,4 +24,4 @@ <ItemGroup> <Folder Include="Properties\" /> </ItemGroup> -</Project> \ No newline at end of file +</Project> diff --git a/dotnet/ServerlessMicroservices.FunctionApp.Passengers/ServerlessMicroservices.FunctionApp.Passengers.csproj b/dotnet/ServerlessMicroservices.FunctionApp.Passengers/ServerlessMicroservices.FunctionApp.Passengers.csproj index c1ffded..5c6b869 100644 --- a/dotnet/ServerlessMicroservices.FunctionApp.Passengers/ServerlessMicroservices.FunctionApp.Passengers.csproj +++ b/dotnet/ServerlessMicroservices.FunctionApp.Passengers/ServerlessMicroservices.FunctionApp.Passengers.csproj @@ -1,11 +1,11 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>netcoreapp3.1</TargetFramework> - <AzureFunctionsVersion>v3</AzureFunctionsVersion> - <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> + <TargetFramework>net6.0</TargetFramework> + <AzureFunctionsVersion>v4</AzureFunctionsVersion> + <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> </PropertyGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" /> + <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\ServerlessMicroservices.Models\ServerlessMicroservices.Models.csproj" /> @@ -20,4 +20,4 @@ <CopyToPublishDirectory>Never</CopyToPublishDirectory> </None> </ItemGroup> -</Project> \ No newline at end of file +</Project> diff --git a/dotnet/ServerlessMicroservices.FunctionApp.Trips/ServerlessMicroservices.FunctionApp.Trips.csproj b/dotnet/ServerlessMicroservices.FunctionApp.Trips/ServerlessMicroservices.FunctionApp.Trips.csproj index 0fa7f0a..549d578 100644 --- a/dotnet/ServerlessMicroservices.FunctionApp.Trips/ServerlessMicroservices.FunctionApp.Trips.csproj +++ b/dotnet/ServerlessMicroservices.FunctionApp.Trips/ServerlessMicroservices.FunctionApp.Trips.csproj @@ -1,13 +1,15 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>netcoreapp3.1</TargetFramework> - <AzureFunctionsVersion>v3</AzureFunctionsVersion> + <TargetFramework>net6.0</TargetFramework> + <AzureFunctionsVersion>v4</AzureFunctionsVersion> + <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> </PropertyGroup> <ItemGroup> - <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventGrid" Version="3.0.0" /> + <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventGrid" Version="3.1.0" /> <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SignalRService" Version="1.6.0" /> - <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.0.0" /> - <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" /> + <PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="6.0.2" /> + <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage.Blobs" Version="5.0.0" /> + <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\ServerlessMicroservices.Models\ServerlessMicroservices.Models.csproj" /> @@ -25,4 +27,4 @@ <ItemGroup> <Folder Include="Properties\" /> </ItemGroup> -</Project> \ No newline at end of file +</Project> diff --git a/dotnet/ServerlessMicroservices.Models/ServerlessMicroservices.Models.csproj b/dotnet/ServerlessMicroservices.Models/ServerlessMicroservices.Models.csproj index 3271307..3644243 100644 --- a/dotnet/ServerlessMicroservices.Models/ServerlessMicroservices.Models.csproj +++ b/dotnet/ServerlessMicroservices.Models/ServerlessMicroservices.Models.csproj @@ -1,7 +1,7 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>netcoreapp3.1</TargetFramework> + <TargetFramework>net6.0</TargetFramework> </PropertyGroup> <ItemGroup> diff --git a/dotnet/ServerlessMicroservices.Seeder/ServerlessMicroservices.Seeder.csproj b/dotnet/ServerlessMicroservices.Seeder/ServerlessMicroservices.Seeder.csproj index f278268..e8eae2a 100644 --- a/dotnet/ServerlessMicroservices.Seeder/ServerlessMicroservices.Seeder.csproj +++ b/dotnet/ServerlessMicroservices.Seeder/ServerlessMicroservices.Seeder.csproj @@ -2,7 +2,7 @@ <PropertyGroup> <OutputType>Exe</OutputType> - <TargetFramework>netcoreapp3.1</TargetFramework> + <TargetFramework>net6.0</TargetFramework> </PropertyGroup> <ItemGroup> diff --git a/dotnet/ServerlessMicroservices.Shared/ServerlessMicroservices.Shared.csproj b/dotnet/ServerlessMicroservices.Shared/ServerlessMicroservices.Shared.csproj index 424cdc2..222ba4b 100644 --- a/dotnet/ServerlessMicroservices.Shared/ServerlessMicroservices.Shared.csproj +++ b/dotnet/ServerlessMicroservices.Shared/ServerlessMicroservices.Shared.csproj @@ -1,7 +1,7 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>netcoreapp3.1</TargetFramework> + <TargetFramework>net6.0</TargetFramework> </PropertyGroup> <ItemGroup> From ef4e1bf05cb4cce7a6082c1997e0d23a2a436732 Mon Sep 17 00:00:00 2001 From: Daniel Larsen <dalars@microsoft.com> Date: Mon, 17 Apr 2023 15:29:09 +1200 Subject: [PATCH 2/6] run-local fix and update workflow --- .github/workflows/dotnet.yml | 2 +- .gitignore | 1 + scripts/run-local.ps1 | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index d6c2efc..a82f80a 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -18,7 +18,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 5.0.x + dotnet-version: 6.0.x - name: Build, restore, test shell: pwsh run: ./pipelines/build-dotnet.ps1 diff --git a/.gitignore b/.gitignore index 5ebd458..a3668de 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ local.settings.json test/settings.example.dan.js __azurite__ +__azurite_* diff --git a/scripts/run-local.ps1 b/scripts/run-local.ps1 index 5fea02c..584ae7b 100644 --- a/scripts/run-local.ps1 +++ b/scripts/run-local.ps1 @@ -1,6 +1,5 @@ # NOTE: Install latest versions of Node and NPM: https://nodejs.org/en/download/ # NOTE: Install latest version of func CLI: https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local -# NOTE: Start Azure Storage Emulator https://docs.microsoft.com/en-us/azure/storage/common/storage-use-emulator $ErrorActionPreference = 'Stop' From b839472a4642d6d520a1b7975edd20f91f1517bb Mon Sep 17 00:00:00 2001 From: odidev <odidev@puresoftware.com> Date: Wed, 19 Apr 2023 11:08:59 +0000 Subject: [PATCH 3/6] Add test support for Arm64 platform Signed-off-by: odidev <odidev@puresoftware.com> --- .github/workflows/dotnet.yml | 33 ++++++++++++++++++- .github/workflows/nodejs.yml | 30 +++++++++++++++++ .github/workflows/spa.yml | 31 +++++++++++++++++ ...ssMicroservices.FunctionApp.Drivers.csproj | 9 ++--- ...oservices.FunctionApp.Orchestrators.csproj | 13 ++++---- ...icroservices.FunctionApp.Passengers.csproj | 10 +++--- ...lessMicroservices.FunctionApp.Trips.csproj | 14 ++++---- .../ServerlessMicroservices.Models.csproj | 2 +- .../ServerlessMicroservices.Seeder.csproj | 2 +- .../ServerlessMicroservices.Shared.csproj | 2 +- 10 files changed, 121 insertions(+), 25 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index d6c2efc..87d8df7 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -18,7 +18,38 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 5.0.x + dotnet-version: 6.0.x - name: Build, restore, test shell: pwsh run: ./pipelines/build-dotnet.ps1 + + arm64_job: + name: Build and Test for arm64 + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: Set up QEMU + id: qemu + uses: docker/setup-qemu-action@v1 + - name: Install and Run tests + run: | + docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws \ + arm64v8/ubuntu:20.04 \ + bash -exc 'apt-get update && \ + apt install sudo -y && \ + sudo apt clean && \ + sudo apt update && \ + sudo apt install --fix-missing && \ + sudo apt update --fix-missing && \ + sudo apt install wget -y && \ + wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && \ + sudo chmod +x ./dotnet-install.sh && \ + ./dotnet-install.sh --channel 6.0 && \ + export DOTNET_ROOT=$HOME/.dotnet && \ + export PATH=$PATH:$HOME/.dotnet:$HOME/.dotnet/tools && \ + export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 && \ + dotnet --version && \ + cd dotnet && \ + dotnet restore && \ + dotnet build -c Release && \ + dotnet test -c Release' diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 2941c4a..4673016 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -31,3 +31,33 @@ jobs: cache-dependency-path: ./nodejs/serverless-microservices-functionapp-triparchiver - run: npm install - run: npm run pack + + arm64_job: + name: Build and Test for arm64 + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: Set up QEMU + id: qemu + uses: docker/setup-qemu-action@v1 + - name: Install and Run tests + run: | + docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws \ + arm64v8/ubuntu:20.04 \ + bash -exc 'apt-get update && \ + apt install sudo -y && \ + sudo apt clean && \ + sudo apt update && \ + sudo apt install --fix-missing && \ + sudo apt update --fix-missing && \ + sudo apt install curl -y && \ + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash && \ + export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || + printf %s "${XDG_CONFIG_HOME}/nvm")" && \ + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \ + nvm install node && \ + node --version && \ + npm --version && \ + cd nodejs/serverless-microservices-functionapp-triparchiver && \ + npm install && \ + npm run pack' diff --git a/.github/workflows/spa.yml b/.github/workflows/spa.yml index 6e99515..f7f603e 100644 --- a/.github/workflows/spa.yml +++ b/.github/workflows/spa.yml @@ -31,3 +31,34 @@ jobs: cache-dependency-path: ./web/serverless-microservices-web - run: npm install - run: npm run build + + arm64_job: + name: Build and Test for arm64 + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: Set up QEMU + id: qemu + uses: docker/setup-qemu-action@v1 + - name: Install and Run tests + run: | + docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws \ + arm64v8/ubuntu:20.04 \ + bash -exc 'apt-get update && \ + apt install sudo -y && \ + sudo apt clean && \ + sudo apt update && \ + sudo apt install --fix-missing && \ + sudo apt update --fix-missing && \ + sudo apt install curl -y && \ + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash && \ + export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || + printf %s "${XDG_CONFIG_HOME}/nvm")" && \ + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \ + nvm install node && \ + node --version && \ + npm --version && \ + cd web/serverless-microservices-web && \ + npm install && \ + export NODE_OPTIONS=--openssl-legacy-provider && \ + npm run build' diff --git a/dotnet/ServerlessMicroservices.FunctionApp.Drivers/ServerlessMicroservices.FunctionApp.Drivers.csproj b/dotnet/ServerlessMicroservices.FunctionApp.Drivers/ServerlessMicroservices.FunctionApp.Drivers.csproj index 30aa239..ba768bd 100644 --- a/dotnet/ServerlessMicroservices.FunctionApp.Drivers/ServerlessMicroservices.FunctionApp.Drivers.csproj +++ b/dotnet/ServerlessMicroservices.FunctionApp.Drivers/ServerlessMicroservices.FunctionApp.Drivers.csproj @@ -1,12 +1,13 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>netcoreapp3.1</TargetFramework> - <AzureFunctionsVersion>v3</AzureFunctionsVersion> + <TargetFramework>net6.0</TargetFramework> + <AzureFunctionsVersion>v4</AzureFunctionsVersion> + <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> </PropertyGroup> <ItemGroup> <!--<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />--> <!--<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.12" />--> - <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" /> + <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\ServerlessMicroservices.Models\ServerlessMicroservices.Models.csproj" /> @@ -24,4 +25,4 @@ <ItemGroup> <Folder Include="Properties\" /> </ItemGroup> -</Project> \ No newline at end of file +</Project> diff --git a/dotnet/ServerlessMicroservices.FunctionApp.Orchestrators/ServerlessMicroservices.FunctionApp.Orchestrators.csproj b/dotnet/ServerlessMicroservices.FunctionApp.Orchestrators/ServerlessMicroservices.FunctionApp.Orchestrators.csproj index 7dccd57..51c6e05 100644 --- a/dotnet/ServerlessMicroservices.FunctionApp.Orchestrators/ServerlessMicroservices.FunctionApp.Orchestrators.csproj +++ b/dotnet/ServerlessMicroservices.FunctionApp.Orchestrators/ServerlessMicroservices.FunctionApp.Orchestrators.csproj @@ -1,12 +1,13 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>netcoreapp3.1</TargetFramework> - <AzureFunctionsVersion>v3</AzureFunctionsVersion> + <TargetFramework>net6.0</TargetFramework> + <AzureFunctionsVersion>v4</AzureFunctionsVersion> + <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> </PropertyGroup> <ItemGroup> - <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.6.0" /> - <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.0.0" /> - <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" /> + <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.6.1" /> + <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage.Queues" Version="5.0.0" /> + <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" /> </ItemGroup> <ItemGroup> <None Update="host.json"> @@ -23,4 +24,4 @@ <ItemGroup> <Folder Include="Properties\" /> </ItemGroup> -</Project> \ No newline at end of file +</Project> diff --git a/dotnet/ServerlessMicroservices.FunctionApp.Passengers/ServerlessMicroservices.FunctionApp.Passengers.csproj b/dotnet/ServerlessMicroservices.FunctionApp.Passengers/ServerlessMicroservices.FunctionApp.Passengers.csproj index c1ffded..5c6b869 100644 --- a/dotnet/ServerlessMicroservices.FunctionApp.Passengers/ServerlessMicroservices.FunctionApp.Passengers.csproj +++ b/dotnet/ServerlessMicroservices.FunctionApp.Passengers/ServerlessMicroservices.FunctionApp.Passengers.csproj @@ -1,11 +1,11 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>netcoreapp3.1</TargetFramework> - <AzureFunctionsVersion>v3</AzureFunctionsVersion> - <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> + <TargetFramework>net6.0</TargetFramework> + <AzureFunctionsVersion>v4</AzureFunctionsVersion> + <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> </PropertyGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" /> + <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\ServerlessMicroservices.Models\ServerlessMicroservices.Models.csproj" /> @@ -20,4 +20,4 @@ <CopyToPublishDirectory>Never</CopyToPublishDirectory> </None> </ItemGroup> -</Project> \ No newline at end of file +</Project> diff --git a/dotnet/ServerlessMicroservices.FunctionApp.Trips/ServerlessMicroservices.FunctionApp.Trips.csproj b/dotnet/ServerlessMicroservices.FunctionApp.Trips/ServerlessMicroservices.FunctionApp.Trips.csproj index 0fa7f0a..549d578 100644 --- a/dotnet/ServerlessMicroservices.FunctionApp.Trips/ServerlessMicroservices.FunctionApp.Trips.csproj +++ b/dotnet/ServerlessMicroservices.FunctionApp.Trips/ServerlessMicroservices.FunctionApp.Trips.csproj @@ -1,13 +1,15 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>netcoreapp3.1</TargetFramework> - <AzureFunctionsVersion>v3</AzureFunctionsVersion> + <TargetFramework>net6.0</TargetFramework> + <AzureFunctionsVersion>v4</AzureFunctionsVersion> + <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> </PropertyGroup> <ItemGroup> - <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventGrid" Version="3.0.0" /> + <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventGrid" Version="3.1.0" /> <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SignalRService" Version="1.6.0" /> - <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.0.0" /> - <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" /> + <PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="6.0.2" /> + <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage.Blobs" Version="5.0.0" /> + <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\ServerlessMicroservices.Models\ServerlessMicroservices.Models.csproj" /> @@ -25,4 +27,4 @@ <ItemGroup> <Folder Include="Properties\" /> </ItemGroup> -</Project> \ No newline at end of file +</Project> diff --git a/dotnet/ServerlessMicroservices.Models/ServerlessMicroservices.Models.csproj b/dotnet/ServerlessMicroservices.Models/ServerlessMicroservices.Models.csproj index 3271307..3644243 100644 --- a/dotnet/ServerlessMicroservices.Models/ServerlessMicroservices.Models.csproj +++ b/dotnet/ServerlessMicroservices.Models/ServerlessMicroservices.Models.csproj @@ -1,7 +1,7 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>netcoreapp3.1</TargetFramework> + <TargetFramework>net6.0</TargetFramework> </PropertyGroup> <ItemGroup> diff --git a/dotnet/ServerlessMicroservices.Seeder/ServerlessMicroservices.Seeder.csproj b/dotnet/ServerlessMicroservices.Seeder/ServerlessMicroservices.Seeder.csproj index f278268..e8eae2a 100644 --- a/dotnet/ServerlessMicroservices.Seeder/ServerlessMicroservices.Seeder.csproj +++ b/dotnet/ServerlessMicroservices.Seeder/ServerlessMicroservices.Seeder.csproj @@ -2,7 +2,7 @@ <PropertyGroup> <OutputType>Exe</OutputType> - <TargetFramework>netcoreapp3.1</TargetFramework> + <TargetFramework>net6.0</TargetFramework> </PropertyGroup> <ItemGroup> diff --git a/dotnet/ServerlessMicroservices.Shared/ServerlessMicroservices.Shared.csproj b/dotnet/ServerlessMicroservices.Shared/ServerlessMicroservices.Shared.csproj index 424cdc2..222ba4b 100644 --- a/dotnet/ServerlessMicroservices.Shared/ServerlessMicroservices.Shared.csproj +++ b/dotnet/ServerlessMicroservices.Shared/ServerlessMicroservices.Shared.csproj @@ -1,7 +1,7 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>netcoreapp3.1</TargetFramework> + <TargetFramework>net6.0</TargetFramework> </PropertyGroup> <ItemGroup> From dcc7e70e0bc9dd5a168d6851e4b44f628069f5a8 Mon Sep 17 00:00:00 2001 From: Anthony Shaw <anthony.p.shaw@gmail.com> Date: Mon, 22 Apr 2024 17:59:43 +1000 Subject: [PATCH 4/6] Create bicep-audit.yml --- .github/workflows/bicep-audit.yml | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/bicep-audit.yml diff --git a/.github/workflows/bicep-audit.yml b/.github/workflows/bicep-audit.yml new file mode 100644 index 0000000..eb7f66d --- /dev/null +++ b/.github/workflows/bicep-audit.yml @@ -0,0 +1,35 @@ +name: Validate bicep templates +on: + push: + branches: + - main + paths: + - "**/*.bicep" + pull_request: + branches: + - main + paths: + - "**/*.bicep" + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + permissions: + security-events: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Run Microsoft Security DevOps Analysis + uses: microsoft/security-devops-action@preview + id: msdo + continue-on-error: true + with: + tools: templateanalyzer + + - name: Upload alerts to Security tab + uses: github/codeql-action/upload-sarif@v3 + if: github.repository_owner == 'Azure-Samples' + with: + sarif_file: ${{ steps.msdo.outputs.sarifFile }} From 06f5e413e54fac8e425066cc95256cb1fbfed2c0 Mon Sep 17 00:00:00 2001 From: Anthony Shaw <anthony.p.shaw@gmail.com> Date: Thu, 6 Jun 2024 19:03:08 +1000 Subject: [PATCH 5/6] Switch to PSRule for security analysis --- .github/workflows/bicep-audit.yml | 22 +++++++++++++++------- bicep/main.bicep | 2 +- bicep/main.test.bicep | 20 ++++++++++++++++++++ bicep/modules/sqldb.bicep | 4 ++-- ps-rule.yaml | 3 +++ 5 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 bicep/main.test.bicep create mode 100644 ps-rule.yaml diff --git a/.github/workflows/bicep-audit.yml b/.github/workflows/bicep-audit.yml index eb7f66d..7ededd4 100644 --- a/.github/workflows/bicep-audit.yml +++ b/.github/workflows/bicep-audit.yml @@ -21,15 +21,23 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Run Microsoft Security DevOps Analysis - uses: microsoft/security-devops-action@preview - id: msdo - continue-on-error: true + - name: Run PSRule analysis + uses: microsoft/ps-rule@v2.9.0 with: - tools: templateanalyzer + modules: PSRule.Rules.Azure + baseline: Azure.Pillar.Security + inputPath: bicep/*.test.bicep + outputFormat: Sarif + outputPath: reports/ps-rule-results.sarif + summary: true + continue-on-error: true + + env: + PSRULE_CONFIGURATION_AZURE_BICEP_FILE_EXPANSION: 'true' + PSRULE_CONFIGURATION_AZURE_BICEP_FILE_EXPANSION_TIMEOUT: '30' - - name: Upload alerts to Security tab + - name: Upload results to security tab uses: github/codeql-action/upload-sarif@v3 if: github.repository_owner == 'Azure-Samples' with: - sarif_file: ${{ steps.msdo.outputs.sarifFile }} + sarif_file: reports/ps-rule-results.sarif diff --git a/bicep/main.bicep b/bicep/main.bicep index d62d9fb..d975d6e 100644 --- a/bicep/main.bicep +++ b/bicep/main.bicep @@ -50,7 +50,7 @@ module sqlDb 'modules/sqldb.bicep' = { name: 'sqldb' params: { sqlServerName: sqlServerName - sqlDatabaeName: applicationName + sqlDatabaseName: applicationName administratorLogin: sqlAdminLogin administratorPassword: sqlAdminPassword location: location diff --git a/bicep/main.test.bicep b/bicep/main.test.bicep new file mode 100644 index 0000000..052b2e7 --- /dev/null +++ b/bicep/main.test.bicep @@ -0,0 +1,20 @@ +// This file is for doing static analysis and contains sensible defaults +// for the bicep analyser to minimise false-positives and provide the best results. + +// This file is not intended to be used as a runtime configuration file. + +targetScope = 'resourceGroup' + +// Random, dummy data for static analysis +param sqlAdminLogin string = newGuid() +@secure() +param sqlAdminPassword string = newGuid() + +module main 'main.bicep' = { + name: 'main' + params: { + staticWebAppLocation: 'westus2' + sqlAdminLogin: sqlAdminLogin + sqlAdminPassword: sqlAdminPassword + } +} diff --git a/bicep/modules/sqldb.bicep b/bicep/modules/sqldb.bicep index ba3bf29..7017ba0 100644 --- a/bicep/modules/sqldb.bicep +++ b/bicep/modules/sqldb.bicep @@ -1,5 +1,5 @@ param sqlServerName string -param sqlDatabaeName string +param sqlDatabaseName string param location string param administratorLogin string @secure() @@ -20,7 +20,7 @@ resource sqlServer 'Microsoft.Sql/servers@2021-05-01-preview' = { resource servers_rideshare_server_name_databases_Rideshare_name 'Microsoft.Sql/servers/databases@2021-05-01-preview' = { parent: sqlServer - name: sqlDatabaeName + name: sqlDatabaseName location: location tags: resourceTags sku: { diff --git a/ps-rule.yaml b/ps-rule.yaml new file mode 100644 index 0000000..bb4904b --- /dev/null +++ b/ps-rule.yaml @@ -0,0 +1,3 @@ +# YAML: Set the AZURE_BICEP_FILE_EXPANSION configuration option to enable expansion +configuration: + AZURE_BICEP_FILE_EXPANSION: true \ No newline at end of file From 1e416e6cc0c82fbb787e26de30ead74a43a04154 Mon Sep 17 00:00:00 2001 From: Anthony Shaw <anthony.p.shaw@gmail.com> Date: Thu, 6 Jun 2024 19:19:41 +1000 Subject: [PATCH 6/6] Improve security on templates. Don't log app insights instrumentation keys. Set minimum TLS versions --- bicep/modules/apim.bicep | 20 +++++++++++++++++++- bicep/modules/cosmosdb.bicep | 5 +++-- bicep/modules/functions.bicep | 5 ++++- bicep/modules/sqldb.bicep | 18 +++++++++++++++++- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/bicep/modules/apim.bicep b/bicep/modules/apim.bicep index 9efe91b..fe1cb6f 100644 --- a/bicep/modules/apim.bicep +++ b/bicep/modules/apim.bicep @@ -1,6 +1,7 @@ @description('API Management DB account name') param apimName string param appInsightsName string +@secure() param appInsightsInstrumentationKey string param resourceTags object @@ -22,7 +23,7 @@ var location = resourceGroup().location var publisherEmail = 'email@contoso.com' var publisherName = 'Company Name' -resource apiManagement 'Microsoft.ApiManagement/service@2021-01-01-preview' = { +resource apiManagement 'Microsoft.ApiManagement/service@2021-08-01' = { name: apimName location: location tags: resourceTags @@ -33,6 +34,23 @@ resource apiManagement 'Microsoft.ApiManagement/service@2021-01-01-preview' = { properties: { publisherEmail: publisherEmail publisherName: publisherName + customProperties: { + 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10': 'False' + 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11': 'False' + 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30': 'False' + 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10': 'False' + 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11': 'False' + 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30': 'False' + 'Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2': 'True' + 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168': 'False' + 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA': 'False' + 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_256_CBC_SHA': 'False' + 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256': 'False' + 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA': 'False' + 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_256_CBC_SHA256': 'False' + 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA': 'False' + 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_GCM_SHA256': 'False' + } } identity: { type: 'SystemAssigned' diff --git a/bicep/modules/cosmosdb.bicep b/bicep/modules/cosmosdb.bicep index 7a75665..22ea8dd 100644 --- a/bicep/modules/cosmosdb.bicep +++ b/bicep/modules/cosmosdb.bicep @@ -16,7 +16,7 @@ var containerNames = [ 'archiver' ] -resource cosmosAccount 'Microsoft.DocumentDB/databaseAccounts@2021-06-15' = { +resource cosmosAccount 'Microsoft.DocumentDB/databaseAccounts@2024-05-15' = { name: toLower(accountName) kind: 'GlobalDocumentDB' location: location @@ -38,7 +38,8 @@ resource cosmosAccount 'Microsoft.DocumentDB/databaseAccounts@2021-06-15' = { backupIntervalInMinutes: 240 backupRetentionIntervalInHours: 8 } - } + } + minimalTlsVersion: 'Tls12' } } diff --git a/bicep/modules/functions.bicep b/bicep/modules/functions.bicep index 2e65772..3c6ccc2 100644 --- a/bicep/modules/functions.bicep +++ b/bicep/modules/functions.bicep @@ -4,6 +4,7 @@ param functionApps array param appServicePlanName string param location string = resourceGroup().location param staticWebAppURL string +@secure() param appInsightsInstrumentationKey string param resourceTags object @@ -20,6 +21,7 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2019-06-01' = { kind: 'StorageV2' properties: { supportsHttpsTrafficOnly: true + minimumTlsVersion: 'TLS1_2' encryption: { services: { file: { @@ -48,7 +50,7 @@ resource plan 'Microsoft.Web/serverFarms@2020-06-01' = { properties: {} } -resource functionApp 'Microsoft.Web/sites@2020-06-01' = [for functionApp in functionApps :{ +resource functionApp 'Microsoft.Web/sites@2023-12-01' = [for functionApp in functionApps :{ name: '${functionAppPrefix}${functionApp}' location: location kind: 'functionapp' @@ -86,6 +88,7 @@ resource functionApp 'Microsoft.Web/sites@2020-06-01' = [for functionApp in func staticWebAppURL ] } + minTlsVersion: '1.2' } httpsOnly: true } diff --git a/bicep/modules/sqldb.bicep b/bicep/modules/sqldb.bicep index 7017ba0..bc949e0 100644 --- a/bicep/modules/sqldb.bicep +++ b/bicep/modules/sqldb.bicep @@ -6,7 +6,7 @@ param administratorLogin string param administratorPassword string param resourceTags object -resource sqlServer 'Microsoft.Sql/servers@2021-05-01-preview' = { +resource sqlServer 'Microsoft.Sql/servers@2022-11-01-preview' = { name: sqlServerName location: location tags: resourceTags @@ -14,6 +14,7 @@ resource sqlServer 'Microsoft.Sql/servers@2021-05-01-preview' = { administratorLogin: administratorLogin administratorLoginPassword: administratorPassword version: '12.0' + minimalTlsVersion: '1.2' } dependsOn: [] } @@ -34,3 +35,18 @@ resource servers_rideshare_server_name_databases_Rideshare_name 'Microsoft.Sql/s zoneRedundant: false } } + +resource sqlAuditSettings 'Microsoft.Sql/servers/auditingSettings@2022-08-01-preview' = { + name: 'default' + parent: sqlServer + properties: { + isAzureMonitorTargetEnabled: true + state: 'Enabled' + retentionDays: 7 + auditActionsAndGroups: [ + 'SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP' + 'FAILED_DATABASE_AUTHENTICATION_GROUP' + 'BATCH_COMPLETED_GROUP' + ] + } +}