From 15665589e67e51af1785803868890ebde4b81925 Mon Sep 17 00:00:00 2001 From: Stas Date: Tue, 16 Mar 2021 10:21:08 -0700 Subject: [PATCH] dotnet5 (#157) Co-authored-by: stas --- .gitignore | 1 + NOTICE.md | 2 +- Scripts/CustomTools/tools/RESTler/config.json | 2 +- ado/stages/build/steps/apiservice.yml | 10 +-- ado/stages/build/steps/azure-auth-utility.yml | 2 +- ado/stages/build/steps/orchestrator.yml | 4 +- ado/stages/build/steps/restleragent.yml | 4 +- ado/stages/build/steps/result-analyzer.yml | 2 +- ado/stages/build/steps/test-infra.yml | 6 +- ado/stages/deploy/steps/upload-tools.yml | 4 +- ado/stages/publish/steps/cli.yml | 2 +- cli/raft.py | 4 +- cli/raft_sdk/raft_deploy.py | 8 +- cli/samples/dredd/petstore/dredd.json | 2 +- .../swagger-petstore/restler.test.json | 2 +- .../swagger-petstore3/compile.json | 2 +- .../swagger-petstore3/test.json | 2 +- .../swagger-petstore3/schemathesis.json | 2 +- cli/samples/zap/swagger-petstore3/zap.json | 2 +- src/APIService/ApiService/APIService.fsproj | 4 +- .../APIServiceTests/APIServiceTests.fsproj | 4 +- src/APIService/ApiService/Dockerfile | 2 +- src/Agent/AzureAuth/AzureAuth.fsproj | 4 +- src/Agent/Dockerfile | 2 +- src/Agent/RESTlerAgent/AgentMain.fs | 4 +- src/Agent/RESTlerAgent/RestlerAgent.fsproj | 4 +- .../RaftResultAnalyzer.fsproj | 4 +- src/Orchestrator/Dockerfile | 11 +-- src/Orchestrator/Orchestrator/Orchestrator.cs | 90 ++++++++++++++----- .../Orchestrator/Orchestrator.csproj | 15 ++-- src/Orchestrator/OrchestratorLogic/Dockerfile | 13 +-- .../OrchestratorLogic.fsproj | 4 +- src/Test/Dockerfile | 13 ++- src/Test/TestInfraFunc/TestInfra.cs | 47 +++++++--- src/Test/TestInfraFunc/TestInfraFunc.csproj | 13 ++- src/Test/TestInfraLogic/Dockerfile | 13 +-- src/Test/TestInfraLogic/TestInfraLogic.fsproj | 2 +- src/restler/Dockerfile | 2 +- 38 files changed, 187 insertions(+), 127 deletions(-) diff --git a/.gitignore b/.gitignore index 9430e6e..5576e75 100644 --- a/.gitignore +++ b/.gitignore @@ -82,6 +82,7 @@ __pycache__/ /cli/raft_sdk/.cache/token_cache.bin /cli/raft-tools/auth/dotnet-core-3.1/* +/cli/raft-tools/auth/dotnet-5.0/* /cli/defaults-*.json /cli/local/ diff --git a/NOTICE.md b/NOTICE.md index f21fcd4..ffada12 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -7866,7 +7866,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI --------------------------------------------------------- -FSharp.Core 4.7.2 - MIT +FSharp.Core 5.0.1 - MIT (c) 2008 VeriSign, Inc. diff --git a/Scripts/CustomTools/tools/RESTler/config.json b/Scripts/CustomTools/tools/RESTler/config.json index 1ea0f33..3c7e4e5 100644 --- a/Scripts/CustomTools/tools/RESTler/config.json +++ b/Scripts/CustomTools/tools/RESTler/config.json @@ -3,7 +3,7 @@ "shell" : "/bin/sh", "run" : { "shellArguments" : ["-c", - "sleep $RAFT_STARTUP_DELAY; dotnet /raft/agent/RestlerAgent.dll --agent-name ${RAFT_CONTAINER_NAME} --job-id ${RAFT_JOB_ID} --task-config-path ${RAFT_WORK_DIRECTORY}/task-config.json --work-directory ${RAFT_WORK_DIRECTORY} --restler-path /RESTler --app-insights-instrumentation-key ${RAFT_APP_INSIGHTS_KEY} --output-sas \"${RAFT_SB_OUT_SAS}\"" + "date; sleep ${RAFT_STARTUP_DELAY}; date; dotnet /raft/agent/RestlerAgent.dll --agent-name ${RAFT_CONTAINER_NAME} --job-id ${RAFT_JOB_ID} --task-config-path ${RAFT_WORK_DIRECTORY}/task-config.json --work-directory ${RAFT_WORK_DIRECTORY} --restler-path /RESTler --app-insights-instrumentation-key ${RAFT_APP_INSIGHTS_KEY} --output-sas \"${RAFT_SB_OUT_SAS}\"" ] }, "idle" : { diff --git a/ado/stages/build/steps/apiservice.yml b/ado/stages/build/steps/apiservice.yml index af2750c..9ca1dff 100644 --- a/ado/stages/build/steps/apiservice.yml +++ b/ado/stages/build/steps/apiservice.yml @@ -32,16 +32,16 @@ steps: - task: CopyFiles@2 displayName: 'Copy APIService Dockerfile' inputs: - targetFolder: src/APIService/ApiService/bin/release/netcoreapp3.1/linux-musl-x64/publish/ + targetFolder: src/APIService/ApiService/bin/release/net5.0/linux-musl-x64/publish/ sourceFolder: src/APIService/ApiService contents: Dockerfile # Create files with version information that will be used in the release pipeline - - script: echo $(imageTag) > src/APIService/ApiService/bin/release/netcoreapp3.1/linux-musl-x64/publish/imageTag.txt - - script: echo $(imageTagWithBuildDate) > src/APIService/ApiService/bin/release/netcoreapp3.1/linux-musl-x64/publish/imageTagWithBuildDate.txt - - script: echo $(imageTagLatest) > src/APIService/ApiService/bin/release/netcoreapp3.1/linux-musl-x64/publish/imageTagLatest.txt + - script: echo $(imageTag) > src/APIService/ApiService/bin/release/net5.0/linux-musl-x64/publish/imageTag.txt + - script: echo $(imageTagWithBuildDate) > src/APIService/ApiService/bin/release/net5.0/linux-musl-x64/publish/imageTagWithBuildDate.txt + - script: echo $(imageTagLatest) > src/APIService/ApiService/bin/release/net5.0/linux-musl-x64/publish/imageTagLatest.txt - task: PublishPipelineArtifact@1 inputs: - targetPath: src/APIService/ApiService/bin/release/netcoreapp3.1/linux-musl-x64/publish + targetPath: src/APIService/ApiService/bin/release/net5.0/linux-musl-x64/publish artifactName: apiservice diff --git a/ado/stages/build/steps/azure-auth-utility.yml b/ado/stages/build/steps/azure-auth-utility.yml index 7eac92d..592b94c 100644 --- a/ado/stages/build/steps/azure-auth-utility.yml +++ b/ado/stages/build/steps/azure-auth-utility.yml @@ -20,5 +20,5 @@ steps: - task: PublishPipelineArtifact@1 inputs: - targetPath: src/Agent/AzureAuth/bin/release/netcoreapp3.1/publish/ + targetPath: src/Agent/AzureAuth/bin/release/net5.0/publish/ artifactName: AzureAuth diff --git a/ado/stages/build/steps/orchestrator.yml b/ado/stages/build/steps/orchestrator.yml index 213d800..22fc748 100644 --- a/ado/stages/build/steps/orchestrator.yml +++ b/ado/stages/build/steps/orchestrator.yml @@ -23,12 +23,12 @@ steps: - task: CopyFiles@2 displayName: 'Copy Orchestrator Dockerfile' inputs: - targetFolder: src/Orchestrator/Orchestrator/bin/release/netcoreapp3.1/publish/ + targetFolder: src/Orchestrator/Orchestrator/bin/release/net5.0/publish/ sourceFolder: src/Orchestrator contents: Dockerfile - task: PublishPipelineArtifact@1 inputs: - targetPath: src/Orchestrator/Orchestrator/bin/release/netcoreapp3.1/publish/ + targetPath: src/Orchestrator/Orchestrator/bin/release/net5.0/publish/ artifactName: Orchestrator diff --git a/ado/stages/build/steps/restleragent.yml b/ado/stages/build/steps/restleragent.yml index dd53321..6c385ca 100644 --- a/ado/stages/build/steps/restleragent.yml +++ b/ado/stages/build/steps/restleragent.yml @@ -23,11 +23,11 @@ steps: - task: CopyFiles@2 displayName: 'Copy RESTlerAgent Dockerfile' inputs: - targetFolder: src/Agent/RESTlerAgent/bin/release/netcoreapp3.1/publish/ + targetFolder: src/Agent/RESTlerAgent/bin/release/net5.0/publish/ sourceFolder: src/Agent contents: Dockerfile - task: PublishPipelineArtifact@1 inputs: - targetPath: src/Agent/RESTlerAgent/bin/release/netcoreapp3.1/publish/ + targetPath: src/Agent/RESTlerAgent/bin/release/net5.0/publish/ artifactName: RestlerAgent diff --git a/ado/stages/build/steps/result-analyzer.yml b/ado/stages/build/steps/result-analyzer.yml index cd26a76..b8092e5 100644 --- a/ado/stages/build/steps/result-analyzer.yml +++ b/ado/stages/build/steps/result-analyzer.yml @@ -20,5 +20,5 @@ steps: - task: PublishPipelineArtifact@1 inputs: - targetPath: src/Agent/RaftResultAnalyzer/bin/release/netcoreapp3.1/publish/ + targetPath: src/Agent/RaftResultAnalyzer/bin/release/net5.0/publish/ artifactName: RaftResultAnalyzer diff --git a/ado/stages/build/steps/test-infra.yml b/ado/stages/build/steps/test-infra.yml index 2e81380..cb321be 100644 --- a/ado/stages/build/steps/test-infra.yml +++ b/ado/stages/build/steps/test-infra.yml @@ -21,7 +21,7 @@ steps: - task: CopyFiles@2 displayName: 'Copy Test Infra Dockerfile' inputs: - targetFolder: src/Test/TestInfraFunc/bin/release/netcoreapp3.1/publish/ + targetFolder: src/Test/TestInfraFunc/bin/release/net5.0/publish/ sourceFolder: src/Test/ contents: Dockerfile @@ -30,12 +30,12 @@ steps: - task: CopyFiles@2 displayName: 'Copy TestInfraFunc Dockerfile' inputs: - targetFolder: src/Test/TestInfraFunc/bin/release/netcoreapp3.1/publish/ + targetFolder: src/Test/TestInfraFunc/bin/release/net5.0/publish/ sourceFolder: src/Test contents: Dockerfile - task: PublishPipelineArtifact@1 inputs: - targetPath: src/Test/TestInfraFunc/bin/release/netcoreapp3.1/publish/ + targetPath: src/Test/TestInfraFunc/bin/release/net5.0/publish/ artifactName: TestInfraFunc diff --git a/ado/stages/deploy/steps/upload-tools.yml b/ado/stages/deploy/steps/upload-tools.yml index ae42597..bca7d7e 100644 --- a/ado/stages/deploy/steps/upload-tools.yml +++ b/ado/stages/deploy/steps/upload-tools.yml @@ -16,7 +16,7 @@ steps: condition: and(succeeded(), eq('${{parameters.BuildArtifactsLocation}}', 'current')) inputs: artifact: AzureAuth - path: $(Build.SourcesDirectory)/cli/raft-tools/auth/dotnet-core-3.1 + path: $(Build.SourcesDirectory)/cli/raft-tools/auth/dotnet-5.0 - task: DownloadPipelineArtifact@2 displayName: 'Download Production pipeline artifact' @@ -29,7 +29,7 @@ steps: # In this case it's the pipeline named 'build-production' pipeline: 2925 artifact: AzureAuth - path: $(Build.SourcesDirectory)/cli/raft-tools/auth/dotnet-core-3.1 + path: $(Build.SourcesDirectory)/cli/raft-tools/auth/dotnet-5.0 runVersion: 'latest' - task: AzureCLI@2 diff --git a/ado/stages/publish/steps/cli.yml b/ado/stages/publish/steps/cli.yml index 6d3c439..2437931 100644 --- a/ado/stages/publish/steps/cli.yml +++ b/ado/stages/publish/steps/cli.yml @@ -18,7 +18,7 @@ steps: project: 'raft' pipeline: $(build-production-pipeline-id) artifact: AzureAuth - path: $(Build.SourcesDirectory)/artifacts/cli/raft-tools/auth/dotnet-core-3.1 + path: $(Build.SourcesDirectory)/artifacts/cli/raft-tools/auth/dotnet-5.0 runVersion: 'latest' - task: ArchiveFiles@2 diff --git a/cli/raft.py b/cli/raft.py index 7ba076e..e5eb9dd 100644 --- a/cli/raft.py +++ b/cli/raft.py @@ -78,14 +78,14 @@ def run(args): if defaults_json: print(f"Loading defaults from command line: {defaults_json}") - defaults = json.loads(defaults_json, object_hook=json_hook) + defaults = json.loads(defaults_json) if not validate(defaults): print(defaults_help) return # check if defaults.json is set in the context and it exists elif os.path.isfile(defaults_path): with open(defaults_path, 'r') as d: - defaults = json.load(d, object_hook=json_hook) + defaults = json.load(d) if not validate(defaults): print(defaults_help) return diff --git a/cli/raft_sdk/raft_deploy.py b/cli/raft_sdk/raft_deploy.py index ddd4233..83fc917 100644 --- a/cli/raft_sdk/raft_deploy.py +++ b/cli/raft_sdk/raft_deploy.py @@ -667,7 +667,8 @@ class RaftServiceCLI(): f' --resource-group {rg}' f' --plan "{self.definitions.asp}"' ' --functions-version 3' - ' --os-type Linux --runtime dotnet' + ' --os-type Linux --runtime dotnet-isolated' + ' --runtime-version 5.0' f' {ai}') connection_string = az_json( @@ -757,7 +758,8 @@ class RaftServiceCLI(): f' --resource-group {rg}' f' --plan "{self.definitions.asp}"' ' --functions-version 3' - ' --os-type Linux --runtime dotnet' + ' --os-type Linux --runtime dotnet-isolated' + ' --runtime-version 5.0' f' {ai}') connection_string = az_json( @@ -947,7 +949,7 @@ class RaftServiceCLI(): json.dump(defaults, d, indent=4) def test_az_version(self): - supported_versions = ['2.19.0', '2.19.1'] + supported_versions = ['2.20.0'] # az sometimes reports the version with an asterisk. # Perhaps when a new version of the CLI is available. tested_az_cli_versions = ( diff --git a/cli/samples/dredd/petstore/dredd.json b/cli/samples/dredd/petstore/dredd.json index e944380..d9b47af 100644 --- a/cli/samples/dredd/petstore/dredd.json +++ b/cli/samples/dredd/petstore/dredd.json @@ -8,7 +8,7 @@ { "Container" : "swaggerapi/petstore", "Ports" : [8080], - "ExpectedDurationUntilReady" : "00:00:30", + "ExpectedDurationUntilReady" : "00:01:00", "shell" : "/bin/sh", "PostRun" : { "ShellArguments" : ["-c", "cp /var/log/*-requests.log $RAFT_WORK_DIRECTORY"], diff --git a/cli/samples/restler/self-contained/swagger-petstore/restler.test.json b/cli/samples/restler/self-contained/swagger-petstore/restler.test.json index 612b437..43f9965 100644 --- a/cli/samples/restler/self-contained/swagger-petstore/restler.test.json +++ b/cli/samples/restler/self-contained/swagger-petstore/restler.test.json @@ -14,7 +14,7 @@ { "Container" : "swaggerapi/petstore", "Ports" : [8080], - "ExpectedDurationUntilReady" : "00:00:30", + "ExpectedDurationUntilReady" : "00:01:00", "Shell" : "/bin/sh", "OutputFolder" : "petstore", "PostRun" : { diff --git a/cli/samples/restler/self-contained/swagger-petstore3/compile.json b/cli/samples/restler/self-contained/swagger-petstore3/compile.json index 74c451f..f70050f 100644 --- a/cli/samples/restler/self-contained/swagger-petstore3/compile.json +++ b/cli/samples/restler/self-contained/swagger-petstore3/compile.json @@ -16,7 +16,7 @@ { "Container" : "swaggerapi/petstore3", "Ports" : [8082], - "ExpectedDurationUntilReady" : "00:00:30", + "ExpectedDurationUntilReady" : "00:01:00", "Shell" : "/bin/sh", "Run" : { "ShellArguments" : ["-c", "java -jar /swagger-petstore/jetty-runner.jar --log /var/log/yyyy_mm_dd-requests.log --port 8082 /swagger-petstore/server.war"] diff --git a/cli/samples/restler/self-contained/swagger-petstore3/test.json b/cli/samples/restler/self-contained/swagger-petstore3/test.json index 322d0aa..b0734cb 100644 --- a/cli/samples/restler/self-contained/swagger-petstore3/test.json +++ b/cli/samples/restler/self-contained/swagger-petstore3/test.json @@ -30,7 +30,7 @@ { "Container" : "swaggerapi/petstore3", "Ports" : [8080], - "ExpectedDurationUntilReady" : "00:00:30", + "ExpectedDurationUntilReady" : "00:01:00", "Shell" : "/bin/sh", "PostRun" : { "ShellArguments" : ["-c", "cp /var/log/*-requests.log $RAFT_WORK_DIRECTORY"], diff --git a/cli/samples/schemathesis/swagger-petstore3/schemathesis.json b/cli/samples/schemathesis/swagger-petstore3/schemathesis.json index 5a8db5d..3d33181 100644 --- a/cli/samples/schemathesis/swagger-petstore3/schemathesis.json +++ b/cli/samples/schemathesis/swagger-petstore3/schemathesis.json @@ -5,7 +5,7 @@ { "Container" : "swaggerapi/petstore3", "Ports" : [8080], - "ExpectedDurationUntilReady" : "00:00:30", + "ExpectedDurationUntilReady" : "00:01:00", "Shell" : "/bin/sh", "PostRun" : { "ShellArguments" : ["-c", "cp /var/log/*-requests.log $RAFT_WORK_DIRECTORY"], diff --git a/cli/samples/zap/swagger-petstore3/zap.json b/cli/samples/zap/swagger-petstore3/zap.json index 2f24295..2ae7a77 100644 --- a/cli/samples/zap/swagger-petstore3/zap.json +++ b/cli/samples/zap/swagger-petstore3/zap.json @@ -5,7 +5,7 @@ { "Container" : "swaggerapi/petstore3", "Ports" : [8080], - "ExpectedDurationUntilReady" : "00:00:30", + "ExpectedDurationUntilReady" : "00:01:00", "Shell" : "/bin/sh", "PostRun" : { "ShellArguments" : ["-c", "cp /var/log/*-requests.log $RAFT_WORK_DIRECTORY"], diff --git a/src/APIService/ApiService/APIService.fsproj b/src/APIService/ApiService/APIService.fsproj index 1f44281..728c52a 100644 --- a/src/APIService/ApiService/APIService.fsproj +++ b/src/APIService/ApiService/APIService.fsproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net5.0 apiservice @@ -72,7 +72,7 @@ - + diff --git a/src/APIService/ApiService/APIServiceTests/APIServiceTests.fsproj b/src/APIService/ApiService/APIServiceTests/APIServiceTests.fsproj index a60d5bb..ad854b8 100644 --- a/src/APIService/ApiService/APIServiceTests/APIServiceTests.fsproj +++ b/src/APIService/ApiService/APIServiceTests/APIServiceTests.fsproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net5.0 false false @@ -51,7 +51,7 @@ - + diff --git a/src/APIService/ApiService/Dockerfile b/src/APIService/ApiService/Dockerfile index f569ca3..53fe9b7 100644 --- a/src/APIService/ApiService/Dockerfile +++ b/src/APIService/ApiService/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/core/runtime-deps:3.1-alpine +FROM mcr.microsoft.com/dotnet/runtime-deps:5.0-alpine COPY . /raft/apiservice RUN ls -al /raft/apiservice RUN chmod +x /raft/apiservice/apiservice diff --git a/src/Agent/AzureAuth/AzureAuth.fsproj b/src/Agent/AzureAuth/AzureAuth.fsproj index c03a6bf..3c74a9c 100644 --- a/src/Agent/AzureAuth/AzureAuth.fsproj +++ b/src/Agent/AzureAuth/AzureAuth.fsproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net5.0 @@ -15,7 +15,7 @@ - + diff --git a/src/Agent/Dockerfile b/src/Agent/Dockerfile index 06f5fab..442b082 100644 --- a/src/Agent/Dockerfile +++ b/src/Agent/Dockerfile @@ -1,3 +1,3 @@ -FROM mcr.microsoft.com/restlerfuzzer/restler:v7.2.0 +FROM mcr.microsoft.com/restlerfuzzer/restler:v7.3.0 COPY RestlerAgent /raft/agent COPY RaftResultAnalyzer /raft/result-analyzer diff --git a/src/Agent/RESTlerAgent/AgentMain.fs b/src/Agent/RESTlerAgent/AgentMain.fs index a3a8972..0c78e07 100644 --- a/src/Agent/RESTlerAgent/AgentMain.fs +++ b/src/Agent/RESTlerAgent/AgentMain.fs @@ -254,10 +254,10 @@ let createRESTlerEngineParameters | Raft.Job.Authentication.TokenRefresh.CommandLine cmd -> cmd | Raft.Job.Authentication.TokenRefresh.MSAL secret -> - (sprintf "dotnet /raft-tools/auth/dotnet-core-3.1/AzureAuth.dll msal --secret \"%s\" --prepend-line \"{u'user1':{}}\"" secret) + (sprintf "dotnet /raft-tools/auth/dotnet-5.0/AzureAuth.dll msal --secret \"%s\" --prepend-line \"{u'user1':{}}\"" secret) | Raft.Job.Authentication.TokenRefresh.TxtToken secret -> - (sprintf "dotnet /raft-tools/auth/dotnet-core-3.1/AzureAuth.dll token --secret \"%s\" --prepend-line \"{u'user1':{}}\"" secret) + (sprintf "dotnet /raft-tools/auth/dotnet-5.0/AzureAuth.dll token --secret \"%s\" --prepend-line \"{u'user1':{}}\"" secret) } printfn "Refreshable token configuration : %A" authConfig Some authConfig diff --git a/src/Agent/RESTlerAgent/RestlerAgent.fsproj b/src/Agent/RESTlerAgent/RestlerAgent.fsproj index 39a0229..08c0d5b 100644 --- a/src/Agent/RESTlerAgent/RestlerAgent.fsproj +++ b/src/Agent/RESTlerAgent/RestlerAgent.fsproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net5.0 @@ -25,7 +25,7 @@ - + diff --git a/src/Agent/RaftResultAnalyzer/RaftResultAnalyzer.fsproj b/src/Agent/RaftResultAnalyzer/RaftResultAnalyzer.fsproj index df2dd84..00de9a8 100644 --- a/src/Agent/RaftResultAnalyzer/RaftResultAnalyzer.fsproj +++ b/src/Agent/RaftResultAnalyzer/RaftResultAnalyzer.fsproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net5.0 @@ -15,7 +15,7 @@ - + diff --git a/src/Orchestrator/Dockerfile b/src/Orchestrator/Dockerfile index 0951f0a..9e5a472 100644 --- a/src/Orchestrator/Dockerfile +++ b/src/Orchestrator/Dockerfile @@ -1,10 +1,5 @@ -# IMPORTANT NOTE: List of all function-docker images can be found here -# https://hub.docker.com/_/microsoft-azure-functions-dotnet -# See FULL TAG LISTING at the bottom of the page for list of available images and versions - -FROM mcr.microsoft.com/azure-functions/dotnet:3.0 - +FROM mcr.microsoft.com/azure-functions/dotnet-isolated:3.0-dotnet-isolated5.0 ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ - AzureFunctionsJobHost__Logging__Console__IsEnabled=true + AzureFunctionsJobHost__Logging__Console__IsEnabled=true -COPY . /home/site/wwwroot +COPY . /home/site/wwwroot \ No newline at end of file diff --git a/src/Orchestrator/Orchestrator/Orchestrator.cs b/src/Orchestrator/Orchestrator/Orchestrator.cs index 16600fd..4bee501 100644 --- a/src/Orchestrator/Orchestrator/Orchestrator.cs +++ b/src/Orchestrator/Orchestrator/Orchestrator.cs @@ -6,19 +6,51 @@ using System.Threading.Tasks; using Microsoft.ApplicationInsights; using Microsoft.Extensions.Logging; using Microsoft.Azure.ServiceBus.Core; -using Microsoft.Azure.WebJobs; + +using Microsoft.Azure.Functions.Worker; +using Microsoft.Extensions.Hosting; using Microsoft.Azure.ServiceBus; using Microsoft.Azure.Management.Fluent; using Microsoft.Azure.Management.ResourceManager.Fluent; using Microsoft.Azure.Cosmos.Table; using System.Collections.Generic; -using Microsoft.Azure.Management.AppService.Fluent.Models; -using Microsoft.Azure.Management.Monitor.Fluent.Models; -using Microsoft.Azure.WebJobs.Extensions.EventGrid; -using Microsoft.Azure.EventGrid.Models; + namespace OrchestratorFunc { + + public class EventGridEvent + { + public string Id { get; set; } + + public string Topic { get; set; } + + public string Subject { get; set; } + + public string EventType { get; set; } + + public DateTime EventTime { get; set; } + + public object Data { get; set; } + } + + public class TimerInfo + { + public TimerScheduleStatus ScheduleStatus { get; set; } + + public bool IsPastDue { get; set; } + } + + public class TimerScheduleStatus + { + public DateTime Last { get; set; } + + public DateTime Next { get; set; } + + public DateTime LastUpdated { get; set; } + } + + public static class Orchestrator { private static String GetSetting(String envVariableName) @@ -151,9 +183,10 @@ namespace OrchestratorFunc } } - [FunctionName("OnSecretChanged")] - public static void EventGridKeyVaultEvent([EventGridTrigger] EventGridEvent eventGridEvent, ILogger log) + [Function("OnSecretChanged")] + public static void EventGridKeyVaultEvent([EventGridTrigger] EventGridEvent eventGridEvent, FunctionContext context) { + var log = context.GetLogger("OnSecretChanged"); log.LogInformation("OnSecretChanged: " + eventGridEvent.Data.ToString()); azure = Authenticate(); @@ -166,11 +199,11 @@ namespace OrchestratorFunc log.LogInformation("OnSecretChanged: Secrets updated from Key Vault"); } - [FunctionName(Raft.Message.ServiceBus.Queue.create)] - public static async Task CreateJob([ServiceBusTrigger(Raft.Message.ServiceBus.Queue.create, IsSessionsEnabled = true)] string createJobMessage, ILogger log) + [Function(Raft.Message.ServiceBus.Queue.create)] + public static async Task CreateJob([ServiceBusTrigger(Raft.Message.ServiceBus.Queue.create, IsSessionsEnabled = true)] string createJobMessage, FunctionContext context) { await OrchestratorLogic.ContainerInstances.createJob( - log, + context.GetLogger("JobCreate"), secrets, dockerConfigs, toolConfigs, @@ -180,11 +213,11 @@ namespace OrchestratorFunc createJobMessage); } - [FunctionName(Raft.Message.ServiceBus.Queue.delete)] - public static async Task Delete([ServiceBusTrigger(Raft.Message.ServiceBus.Queue.delete, IsSessionsEnabled = true)]string deleteJobMessage, ILogger log) + [Function(Raft.Message.ServiceBus.Queue.delete)] + public static async Task Delete([ServiceBusTrigger(Raft.Message.ServiceBus.Queue.delete, IsSessionsEnabled = true)]string deleteJobMessage, FunctionContext context) { await OrchestratorLogic.ContainerInstances.delete( - log, + context.GetLogger("JobDelete"), azure, agentConfig, communicationClients, @@ -192,36 +225,49 @@ namespace OrchestratorFunc } - [FunctionName("jobstatus-handler")] - public static async Task Status([ServiceBusTrigger(Raft.Message.ServiceBus.Topic.events, "jobstatus-handler")]string statusMessage, ILogger log) + [Function("jobstatus-handler")] + public static async Task Status([ServiceBusTrigger(Raft.Message.ServiceBus.Topic.events, "jobstatus-handler")]string statusMessage, FunctionContext context) { await OrchestratorLogic.ContainerInstances.status( - log, + context.GetLogger("JobStatus"), azure, agentConfig, communicationClients, statusMessage); } - [FunctionName("webhooks-handler")] - public static async Task WebhookMessage([ServiceBusTrigger(Raft.Message.ServiceBus.Topic.events, "webhooks-handler")] string webhookMessage, ILogger log) + [Function("webhooks-handler")] + public static async Task WebhookMessage([ServiceBusTrigger(Raft.Message.ServiceBus.Topic.events, "webhooks-handler")] string webhookMessage, FunctionContext context) { await OrchestratorLogic.ContainerInstances.webhookMessage( - log, + context.GetLogger("Webhooks"), azure, agentConfig, communicationClients, webhookMessage); } - [FunctionName("raft-timer-garbage-collection")] - public static async Task TimerGarbageCollection([TimerTrigger("0 */1 * * * *")] TimerInfo t, ILogger log) + [Function("raft-timer-garbage-collection")] + public static async Task TimerGarbageCollection([TimerTrigger("0 */1 * * * *")] TimerInfo t, FunctionContext context) { await OrchestratorLogic.ContainerInstances.gc( - log, + context.GetLogger("GC"), azure, agentConfig, communicationClients); } } + + + public class Program + { + public static void Main() + { + var host = new HostBuilder() + .ConfigureFunctionsWorkerDefaults() + .Build(); + + host.Run(); + } + } } diff --git a/src/Orchestrator/Orchestrator/Orchestrator.csproj b/src/Orchestrator/Orchestrator/Orchestrator.csproj index 95f11e1..40d41ad 100644 --- a/src/Orchestrator/Orchestrator/Orchestrator.csproj +++ b/src/Orchestrator/Orchestrator/Orchestrator.csproj @@ -1,16 +1,21 @@ - netcoreapp3.1 + net5.0 +Exe v3 + + + + + + + - - - @@ -24,4 +29,4 @@ Never - \ No newline at end of file + diff --git a/src/Orchestrator/OrchestratorLogic/Dockerfile b/src/Orchestrator/OrchestratorLogic/Dockerfile index 889b61e..301d9cf 100644 --- a/src/Orchestrator/OrchestratorLogic/Dockerfile +++ b/src/Orchestrator/OrchestratorLogic/Dockerfile @@ -1,12 +1,7 @@ -# IMPORTANT NOTE: List of all function-docker images can be found here -# https://hub.docker.com/_/microsoft-azure-functions-base -# https://mcr.microsoft.com/v2/azure-functions/base/tags/list - # 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.0 - +# FROM mcr.microsoft.com/azure-functions/dotnet-isolated:3.0-dotnet-isolated5.0-appservice +FROM mcr.microsoft.com/azure-functions/dotnet-isolated:3.0-dotnet-isolated5.0 ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ - AzureFunctionsJobHost__Logging__Console__IsEnabled=true + AzureFunctionsJobHost__Logging__Console__IsEnabled=true -COPY . /home/site/wwwroot +COPY . /home/site/wwwroot \ No newline at end of file diff --git a/src/Orchestrator/OrchestratorLogic/OrchestratorLogic.fsproj b/src/Orchestrator/OrchestratorLogic/OrchestratorLogic.fsproj index 8fee1dd..38591db 100644 --- a/src/Orchestrator/OrchestratorLogic/OrchestratorLogic.fsproj +++ b/src/Orchestrator/OrchestratorLogic/OrchestratorLogic.fsproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 @@ -30,7 +30,7 @@ - + diff --git a/src/Test/Dockerfile b/src/Test/Dockerfile index 0951f0a..301d9cf 100644 --- a/src/Test/Dockerfile +++ b/src/Test/Dockerfile @@ -1,10 +1,7 @@ -# IMPORTANT NOTE: List of all function-docker images can be found here -# https://hub.docker.com/_/microsoft-azure-functions-dotnet -# See FULL TAG LISTING at the bottom of the page for list of available images and versions - -FROM mcr.microsoft.com/azure-functions/dotnet:3.0 - +# To enable ssh & remote debugging on app service change the base image to the one below +# FROM mcr.microsoft.com/azure-functions/dotnet-isolated:3.0-dotnet-isolated5.0-appservice +FROM mcr.microsoft.com/azure-functions/dotnet-isolated:3.0-dotnet-isolated5.0 ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ - AzureFunctionsJobHost__Logging__Console__IsEnabled=true + AzureFunctionsJobHost__Logging__Console__IsEnabled=true -COPY . /home/site/wwwroot +COPY . /home/site/wwwroot \ No newline at end of file diff --git a/src/Test/TestInfraFunc/TestInfra.cs b/src/Test/TestInfraFunc/TestInfra.cs index 695e6f5..cddd44b 100644 --- a/src/Test/TestInfraFunc/TestInfra.cs +++ b/src/Test/TestInfraFunc/TestInfra.cs @@ -1,11 +1,11 @@ using System; -using System.IO; +using System.Net; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Azure.WebJobs; -using Microsoft.Azure.WebJobs.Extensions.Http; -using Microsoft.AspNetCore.Http; +using Microsoft.Azure.Functions.Worker; +using Microsoft.Azure.Functions.Worker.Http; + using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Hosting; using Newtonsoft.Json; namespace TestInfraFunc @@ -19,10 +19,13 @@ namespace TestInfraFunc static private string StorageTableConnectionString = GetSetting("RAFT_STORAGE_TABLE_CONNECTION_STRING"); - [FunctionName("webhooks-trigger-test")] - public static async Task WebhookTriggerTest([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "test")] HttpRequest request, ILogger log) + [Function("webhooks-trigger-test")] + public static async Task WebhookTriggerTest([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "test")] HttpRequestData request, FunctionContext executionContext) { - string jobId = request.Query["jobId"]; + var log = executionContext.GetLogger("WebhooksTrigger"); + + var query = System.Web.HttpUtility.ParseQueryString(request.Url.Query); + string jobId = query["jobId"]; if (string.IsNullOrEmpty(jobId)) { @@ -37,18 +40,20 @@ namespace TestInfraFunc if (r.Item1) { log.LogInformation($"Returning validation code {r.Item2}"); - return new OkObjectResult(r.Item2); + var response = request.CreateResponse(HttpStatusCode.OK); + await response.WriteAsJsonAsync(r.Item2); + return response; } else { await TestInfraLogic.WebhooksTest.post(log, StorageTableConnectionString, text); - return new OkResult(); + return request.CreateResponse(HttpStatusCode.OK); } } else { log.LogWarning($"Unhandled request method {request.Method} when job id is not set"); - return new BadRequestResult(); + return request.CreateResponse(HttpStatusCode.BadRequest); } } else @@ -57,14 +62,30 @@ namespace TestInfraFunc { log.LogInformation($"Getting webhook messages for job {jobId}"); var results = await TestInfraLogic.WebhooksTest.get(log, StorageTableConnectionString, jobId); - return new OkObjectResult(results); + var response = request.CreateResponse(HttpStatusCode.OK); + await response.WriteAsJsonAsync(results); + return response; } else { log.LogWarning($"Unhandled request method {request.Method} when job id is {jobId}"); - return new BadRequestResult(); + + return request.CreateResponse(HttpStatusCode.BadRequest); } } } } + + public class Program + { + public static void Main() + { + var host = new HostBuilder() + .ConfigureFunctionsWorkerDefaults() + .Build(); + + host.Run(); + } + } + } diff --git a/src/Test/TestInfraFunc/TestInfraFunc.csproj b/src/Test/TestInfraFunc/TestInfraFunc.csproj index c1add84..93b5025 100644 --- a/src/Test/TestInfraFunc/TestInfraFunc.csproj +++ b/src/Test/TestInfraFunc/TestInfraFunc.csproj @@ -1,10 +1,15 @@ - + - netcoreapp3.1 + net5.0 + Exe + v3 - + + + + @@ -18,4 +23,4 @@ Never - \ No newline at end of file + diff --git a/src/Test/TestInfraLogic/Dockerfile b/src/Test/TestInfraLogic/Dockerfile index 889b61e..9e5a472 100644 --- a/src/Test/TestInfraLogic/Dockerfile +++ b/src/Test/TestInfraLogic/Dockerfile @@ -1,12 +1,5 @@ -# IMPORTANT NOTE: List of all function-docker images can be found here -# https://hub.docker.com/_/microsoft-azure-functions-base -# https://mcr.microsoft.com/v2/azure-functions/base/tags/list - -# 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.0 - +FROM mcr.microsoft.com/azure-functions/dotnet-isolated:3.0-dotnet-isolated5.0 ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ - AzureFunctionsJobHost__Logging__Console__IsEnabled=true + AzureFunctionsJobHost__Logging__Console__IsEnabled=true -COPY . /home/site/wwwroot +COPY . /home/site/wwwroot \ No newline at end of file diff --git a/src/Test/TestInfraLogic/TestInfraLogic.fsproj b/src/Test/TestInfraLogic/TestInfraLogic.fsproj index b514cd1..10a25db 100644 --- a/src/Test/TestInfraLogic/TestInfraLogic.fsproj +++ b/src/Test/TestInfraLogic/TestInfraLogic.fsproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/restler/Dockerfile b/src/restler/Dockerfile index 017546b..da378ae 100644 --- a/src/restler/Dockerfile +++ b/src/restler/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine +FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine COPY ./compiler /RESTler/compiler COPY ./restler /RESTler/restler