From bdaba659bb13daca47daed063fbfbbf1a7279ae3 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 28 Apr 2020 14:50:55 -0700 Subject: [PATCH 001/111] squash build / ci / checkin migrations --- Microsoft.Azure.Devices.Edge.sln | 41 +- builds/checkin/dotnet.yaml | 8 +- builds/ci/dotnet.yaml | 20 +- builds/misc/images-release.yaml | 639 ++++++++ builds/misc/images.yaml | 168 +- builds/misc/templates/image-linux.yaml | 8 +- builds/templates/install-dotnet3.yaml | 6 + dotnetVersion.props | 5 + edge-agent/docker/linux/amd64/Dockerfile | 4 +- edge-agent/docker/linux/arm32v7/Dockerfile | 2 +- .../docker/linux/arm32v7/base/Dockerfile | 4 +- edge-agent/docker/linux/arm64v8/Dockerfile | 2 +- .../docker/linux/arm64v8/base/Dockerfile | 5 +- edge-agent/docker/windows/amd64/Dockerfile | 4 +- edge-agent/docker/windows/arm32v7/Dockerfile | 2 +- .../docker/windows/arm32v7/base/Dockerfile | 2 +- ...osoft.Azure.Devices.Edge.Agent.Core.csproj | 5 +- ...zure.Devices.Edge.Agent.Diagnostics.csproj | 9 +- ...oft.Azure.Devices.Edge.Agent.Docker.csproj | 5 +- ...e.Devices.Edge.Agent.Edgelet.Docker.csproj | 3 +- ...ft.Azure.Devices.Edge.Agent.Edgelet.csproj | 5 +- .../ModuleManagementHttpClient.cs | 2 +- .../ModuleManagementHttpClient.cs | 2 +- .../ModuleManagementHttpClient.cs | 2 +- ...oft.Azure.Devices.Edge.Agent.IoTHub.csproj | 3 +- ...Azure.Devices.Edge.Agent.Kubernetes.csproj | 8 +- ...ft.Azure.Devices.Edge.Agent.Service.csproj | 14 +- ....Azure.Devices.Edge.Agent.Core.Test.csproj | 8 +- .../commands/LoggingCommandFactoryTest.cs | 16 +- ...Devices.Edge.Agent.Diagnostics.Test.csproj | 8 +- ....Devices.Edge.Agent.Docker.E2E.Test.csproj | 12 +- ...zure.Devices.Edge.Agent.Docker.Test.csproj | 8 +- ...ices.Edge.Agent.Edgelet.Docker.Test.csproj | 8 +- .../EdgeletFixture.cs | 17 +- ...ure.Devices.Edge.Agent.Edgelet.Test.csproj | 19 +- .../TestServer/Startup.cs | 14 +- ...Devices.Edge.Agent.Integration.Test.csproj | 12 +- ...zure.Devices.Edge.Agent.IoTHub.Test.csproj | 9 +- ...ge.Agent.Kubernetes.IntegrationTest.csproj | 10 +- ....Devices.Edge.Agent.Kubernetes.Test.csproj | 15 +- edge-hub/docker/linux/amd64/Dockerfile | 6 +- edge-hub/docker/linux/arm32v7/Dockerfile | 2 +- edge-hub/docker/linux/arm32v7/base/Dockerfile | 4 +- edge-hub/docker/linux/arm64v8/Dockerfile | 2 +- edge-hub/docker/linux/arm64v8/base/Dockerfile | 4 +- edge-hub/docker/windows/amd64/Dockerfile | 4 +- edge-hub/docker/windows/arm32v7/Dockerfile | 2 +- .../docker/windows/arm32v7/base/Dockerfile | 2 +- ...crosoft.Azure.Devices.Edge.Hub.Amqp.csproj | 3 +- ...t.Azure.Devices.Edge.Hub.CloudProxy.csproj | 3 +- ...crosoft.Azure.Devices.Edge.Hub.Core.csproj | 3 +- .../HttpProtocolHead.cs | 14 +- ...crosoft.Azure.Devices.Edge.Hub.Http.csproj | 3 +- .../DeviceIdentityProvider.cs | 4 +- ...crosoft.Azure.Devices.Edge.Hub.Mqtt.csproj | 5 +- .../Hosting.cs | 66 +- ...soft.Azure.Devices.Edge.Hub.Service.csproj | 19 +- .../Program.cs | 2 +- .../Startup.cs | 9 +- ...icrosoft.Azure.Devices.Routing.Core.csproj | 3 +- ...ft.Azure.Devices.Edge.Hub.Amqp.Test.csproj | 8 +- ...re.Devices.Edge.Hub.CloudProxy.Test.csproj | 8 +- ...ft.Azure.Devices.Edge.Hub.Core.Test.csproj | 8 +- ...oft.Azure.Devices.Edge.Hub.E2E.Test.csproj | 8 +- .../ProtocolHeadFixture.cs | 2 +- ...ft.Azure.Devices.Edge.Hub.Http.Test.csproj | 8 +- ...ft.Azure.Devices.Edge.Hub.Mqtt.Test.csproj | 8 +- ...Azure.Devices.Edge.Hub.Service.Test.csproj | 8 +- ...oft.Azure.Devices.Routing.Core.Test.csproj | 8 +- .../query/ConditionCompilerTest.cs | 5 +- .../MetricsCollector/MetricsCollector.csproj | 20 +- .../docker/linux/amd64/Dockerfile | 2 +- .../docker/linux/arm32v7/Dockerfile | 2 +- .../docker/linux/arm64v8/Dockerfile | 2 +- .../docker/windows/amd64/Dockerfile | 2 +- .../docker/windows/arm32v7/Dockerfile | 2 +- .../SimulatedTemperatureSensor.csproj | 20 +- .../docker/linux/amd64/Dockerfile | 2 +- .../docker/linux/arm32v7/Dockerfile | 2 +- .../docker/linux/arm32v7/base/Dockerfile | 2 +- .../docker/linux/arm64v8/Dockerfile | 2 +- .../docker/linux/arm64v8/base/Dockerfile | 2 +- .../docker/windows/amd64/Dockerfile | 2 +- .../docker/windows/arm32v7/Dockerfile | 2 +- .../docker/windows/arm32v7/base/Dockerfile | 2 +- ...ft.Azure.WebJobs.Extensions.EdgeHub.csproj | 6 +- .../EdgeHubTriggerCSharp.csproj | 6 +- ....Azure.Devices.Edge.Storage.RocksDb.csproj | 3 +- ...icrosoft.Azure.Devices.Edge.Storage.csproj | 3 +- .../Microsoft.Azure.Devices.Edge.Util.csproj | 5 +- .../SslProtocolsHelper.cs | 9 - .../generatedCode/HttpWorkloadClient.cs | 1432 +++++++---------- .../generatedCode/HttpWorkloadClient.cs | 1431 +++++++--------- ...e.Devices.Edge.Storage.RocksDb.Test.csproj | 8 +- ...oft.Azure.Devices.Edge.Storage.Test.csproj | 8 +- ...Azure.Devices.Edge.Util.Test.Common.csproj | 9 +- ...rosoft.Azure.Devices.Edge.Util.Test.csproj | 19 +- .../Controllers/Controller.cs | 892 ++++------ .../workloadtestserver/Startup.cs | 14 +- .../workloadtestserver/WorkloadFixture.cs | 17 +- .../WorkloadTestImplementation.cs | 4 +- .../EdgeDownstreamDevice.csproj | 8 +- .../EdgeX509AuthDownstreamDevice.csproj | 4 +- .../Microsoft.Azure.Devices.Edge.Samples.sln | 36 - ...Azure.Devices.Edge.Samples.sln.DotSettings | 6 - scripts/linux/buildBranch.sh | 9 +- scripts/linux/buildManifest.sh | 11 +- scripts/linux/installPrereqs.sh | 49 +- scripts/linux/runTests.sh | 4 + scripts/windows/build/Publish-Branch.ps1 | 35 +- .../windows/setup/Install-Prerequisites.ps1 | 30 +- .../IotEdgeQuickstart.csproj | 8 +- smoke/LeafDevice/LeafDevice.csproj | 8 +- stylecop.props | 2 +- stylecop.ruleset | 4 + ...soft.Azure.Devices.Edge.Test.Common.csproj | 10 +- .../Microsoft.Azure.Devices.Edge.Test.csproj | 14 +- .../Provisioning.cs | 1 - .../NetworkController.csproj | 16 +- .../NetworkStatusReporter.cs | 1 - .../docker/linux/amd64/Dockerfile | 2 +- .../docker/linux/arm32v7/base/Dockerfile | 2 +- .../docker/linux/arm64v8/Dockerfile | 2 +- .../docker/windows/amd64/Dockerfile | 2 +- .../docker/windows/arm32v7/Dockerfile | 2 +- .../CloudToDeviceMessageTester.csproj | 20 +- .../docker/linux/amd64/Dockerfile | 2 +- .../docker/linux/arm32v7/Dockerfile | 2 +- .../docker/linux/arm64v8/Dockerfile | 2 +- .../docker/windows/amd64/Dockerfile | 2 +- .../docker/windows/arm32v7/Dockerfile | 2 +- .../DeploymentTester/DeploymentTester.csproj | 22 +- .../docker/linux/amd64/Dockerfile | 2 +- .../docker/linux/arm32v7/Dockerfile | 2 +- .../docker/linux/arm64v8/Dockerfile | 2 +- .../docker/windows/amd64/Dockerfile | 2 +- .../docker/windows/arm32v7/Dockerfile | 2 +- .../DirectMethodReceiver.csproj | 20 +- .../docker/linux/amd64/Dockerfile | 2 +- .../docker/linux/arm32v7/Dockerfile | 2 +- .../docker/linux/arm64v8/Dockerfile | 2 +- .../docker/windows/amd64/Dockerfile | 2 +- .../docker/windows/arm32v7/Dockerfile | 2 +- .../DirectMethodSender.csproj | 20 +- .../docker/linux/amd64/Dockerfile | 2 +- .../docker/linux/arm32v7/Dockerfile | 2 +- .../docker/linux/arm64v8/Dockerfile | 2 +- .../docker/windows/amd64/Dockerfile | 2 +- .../docker/windows/arm32v7/Dockerfile | 2 +- .../EdgeHubRestartTester.csproj | 20 +- .../docker/linux/arm32v7/Dockerfile | 2 +- .../docker/linux/arm64v8/Dockerfile | 2 +- .../MetricsValidator/MetricsValidator.csproj | 19 +- .../docker/linux/amd64/Dockerfile | 2 +- .../docker/linux/arm32v7/Dockerfile | 2 +- .../docker/linux/arm64v8/Dockerfile | 2 +- .../docker/windows/amd64/Dockerfile | 2 +- .../docker/windows/arm32v7/Dockerfile | 2 +- ...osoft.Azure.Devices.Edge.ModuleUtil.csproj | 10 +- .../ModuleRestarter/ModuleRestarter.csproj | 20 +- .../docker/linux/arm32v7/Dockerfile | 2 +- .../docker/linux/arm64v8/Dockerfile | 2 +- test/modules/Modules.Test/Modules.Test.csproj | 8 +- test/modules/Relayer/Relayer.csproj | 22 +- .../Relayer/docker/linux/amd64/Dockerfile | 2 +- .../Relayer/docker/linux/arm32v7/Dockerfile | 2 +- .../Relayer/docker/linux/arm64v8/Dockerfile | 2 +- .../Relayer/docker/windows/amd64/Dockerfile | 2 +- .../Relayer/docker/windows/arm32v7/Dockerfile | 2 +- .../TemperatureFilter.csproj | 18 +- .../docker/linux/amd64/Dockerfile | 2 +- .../docker/linux/arm32v7/Dockerfile | 2 +- .../docker/linux/arm64v8/Dockerfile | 2 +- .../docker/windows/amd64/Dockerfile | 2 +- .../docker/windows/arm32v7/Dockerfile | 2 +- test/modules/TestAnalyzer/Program.cs | 16 +- test/modules/TestAnalyzer/Startup.cs | 14 +- test/modules/TestAnalyzer/TestAnalyzer.csproj | 30 +- .../docker/linux/amd64/Dockerfile | 4 +- .../docker/linux/arm32v7/Dockerfile | 4 +- .../docker/linux/arm32v7/base/Dockerfile | 4 +- .../docker/linux/arm64v8/Dockerfile | 4 +- .../docker/linux/arm64v8/base/Dockerfile | 4 +- .../docker/windows/amd64/Dockerfile | 4 +- .../docker/windows/arm32v7/Dockerfile | 2 +- test/modules/TestResultCoordinator/Program.cs | 18 +- test/modules/TestResultCoordinator/Startup.cs | 8 +- .../TestResultCoordinator.csproj | 20 +- .../docker/linux/amd64/Dockerfile | 4 +- .../docker/linux/arm32v7/Dockerfile | 4 +- .../docker/linux/arm64v8/Dockerfile | 4 +- .../docker/windows/amd64/Dockerfile | 4 +- .../docker/windows/arm32v7/Dockerfile | 2 +- test/modules/TwinTester/TwinTester.csproj | 22 +- .../TwinTester/docker/linux/amd64/Dockerfile | 2 +- .../docker/linux/arm32v7/Dockerfile | 2 +- .../docker/linux/arm64v8/Dockerfile | 2 +- .../docker/windows/amd64/Dockerfile | 2 +- .../docker/windows/arm32v7/Dockerfile | 2 +- .../load-gen/docker/linux/amd64/Dockerfile | 2 +- .../load-gen/docker/linux/arm32v7/Dockerfile | 2 +- .../load-gen/docker/linux/arm64v8/Dockerfile | 2 +- .../load-gen/docker/windows/amd64/Dockerfile | 2 +- .../docker/windows/arm32v7/Dockerfile | 2 +- test/modules/load-gen/load-gen.csproj | 22 +- 205 files changed, 2620 insertions(+), 3434 deletions(-) create mode 100644 builds/misc/images-release.yaml create mode 100644 builds/templates/install-dotnet3.yaml create mode 100644 dotnetVersion.props delete mode 100644 samples/dotnet/Microsoft.Azure.Devices.Edge.Samples.sln delete mode 100644 samples/dotnet/Microsoft.Azure.Devices.Edge.Samples.sln.DotSettings diff --git a/Microsoft.Azure.Devices.Edge.sln b/Microsoft.Azure.Devices.Edge.sln index df1fcc6c987..430f1431164 100644 --- a/Microsoft.Azure.Devices.Edge.sln +++ b/Microsoft.Azure.Devices.Edge.sln @@ -219,7 +219,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MetricsValidator", "test\mo EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EdgeHubRestartTester", "test\modules\EdgeHubRestartTester\EdgeHubRestartTester.csproj", "{DA073067-83EF-4F4C-8E58-51CA7870C1F6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudToDeviceMessageTester", "test\modules\CloudToDeviceMessageTester\CloudToDeviceMessageTester.csproj", "{446F50F3-3E93-454B-8EBF-4830E92DFE5D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CloudToDeviceMessageTester", "test\modules\CloudToDeviceMessageTester\CloudToDeviceMessageTester.csproj", "{446F50F3-3E93-454B-8EBF-4830E92DFE5D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{C077918C-9AD4-4F01-ADED-4B8B6AB784A2}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dotnet", "dotnet", "{A6D8677F-DB76-459E-B6DE-110AFCEF7F08}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EdgeDownstreamDevice", "samples\dotnet\EdgeDownstreamDevice\EdgeDownstreamDevice.csproj", "{7546DB89-643A-477F-AEE3-FA05BDCE4ACD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EdgeX509AuthDownstreamDevice", "samples\dotnet\EdgeX509AuthDownstreamDevice\EdgeX509AuthDownstreamDevice.csproj", "{9E809F78-0EFF-4860-94D1-8D0EF1A9C1F1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -590,18 +598,10 @@ Global {1C1C8203-CD73-4CC1-9112-7315F9DE1AB6}.Release|Any CPU.Build.0 = Release|Any CPU {B3C68519-B309-42FF-B4DF-9E77B2D4BD50}.CheckInBuild|Any CPU.ActiveCfg = CheckInBuild|Any CPU {B3C68519-B309-42FF-B4DF-9E77B2D4BD50}.CheckInBuild|Any CPU.Build.0 = CheckInBuild|Any CPU - {B3C68519-B309-42FF-B4DF-9E77B2D4BD50}.CodeCoverage|Any CPU.ActiveCfg = CodeCoverage|Any CPU - {B3C68519-B309-42FF-B4DF-9E77B2D4BD50}.CodeCoverage|Any CPU.Build.0 = CodeCoverage|Any CPU {B3C68519-B309-42FF-B4DF-9E77B2D4BD50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B3C68519-B309-42FF-B4DF-9E77B2D4BD50}.Debug|Any CPU.Build.0 = Debug|Any CPU {B3C68519-B309-42FF-B4DF-9E77B2D4BD50}.Release|Any CPU.ActiveCfg = Release|Any CPU {B3C68519-B309-42FF-B4DF-9E77B2D4BD50}.Release|Any CPU.Build.0 = Release|Any CPU - {446F50F3-3E93-454B-8EBF-4830E92DFE5D}.CheckInBuild|Any CPU.ActiveCfg = Debug|Any CPU - {446F50F3-3E93-454B-8EBF-4830E92DFE5D}.CheckInBuild|Any CPU.Build.0 = Debug|Any CPU - {446F50F3-3E93-454B-8EBF-4830E92DFE5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {446F50F3-3E93-454B-8EBF-4830E92DFE5D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {446F50F3-3E93-454B-8EBF-4830E92DFE5D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {446F50F3-3E93-454B-8EBF-4830E92DFE5D}.Release|Any CPU.Build.0 = Release|Any CPU {5857DB4A-F61A-4467-96F1-003B47B8B2CF}.CheckInBuild|Any CPU.ActiveCfg = CheckInBuild|Any CPU {5857DB4A-F61A-4467-96F1-003B47B8B2CF}.CheckInBuild|Any CPU.Build.0 = CheckInBuild|Any CPU {5857DB4A-F61A-4467-96F1-003B47B8B2CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -610,12 +610,28 @@ Global {5857DB4A-F61A-4467-96F1-003B47B8B2CF}.Release|Any CPU.Build.0 = Release|Any CPU {DA073067-83EF-4F4C-8E58-51CA7870C1F6}.CheckInBuild|Any CPU.ActiveCfg = CheckInBuild|Any CPU {DA073067-83EF-4F4C-8E58-51CA7870C1F6}.CheckInBuild|Any CPU.Build.0 = CheckInBuild|Any CPU - {DA073067-83EF-4F4C-8E58-51CA7870C1F6}.CodeCoverage|Any CPU.ActiveCfg = CodeCoverage|Any CPU - {DA073067-83EF-4F4C-8E58-51CA7870C1F6}.CodeCoverage|Any CPU.Build.0 = CodeCoverage|Any CPU {DA073067-83EF-4F4C-8E58-51CA7870C1F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DA073067-83EF-4F4C-8E58-51CA7870C1F6}.Debug|Any CPU.Build.0 = Debug|Any CPU {DA073067-83EF-4F4C-8E58-51CA7870C1F6}.Release|Any CPU.ActiveCfg = Release|Any CPU {DA073067-83EF-4F4C-8E58-51CA7870C1F6}.Release|Any CPU.Build.0 = Release|Any CPU + {446F50F3-3E93-454B-8EBF-4830E92DFE5D}.CheckInBuild|Any CPU.ActiveCfg = CheckInBuild|Any CPU + {446F50F3-3E93-454B-8EBF-4830E92DFE5D}.CheckInBuild|Any CPU.Build.0 = CheckInBuild|Any CPU + {446F50F3-3E93-454B-8EBF-4830E92DFE5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {446F50F3-3E93-454B-8EBF-4830E92DFE5D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {446F50F3-3E93-454B-8EBF-4830E92DFE5D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {446F50F3-3E93-454B-8EBF-4830E92DFE5D}.Release|Any CPU.Build.0 = Release|Any CPU + {7546DB89-643A-477F-AEE3-FA05BDCE4ACD}.CheckInBuild|Any CPU.ActiveCfg = CheckInBuild|Any CPU + {7546DB89-643A-477F-AEE3-FA05BDCE4ACD}.CheckInBuild|Any CPU.Build.0 = CheckInBuild|Any CPU + {7546DB89-643A-477F-AEE3-FA05BDCE4ACD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7546DB89-643A-477F-AEE3-FA05BDCE4ACD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7546DB89-643A-477F-AEE3-FA05BDCE4ACD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7546DB89-643A-477F-AEE3-FA05BDCE4ACD}.Release|Any CPU.Build.0 = Release|Any CPU + {9E809F78-0EFF-4860-94D1-8D0EF1A9C1F1}.CheckInBuild|Any CPU.ActiveCfg = CheckInBuild|Any CPU + {9E809F78-0EFF-4860-94D1-8D0EF1A9C1F1}.CheckInBuild|Any CPU.Build.0 = CheckInBuild|Any CPU + {9E809F78-0EFF-4860-94D1-8D0EF1A9C1F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E809F78-0EFF-4860-94D1-8D0EF1A9C1F1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E809F78-0EFF-4860-94D1-8D0EF1A9C1F1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E809F78-0EFF-4860-94D1-8D0EF1A9C1F1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -704,6 +720,9 @@ Global {5857DB4A-F61A-4467-96F1-003B47B8B2CF} = {F921339B-32F9-4BF3-B364-2DB01FA2F1A1} {DA073067-83EF-4F4C-8E58-51CA7870C1F6} = {F921339B-32F9-4BF3-B364-2DB01FA2F1A1} {446F50F3-3E93-454B-8EBF-4830E92DFE5D} = {F921339B-32F9-4BF3-B364-2DB01FA2F1A1} + {A6D8677F-DB76-459E-B6DE-110AFCEF7F08} = {C077918C-9AD4-4F01-ADED-4B8B6AB784A2} + {7546DB89-643A-477F-AEE3-FA05BDCE4ACD} = {A6D8677F-DB76-459E-B6DE-110AFCEF7F08} + {9E809F78-0EFF-4860-94D1-8D0EF1A9C1F1} = {A6D8677F-DB76-459E-B6DE-110AFCEF7F08} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D71830F5-3AF5-46B4-8A9E-1DCE4F2253AC} diff --git a/builds/checkin/dotnet.yaml b/builds/checkin/dotnet.yaml index b5c898ad1cf..c53b8a2d245 100644 --- a/builds/checkin/dotnet.yaml +++ b/builds/checkin/dotnet.yaml @@ -31,11 +31,11 @@ jobs: pool: vmImage: "ubuntu-16.04" steps: + - template: ../templates/install-dotnet3.yaml - task: Bash@3 - displayName: Install + displayName: Install Prerequisites inputs: filePath: scripts/linux/installPrereqs.sh - arguments: -u $(NetCorePackageUriLinux) - task: Bash@3 displayName: Build inputs: @@ -62,11 +62,11 @@ jobs: pool: vmImage: "vs2017-win2016" steps: + - template: ../templates/install-dotnet3.yaml - task: PowerShell@2 - displayName: Install + displayName: Install Prerequisites inputs: filePath: scripts/windows/setup/Install-Prerequisites.ps1 - arguments: -DotnetSdkUrl $(NetCorePackageUriWindows) -Dotnet -Nuget - task: PowerShell@2 displayName: Build inputs: diff --git a/builds/ci/dotnet.yaml b/builds/ci/dotnet.yaml index 0ac6e90e28a..158919c9f1c 100644 --- a/builds/ci/dotnet.yaml +++ b/builds/ci/dotnet.yaml @@ -7,7 +7,6 @@ trigger: pr: none variables: build.configuration: Release - dotnet.version: 2.1.x test.filter: Category=Integration&Category!=Stress jobs: - job: linux @@ -31,15 +30,12 @@ jobs: IotDevice3ConnStr2, IotHubConnStr2, IotHubMqttHeadCert - - task: UseDotNet@2 - displayName: Install .NET Core sdk + - template: ../templates/install-dotnet3.yaml + - task: Bash@3 + displayName: Install Prerequisites needed for RocksDB integration tests inputs: - packageType: sdk - version: $(dotnet.version) - - script: | - sudo apt-get update - sudo apt-get install -y libsnappy1v5 - displayName: Install libsnappy1v5 # Needed for rocksdb integration tests + filePath: scripts/linux/installPrereqs.sh + arguments: -u $(NetCorePackageUriLinux) - pwsh: | $store = [System.Security.Cryptography.X509Certificates.X509Store]::new('Root', 'CurrentUser') $store.Open('ReadWrite') @@ -110,11 +106,7 @@ jobs: IotDevice3ConnStr2, IotHubConnStr2, IotHubMqttHeadCert - - task: UseDotNet@2 - displayName: Install .NET Core sdk - inputs: - packageType: sdk - version: $(dotnet.version) + - template: ../templates/install-dotnet3.yaml - powershell: scripts/windows/build/Publish-Branch.ps1 -Configuration $(Build.Configuration) -UpdateVersion displayName: Build - powershell: scripts/windows/test/Test-Branch.ps1 -Filter "$(test.filter)&Category!=Kubernetes" -BuildConfig $(Build.Configuration) diff --git a/builds/misc/images-release.yaml b/builds/misc/images-release.yaml new file mode 100644 index 00000000000..9aa0fbd9f22 --- /dev/null +++ b/builds/misc/images-release.yaml @@ -0,0 +1,639 @@ +#Your build pipeline references a secret variable named ‘build.registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 +#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 +#Your build pipeline references the ‘configuration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 +#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 +#Your build pipeline references the ‘version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 +#Your build pipeline references the ‘configuration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 +#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 +#Your build pipeline references the ‘version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 +#Your build pipeline references the ‘configuration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 +#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 +#Your build pipeline references the ‘version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 +#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 +#Your build pipeline references the ‘version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 +#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 +#Your build pipeline references the ‘version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 +#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 +#Your build pipeline references the ‘version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 +#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 +#Your build pipeline references the ‘version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 +#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 +#Your build pipeline references the ‘version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 +#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 +#Your build pipeline references the ‘version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 +jobs: + - job: linux_dotnet_projects + displayName: LinuxDotnet + pool: + name: "Hosted Ubuntu 1604" + steps: + - bash: | + docker login '$(build.registry.address)' --username '$(build.registry.user)' --password '$(build.registry.password)' + docker login '$(registry.address)' --username '$(registry.user)' --password '$(registry.password)' + displayName: 'Docker Login' + - displayName: "Install Rust" + inputs: + arguments: "--package-arm" + filePath: ./edgelet/build/linux/install.sh + targetType: filePath + task: Bash@3 + - bash: "echo \"##vso[task.setvariable variable=PATH;]$HOME/.cargo/bin:$PATH\"" + displayName: "Modify path" + - displayName: "Install .NET Core - 3.1.3" + inputs: + version: "3.1.201" + task: DotNetCoreInstaller@0 + - displayName: "Install build prerequisites" + inputs: + scriptPath: scripts/linux/installPrereqs.sh + task: ShellScript@2 + - bash: "cargo install --git https://github.com/arsing/cross.git --branch set-path" + displayName: "Install cross (fork with docker fix)" + - displayName: "Build Azure-IoT-Edge-Core" + inputs: + args: "-c Release" + scriptPath: scripts/linux/buildBranch.sh + task: ShellScript@2 + - displayName: "Install .NET Core 2.1" + inputs: + version: "2.1.700" + task: DotNetCoreInstaller@0 + - displayName: "Edge Agent Code Sign" + inputs: + ConnectedServiceName: "Azure IoT Edge Code Sign 2" + FolderPath: $(Build.BinariesDirectory)/publish/Microsoft.Azure.Devices.Edge.Agent.Service + Pattern: Microsoft.Azure.Devices.Edge.*.dll + SessionTimeout: 20 + inlineOperation: | + [ + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolSign", + "parameters": [ + { + "parameterName": "OpusName", + "parameterValue": "Microsoft" + }, + { + "parameterName": "OpusInfo", + "parameterValue": "http://www.microsoft.com" + }, + { + "parameterName": "Append", + "parameterValue": "/as" + }, + { + "parameterName": "FileDigest", + "parameterValue": "/fd \"SHA256\"" + }, + { + "parameterName": "PageHash", + "parameterValue": "/NPH" + }, + { + "parameterName": "TimeStamp", + "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" + } + ], + "toolName": "sign", + "toolVersion": "1.0" + }, + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolVerify", + "parameters": [ + { + "parameterName": "VerifyAll", + "parameterValue": "/all" + } + ], + "toolName": "sign", + "toolVersion": "1.0" + } + ] + signConfigType: inlineSignParams + task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + - displayName: "Edge Hub Code Sign" + inputs: + ConnectedServiceName: "Azure IoT Edge Code Sign 2" + FolderPath: $(Build.BinariesDirectory)/publish/Microsoft.Azure.Devices.Edge.Hub.Service + Pattern: "Microsoft.Azure.Devices.Edge.*.dll,Microsoft.Azure.Devices.Routing.*.dll" + SessionTimeout: 20 + inlineOperation: | + [ + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolSign", + "parameters": [ + { + "parameterName": "OpusName", + "parameterValue": "Microsoft" + }, + { + "parameterName": "OpusInfo", + "parameterValue": "http://www.microsoft.com" + }, + { + "parameterName": "Append", + "parameterValue": "/as" + }, + { + "parameterName": "FileDigest", + "parameterValue": "/fd \"SHA256\"" + }, + { + "parameterName": "PageHash", + "parameterValue": "/NPH" + }, + { + "parameterName": "TimeStamp", + "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" + } + ], + "toolName": "sign", + "toolVersion": "1.0" + }, + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolVerify", + "parameters": [ + { + "parameterName": "VerifyAll", + "parameterValue": "/all" + } + ], + "toolName": "sign", + "toolVersion": "1.0" + } + ] + signConfigType: inlineSignParams + task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + - displayName: "Temp Sensor Code Sign" + inputs: + ConnectedServiceName: "Azure IoT Edge Code Sign 2" + FolderPath: $(Build.BinariesDirectory)/publish/SimulatedTemperatureSensor + Pattern: "Microsoft.Azure.Devices.Edge.*.dll,SimulatedTemperatureSensor.dll" + SessionTimeout: 20 + inlineOperation: | + [ + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolSign", + "parameters": [ + { + "parameterName": "OpusName", + "parameterValue": "Microsoft" + }, + { + "parameterName": "OpusInfo", + "parameterValue": "http://www.microsoft.com" + }, + { + "parameterName": "Append", + "parameterValue": "/as" + }, + { + "parameterName": "FileDigest", + "parameterValue": "/fd \"SHA256\"" + }, + { + "parameterName": "PageHash", + "parameterValue": "/NPH" + }, + { + "parameterName": "TimeStamp", + "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" + } + ], + "toolName": "sign", + "toolVersion": "1.0" + }, + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolVerify", + "parameters": [ + { + "parameterName": "VerifyAll", + "parameterValue": "/all" + } + ], + "toolName": "sign", + "toolVersion": "1.0" + } + ] + signConfigType: inlineSignParams + task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + - displayName: "Functions Binding Code Sign" + inputs: + ConnectedServiceName: "Azure IoT Edge Code Sign 2" + FolderPath: $(Build.BinariesDirectory)/publish/Microsoft.Azure.WebJobs.Extensions.EdgeHub + Pattern: Microsoft.Azure.WebJobs.Extensions*.dll + SessionTimeout: 20 + inlineOperation: | + [ + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolSign", + "parameters": [ + { + "parameterName": "OpusName", + "parameterValue": "Microsoft" + }, + { + "parameterName": "OpusInfo", + "parameterValue": "http://www.microsoft.com" + }, + { + "parameterName": "Append", + "parameterValue": "/as" + }, + { + "parameterName": "FileDigest", + "parameterValue": "/fd \"SHA256\"" + }, + { + "parameterName": "PageHash", + "parameterValue": "/NPH" + }, + { + "parameterName": "TimeStamp", + "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" + } + ], + "toolName": "sign", + "toolVersion": "1.0" + }, + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolVerify", + "parameters": [ + { + "parameterName": "VerifyAll", + "parameterValue": "/all" + } + ], + "toolName": "sign", + "toolVersion": "1.0" + } + ] + signConfigType: inlineSignParams + task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + - displayName: "Install .NET Core - 3.1.3" + inputs: + version: "3.1.201" + task: DotNetCoreInstaller@0 + - displayName: "Functions Binding nuget package" + inputs: + buildProperties: OutDir=$(Build.BinariesDirectory)/publish/Microsoft.Azure.WebJobs.Extensions.EdgeHub + command: pack + nobuild: true + packDirectory: $(Build.BinariesDirectory)/publish/ + packagesToPack: "**/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj" + versionEnvVar: version + versioningScheme: byEnvVar + task: DotNetCoreCLI@2 + - displayName: "Install .NET Core 2.1" + inputs: + version: "2.1.700" + task: DotNetCoreInstaller@0 + - displayName: "Functions Binding nuget package Sign" + inputs: + ConnectedServiceName: "Azure IoT Edge Code Sign 2" + FolderPath: $(Build.BinariesDirectory)/publish + Pattern: Microsoft.Azure.WebJobs.Extensions*.nupkg + inlineOperation: | + [ + { + "keyCode": "CP-401405", + "operationSetCode": "NuGetSign", + "parameters": [], + "toolName": "sign", + "toolVersion": "1.0" + }, + { + "keyCode": "CP-401405", + "operationSetCode": "NuGetVerify", + "parameters": [], + "toolName": "sign", + "toolVersion": "1.0" + } + ] + signConfigType: inlineSignParams + task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + - displayName: "Build iotedge-diagnostics" + inputs: + arguments: "-i azureiotedge-diagnostics -n microsoft -P iotedge-diagnostics -c $(Build.Configuration)" + filePath: ./scripts/linux/buildEdgelet.sh + targetType: filePath + task: Bash@3 + - bash: | + scripts/linux/buildEdgelet.sh -i azureiotedge-diagnostics -n microsoft -P iotedge-diagnostics -c $(configuration) && + scripts/linux/buildImage.sh -r $(registry.address) -u $(registry.user) -p $(registry.password) -v $(version) -i azureiotedge-diagnostics -n $(namespace) -P azureiotedge-diagnostics + displayName: 'Build Image - azureiotedge-diagnostics - amd64' + - bash: | + scripts/linux/buildEdgelet.sh -i azureiotedge-diagnostics -n microsoft -P iotedge-diagnostics -c $(configuration) --target-arch armv7l && + scripts/linux/buildImage.sh -r $(registry.address) -u $(registry.user) -p $(registry.password) -v $(version) -i azureiotedge-diagnostics -n $(namespace) -P azureiotedge-diagnostics --target-arch armv7l + displayName: 'Build Image - azureiotedge-diagnostics - ARM32' + - bash: | + scripts/linux/buildEdgelet.sh -i azureiotedge-diagnostics -n microsoft -P iotedge-diagnostics -c $(configuration) --target-arch aarch64 && + scripts/linux/buildImage.sh -r $(registry.address) -u $(registry.user) -p $(registry.password) -v $(version) -i azureiotedge-diagnostics -n $(namespace) -P azureiotedge-diagnostics --target-arch aarch64 + displayName: 'Build Image - azureiotedge-diagnostics - ARM64' + - parameters: + imageName: azureiotedge-agent + name: "Edge Agent" + project: Microsoft.Azure.Devices.Edge.Agent.Service + template: templates/image-linux.yaml + - parameters: + imageName: azureiotedge-hub + name: "Edge Hub" + project: Microsoft.Azure.Devices.Edge.Hub.Service + template: templates/image-linux.yaml + - parameters: + imageName: azureiotedge-simulated-temperature-sensor + name: "Temperature Sensor" + project: SimulatedTemperatureSensor + template: templates/image-linux.yaml + variables: + build.registry.address: edgebuilds.azurecr.io + build.registry.user: EdgeBuilds + registry.address: edgerelease.azurecr.io + registry.user: EdgeRelease + - demands: + - "Build-Image -equals true" + - win-rs5 + - DotNetFramework + displayName: Windows + job: windows + name: Azure-IoT-Edge-Core + pool: ~ + steps: + - displayName: "Install .NET Core - 3.1.3" + inputs: + version: "3.1.201" + task: DotNetCoreInstaller@0 + - displayName: "Build ($(Build.Configuration))" + name: build + powershell: "scripts/windows/build/Publish-Branch.ps1 -Configuration:\"$(Build.Configuration)\" -PublishTests:$False -UpdateVersion" + - script: | + docker login $(build.registry.address) -u $(build.registry.user) -p $(build.registry.password) + docker login $(registry.address) -u $(registry.user) -p $(registry.password) + displayName: 'docker login' + - displayName: "Build iotedge-diagnostics" + inputs: + filePath: ./edgelet/build/windows/build-diagnostics.ps1 + targetType: filePath + task: PowerShell@2 + - displayName: "azureiotedge-diagnostics Code Sign" + inputs: + ConnectedServiceName: "Azure IoT Edge Code Sign 2" + FolderPath: $(Build.BinariesDirectory)\publish\azureiotedge-diagnostics + Pattern: iotedge-diagnostics.exe + SessionTimeout: 20 + inlineOperation: | + [ + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolSign", + "parameters": [ + { + "parameterName": "OpusName", + "parameterValue": "Microsoft" + }, + { + "parameterName": "OpusInfo", + "parameterValue": "http://www.microsoft.com" + }, + { + "parameterName": "Append", + "parameterValue": "/as" + }, + { + "parameterName": "FileDigest", + "parameterValue": "/fd \"SHA256\"" + }, + { + "parameterName": "PageHash", + "parameterValue": "/NPH" + }, + { + "parameterName": "TimeStamp", + "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" + } + ], + "toolName": "sign", + "toolVersion": "1.0" + }, + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolVerify", + "parameters": [ + { + "parameterName": "VerifyAll", + "parameterValue": "/all" + } + ], + "toolName": "sign", + "toolVersion": "1.0" + } + ] + signConfigType: inlineSignParams + task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + - displayName: "Edge Agent Code Sign" + inputs: + ConnectedServiceName: "Azure IoT Edge Code Sign 2" + FolderPath: $(Build.BinariesDirectory)\publish\Microsoft.Azure.Devices.Edge.Agent.Service + Pattern: Microsoft.Azure.Devices.Edge.*.dll + SessionTimeout: 20 + inlineOperation: | + [ + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolSign", + "parameters": [ + { + "parameterName": "OpusName", + "parameterValue": "Microsoft" + }, + { + "parameterName": "OpusInfo", + "parameterValue": "http://www.microsoft.com" + }, + { + "parameterName": "Append", + "parameterValue": "/as" + }, + { + "parameterName": "FileDigest", + "parameterValue": "/fd \"SHA256\"" + }, + { + "parameterName": "PageHash", + "parameterValue": "/NPH" + }, + { + "parameterName": "TimeStamp", + "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" + } + ], + "toolName": "sign", + "toolVersion": "1.0" + }, + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolVerify", + "parameters": [ + { + "parameterName": "VerifyAll", + "parameterValue": "/all" + } + ], + "toolName": "sign", + "toolVersion": "1.0" + } + ] + signConfigType: inlineSignParams + task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + - displayName: "Edge Hub Code Sign" + inputs: + ConnectedServiceName: "Azure IoT Edge Code Sign 2" + FolderPath: $(Build.BinariesDirectory)\publish\Microsoft.Azure.Devices.Edge.Hub.Service + Pattern: "Microsoft.Azure.Devices.Edge.*.dll,Microsoft.Azure.Devices.Routing.*.dll" + SessionTimeout: 20 + inlineOperation: | + [ + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolSign", + "parameters": [ + { + "parameterName": "OpusName", + "parameterValue": "Microsoft" + }, + { + "parameterName": "OpusInfo", + "parameterValue": "http://www.microsoft.com" + }, + { + "parameterName": "Append", + "parameterValue": "/as" + }, + { + "parameterName": "FileDigest", + "parameterValue": "/fd \"SHA256\"" + }, + { + "parameterName": "PageHash", + "parameterValue": "/NPH" + }, + { + "parameterName": "TimeStamp", + "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" + } + ], + "toolName": "sign", + "toolVersion": "1.0" + }, + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolVerify", + "parameters": [ + { + "parameterName": "VerifyAll", + "parameterValue": "/all" + } + ], + "toolName": "sign", + "toolVersion": "1.0" + } + ] + signConfigType: inlineSignParams + task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + - displayName: "Temp Sensor Code Sign" + inputs: + ConnectedServiceName: "Azure IoT Edge Code Sign 2" + FolderPath: $(Build.BinariesDirectory)\publish\SimulatedTemperatureSensor + Pattern: "Microsoft.Azure.Devices.Edge.*.dll,SimulatedTemperatureSensor.dll" + SessionTimeout: 20 + inlineOperation: | + [ + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolSign", + "parameters": [ + { + "parameterName": "OpusName", + "parameterValue": "Microsoft" + }, + { + "parameterName": "OpusInfo", + "parameterValue": "http://www.microsoft.com" + }, + { + "parameterName": "Append", + "parameterValue": "/as" + }, + { + "parameterName": "FileDigest", + "parameterValue": "/fd \"SHA256\"" + }, + { + "parameterName": "PageHash", + "parameterValue": "/NPH" + }, + { + "parameterName": "TimeStamp", + "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" + } + ], + "toolName": "sign", + "toolVersion": "1.0" + }, + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolVerify", + "parameters": [ + { + "parameterName": "VerifyAll", + "parameterValue": "/all" + } + ], + "toolName": "sign", + "toolVersion": "1.0" + } + ] + signConfigType: inlineSignParams + task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + - displayName: "Build Image - Edge Agent - amd64" + inputs: + arguments: "-Name 'azureiotedge-agent' -Project 'Microsoft.Azure.Devices.Edge.Agent.Service' -Version '$(version)' -Registry '$(registry.address)' -Namespace '$(namespace)' -Push" + filePath: ./scripts/windows/build/Publish-DockerImage.ps1 + targetType: filePath + task: PowerShell@2 + - displayName: "Build Image - Edge Hub - amd64" + inputs: + arguments: "-Name 'azureiotedge-hub' -Project 'Microsoft.Azure.Devices.Edge.Hub.Service' -Version '$(version)' -Registry '$(registry.address)' -Namespace '$(namespace)' -Push" + filePath: ./scripts/windows/build/Publish-DockerImage.ps1 + targetType: filePath + task: PowerShell@2 + - displayName: "Build Image - Temp Sensor - amd64" + inputs: + arguments: "-Name 'azureiotedge-simulated-temperature-sensor' -Project 'SimulatedTemperatureSensor' -Version '$(version)' -Registry '$(registry.address)' -Namespace '$(namespace)' -Push" + filePath: ./scripts/windows/build/Publish-DockerImage.ps1 + targetType: filePath + task: PowerShell@2 + - displayName: "Build Image - azureiotedge-diagnostics - amd64" + inputs: + arguments: "-Name 'azureiotedge-diagnostics' -Project 'azureiotedge-diagnostics' -Version '$(version)' -Registry '$(registry.address)' -Namespace '$(namespace)' -Push" + filePath: ./scripts/windows/build/Publish-DockerImage.ps1 + targetType: filePath + task: PowerShell@2 + - displayName: "Publish Artifacts to VSTS" + inputs: + ArtifactName: publish-win + PathtoPublish: $(Build.BinariesDirectory)\publish + task: PublishBuildArtifacts@1 + variables: + build.registry.address: edgebuilds.azurecr.io + build.registry.user: EdgeBuilds + registry.address: edgerelease.azurecr.io + registry.user: EdgeRelease diff --git a/builds/misc/images.yaml b/builds/misc/images.yaml index 82542a21856..581399c1504 100644 --- a/builds/misc/images.yaml +++ b/builds/misc/images.yaml @@ -6,158 +6,6 @@ trigger: pr: none jobs: -################################################################################ - - job: linux_dotnet_projects_arm64 -################################################################################ - displayName: LinuxDotnet ARM64 - pool: - vmImage: 'ubuntu-16.04' - steps: - - task: UseDotNet@2 - displayName: Install .NET Core sdk - inputs: - packageType: sdk - version: 3.0.x - - - bash: 'docker login $(registry.address) --username $(registry.user) --password $(registry.password)' - displayName: 'Docker Login' - - - script: scripts/linux/buildBranch.sh -c $(Build.Configuration) --no-rocksdb-bin --os Unix --dotnet_runtime netcoreapp3.0 - name: build - displayName: Build ($(Build.Configuration)) - - - task: PublishBuildArtifacts@1 - displayName: 'Publish Artifacts' - inputs: - PathtoPublish: '$(Build.BinariesDirectory)/publish' - ArtifactName: 'core-linux' - - # Edge Agent - Not Using Template for ARM64 because we have 2 different .NET Core. - - task: Bash@3 - displayName: Build Image - Edge Agent - aarch64 - inputs: - filePath: scripts/linux/buildImage.sh - arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i azureiotedge-agent -n microsoft -P Microsoft.Azure.Devices.Edge.Agent.Service --target-arch aarch64 - - # Edge Hub - Not Using Template for ARM64 because we have 2 different .NET Core. - - task: Bash@3 - displayName: Build Image - Edge Hub - aarch64 - inputs: - filePath: scripts/linux/buildImage.sh - arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i azureiotedge-hub -n microsoft -P Microsoft.Azure.Devices.Edge.Hub.Service --target-arch aarch64 - - # Simulated Temperature Sensor - Not Using Template for ARM64 because we have 2 different .NET Core. - - task: Bash@3 - displayName: Build Image - Temperature Sensor - aarch64 - inputs: - filePath: scripts/linux/buildImage.sh - arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i azureiotedge-simulated-temperature-sensor -n microsoft -P SimulatedTemperatureSensor --target-arch aarch64 - - # Temperature Filter - Not Using Template for ARM64 because we have 2 different .NET Core. - - task: Bash@3 - displayName: Build Image - Temperature Filter - aarch64 - inputs: - filePath: scripts/linux/buildImage.sh - arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i azureiotedge-temperature-filter -n microsoft -P TemperatureFilter --target-arch aarch64 - - # Load Gen - Not Using Template for ARM64 because we have 2 different .NET Core. - - task: Bash@3 - displayName: Build Image - Load Gen - aarch64 - inputs: - filePath: scripts/linux/buildImage.sh - arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i azureiotedge-load-gen -n microsoft -P load-gen --target-arch aarch64 - - # Test Analyzer - Not Using Template for ARM64 because we have 2 different .NET Core. - - task: Bash@3 - displayName: Build Image - Test Analyzer - aarch64 - inputs: - filePath: scripts/linux/buildImage.sh - arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i azureiotedge-analyzer -n microsoft -P TestAnalyzer --target-arch aarch64 - - # Functions Sample - Not Using Template for ARM64 because we have 2 different .NET Core.//TODO: Enable this once Functions supports arm64v8. Right now they are not ready. - #- task: Bash@3 - # displayName: Build Image - Functions Sample - aarch64 - # inputs: - # filePath: scripts/linux/buildImage.sh - # arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i azureiotedge-functions-filter -n azureiotedge -P EdgeHubTriggerCSharp --target-arch aarch64 - - # Direct Method Sender - Not Using Template for ARM64 because we have 2 different .NET Core. - - task: Bash@3 - displayName: Build Image - Direct Method Sender - aarch64 - inputs: - filePath: scripts/linux/buildImage.sh - arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i azureiotedge-direct-method-sender -n microsoft -P DirectMethodSender --target-arch aarch64 - - # Direct Method Receiver - Not Using Template for ARM64 because we have 2 different .NET Core. - - task: Bash@3 - displayName: Build Image - Direct Method Receiver - aarch64 - inputs: - filePath: scripts/linux/buildImage.sh - arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i azureiotedge-direct-method-receiver -n microsoft -P DirectMethodReceiver --target-arch aarch64 - - # Metrics Validator - Not Using Template for ARM64 because we have 2 different .NET Core. - - task: Bash@3 - displayName: Build Image - Metrics Validator - aarch64 - inputs: - filePath: scripts/linux/buildImage.sh - arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i azureiotedge-metrics-validator -n microsoft -P MetricsValidator --target-arch aarch64 - - # Module Restarter - Not Using Template for ARM64 because we have 2 different .NET Core. - - task: Bash@3 - displayName: Build Image - Module Restarter - aarch64 - inputs: - filePath: scripts/linux/buildImage.sh - arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i azureiotedge-module-restarter -n microsoft -P ModuleRestarter --target-arch aarch64 - - # Twin Tester - Not Using Template for ARM64 because we have 2 different .NET Core. - - task: Bash@3 - displayName: Build Image - Twin Tester - aarch64 - inputs: - filePath: scripts/linux/buildImage.sh - arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i azureiotedge-twin-tester -n microsoft -P TwinTester --target-arch aarch64 - - # Relayer - Not Using Template for ARM64 because we have 2 different .NET Core. - - task: Bash@3 - displayName: Build Image - Relayer - aarch64 - inputs: - filePath: scripts/linux/buildImage.sh - arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i azureiotedge-relayer -n microsoft -P Relayer --target-arch aarch64 - - # Metrics Collector - Not Using Template for ARM64 because we have 2 different .NET Core. - - task: Bash@3 - displayName: Build Image - Metrics Collector - aarch64 - inputs: - filePath: scripts/linux/buildImage.sh - arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i azureiotedge-metrics-collector -n microsoft -P MetricsCollector --target-arch aarch64 - - # TestResultCoordinator - Not Using Template for ARM64 because we have 2 different .NET Core. - - task: Bash@3 - displayName: Build Image - Test Result Coordinator - aarch64 - inputs: - filePath: scripts/linux/buildImage.sh - arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i azureiotedge-test-result-coordinator -n microsoft -P TestResultCoordinator --target-arch aarch64 - - # DeploymentTester - Not Using Template for ARM64 because we have 2 different .NET Core. - - task: Bash@3 - displayName: Build Image - Deployment Tester - aarch64 - inputs: - filePath: scripts/linux/buildImage.sh - arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i azureiotedge-deployment-tester -n microsoft -P DeploymentTester --target-arch aarch64 - - # EdgeHubRestartTester - Not Using Template for ARM64 because we have 2 different .NET Core. - - task: Bash@3 - displayName: Build Image - EdgeHub Restart Tester - aarch64 - inputs: - filePath: scripts/linux/buildImage.sh - arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i azureiotedge-edgehub-restart-tester -n microsoft -P EdgeHubRestartTester --target-arch aarch64 - - # CloudToDeviceMessageTester - Not Using Template for ARM64 because we have 2 different .NET Core. - - task: Bash@3 - displayName: Build Image - Cloud To Device Message Receiver Tester - aarch64 - inputs: - filePath: scripts/linux/buildImage.sh - arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i azureiotedge-c2dmessage-tester -n microsoft -P CloudToDeviceMessageTester --target-arch aarch64 - ################################################################################ - job: linux_dotnet_projects ################################################################################ @@ -165,11 +13,8 @@ jobs: pool: vmImage: 'ubuntu-16.04' steps: - - task: UseDotNet@2 - displayName: 'Install .NET Core sdk' - inputs: - packageType: sdk - version: 2.1.x + - template: ../templates/install-dotnet3.yaml + - bash: 'docker login $(registry.address) --username $(registry.user) --password $(registry.password)' displayName: 'Docker Login' @@ -356,11 +201,9 @@ jobs: workspace: clean: all variables: - NetCorePackageUri: https://download.microsoft.com/download/4/0/9/40920432-3302-47a8-b13c-bbc4848ad114/dotnet-sdk-2.1.302-win-x64.zip + NetCorePackageUri: https://download.visualstudio.microsoft.com/download/pr/56131147-65ea-47d6-a945-b0296c86e510/44b43b7cb27d55081e650b9a4188a419/dotnet-sdk-3.1.201-win-x64.exe steps: - - powershell: scripts/windows/setup/Install-Prerequisites.ps1 -DotnetSdkUrl $(NetCorePackageUri) -Dotnet -Nuget - name: install - displayName: Install + - template: ../templates/install-dotnet3.yaml - script: echo $(registry.password)|docker login "edgebuilds.azurecr.io" -u "$(registry.user)" --password-stdin displayName: Docker Login @@ -430,7 +273,7 @@ jobs: imageName: azureiotedge-analyzer project: TestAnalyzer - # Functions Sample + # Functions Sample - Not supported on arm64 - template: templates/image-windows.yaml parameters: name: Functions Sample @@ -525,7 +368,6 @@ jobs: vmImage: 'ubuntu-16.04' dependsOn: - linux_dotnet_projects - - linux_dotnet_projects_arm64 - linux_rust_amd64 - linux_rust_arm32 - linux_rust_arm64 diff --git a/builds/misc/templates/image-linux.yaml b/builds/misc/templates/image-linux.yaml index 12850b7600f..d6bd8bda9af 100644 --- a/builds/misc/templates/image-linux.yaml +++ b/builds/misc/templates/image-linux.yaml @@ -14,4 +14,10 @@ steps: displayName: Build Image - ${{ parameters.name }} - arm32 inputs: filePath: scripts/linux/buildImage.sh - arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i ${{ parameters.imageName }} -n ${{ parameters.namespace }} -P ${{ parameters.project }} --target-arch armv7l \ No newline at end of file + arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i ${{ parameters.imageName }} -n ${{ parameters.namespace }} -P ${{ parameters.project }} --target-arch armv7l + - task: Bash@3 + displayName: Build Image - ${{ parameters.name }} - arm64 + condition: ne('${{ parameters.name }}', 'Functions Sample') + inputs: + filePath: scripts/linux/buildImage.sh + arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i ${{ parameters.imageName }} -n ${{ parameters.namespace }} -P ${{ parameters.project }} --target-arch aarch64 \ No newline at end of file diff --git a/builds/templates/install-dotnet3.yaml b/builds/templates/install-dotnet3.yaml new file mode 100644 index 00000000000..05b5e5883f5 --- /dev/null +++ b/builds/templates/install-dotnet3.yaml @@ -0,0 +1,6 @@ +steps: + - task: UseDotNet@2 + displayName: Install .NET Core sdk + inputs: + packageType: sdk + version: 3.1.201 diff --git a/dotnetVersion.props b/dotnetVersion.props new file mode 100644 index 00000000000..b00ddca4a2e --- /dev/null +++ b/dotnetVersion.props @@ -0,0 +1,5 @@ + + + netcoreapp3.1 + + \ No newline at end of file diff --git a/edge-agent/docker/linux/amd64/Dockerfile b/edge-agent/docker/linux/amd64/Dockerfile index 27100828215..4f14b5ca669 100644 --- a/edge-agent/docker/linux/amd64/Dockerfile +++ b/edge-agent/docker/linux/amd64/Dockerfile @@ -1,7 +1,7 @@ -ARG base_tag=2.1.13-alpine3.10 +ARG base_tag=3.1.2-alpine3.10 FROM azureiotedge/azureiotedge-runtime-base:1.2-linux-amd64 as builder -FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} +FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} ARG EXE_DIR=. diff --git a/edge-agent/docker/linux/arm32v7/Dockerfile b/edge-agent/docker/linux/arm32v7/Dockerfile index fa7c6a5d35d..a0162e73dbe 100644 --- a/edge-agent/docker/linux/arm32v7/Dockerfile +++ b/edge-agent/docker/linux/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm32v7 +ARG base_tag=1.0.5-linux-arm32v7 FROM azureiotedge/azureiotedge-agent-base:${base_tag} ARG EXE_DIR=. diff --git a/edge-agent/docker/linux/arm32v7/base/Dockerfile b/edge-agent/docker/linux/arm32v7/base/Dockerfile index e3b42a1bc47..cd9db42dd4e 100644 --- a/edge-agent/docker/linux/arm32v7/base/Dockerfile +++ b/edge-agent/docker/linux/arm32v7/base/Dockerfile @@ -1,5 +1,5 @@ -ARG base_tag=2.1.16-bionic-arm32v7 -FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} +ARG base_tag=3.1.2-bionic-arm32v7 +FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} RUN apt-get update && \ apt-get install -y libsnappy1v5 && \ diff --git a/edge-agent/docker/linux/arm64v8/Dockerfile b/edge-agent/docker/linux/arm64v8/Dockerfile index 7787927427b..ad993a10bee 100644 --- a/edge-agent/docker/linux/arm64v8/Dockerfile +++ b/edge-agent/docker/linux/arm64v8/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm64v8 +ARG base_tag=1.0.5-linux-arm64v8 FROM azureiotedge/azureiotedge-agent-base:${base_tag} diff --git a/edge-agent/docker/linux/arm64v8/base/Dockerfile b/edge-agent/docker/linux/arm64v8/base/Dockerfile index e6ebe25e825..31e6dc6074c 100644 --- a/edge-agent/docker/linux/arm64v8/base/Dockerfile +++ b/edge-agent/docker/linux/arm64v8/base/Dockerfile @@ -1,8 +1,7 @@ -ARG base_tag=3.0.3-bionic-arm64v8 +ARG base_tag=3.1.2-bionic-arm64v8 ARG num_procs=4 -FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} - +FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} RUN mkdir -p ../publish diff --git a/edge-agent/docker/windows/amd64/Dockerfile b/edge-agent/docker/windows/amd64/Dockerfile index dde3bfd8ec8..752a5b1c362 100644 --- a/edge-agent/docker/windows/amd64/Dockerfile +++ b/edge-agent/docker/windows/amd64/Dockerfile @@ -1,5 +1,5 @@ -ARG base_tag=2.1.15-nanoserver-1809 -FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} +ARG base_tag=3.1.2-nanoserver-1809 +FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} USER ContainerAdministrator diff --git a/edge-agent/docker/windows/arm32v7/Dockerfile b/edge-agent/docker/windows/arm32v7/Dockerfile index 8d6d028d436..228179bc83e 100644 --- a/edge-agent/docker/windows/arm32v7/Dockerfile +++ b/edge-agent/docker/windows/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-windows-arm32v7 +ARG base_tag=1.0.5-windows-arm32v7 ARG base_registry FROM ${base_registry}/azureiotedge/azureiotedge-agent-base:${base_tag} diff --git a/edge-agent/docker/windows/arm32v7/base/Dockerfile b/edge-agent/docker/windows/arm32v7/base/Dockerfile index a24078c8357..6e6c15f4378 100644 --- a/edge-agent/docker/windows/arm32v7/base/Dockerfile +++ b/edge-agent/docker/windows/arm32v7/base/Dockerfile @@ -1,7 +1,7 @@ # Base image for arm32v7 dotnet-runtime container FROM mcr.microsoft.com/windows/nanoserver:1809-arm32v7 -ENV DOTNET_VERSION 2.1.13 +ENV DOTNET_VERSION 3.1.2 ENV DOTNET_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-runtime-${DOTNET_VERSION}-win-arm.zip RUN curl -SL %DOTNET_DOWNLOAD_URL% --output dotnet.zip \ diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Core/Microsoft.Azure.Devices.Edge.Agent.Core.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Core/Microsoft.Azure.Devices.Edge.Agent.Core.csproj index a3f42e1a57f..5c80c3dc618 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Core/Microsoft.Azure.Devices.Edge.Agent.Core.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Core/Microsoft.Azure.Devices.Edge.Agent.Core.csproj @@ -1,7 +1,8 @@  + + - netstandard2.0 True Debug;Release;CheckInBuild true @@ -9,7 +10,7 @@ - + diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Diagnostics/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Diagnostics/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.csproj index 977b819d7f5..aaa4aa2079e 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Diagnostics/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Diagnostics/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.csproj @@ -1,7 +1,8 @@  + + - netstandard2.0 True Debug;Release;CheckInBuild true @@ -9,12 +10,8 @@ - + - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Docker/Microsoft.Azure.Devices.Edge.Agent.Docker.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Docker/Microsoft.Azure.Devices.Edge.Agent.Docker.csproj index 9e4b59b514c..6803c799987 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Docker/Microsoft.Azure.Devices.Edge.Agent.Docker.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Docker/Microsoft.Azure.Devices.Edge.Agent.Docker.csproj @@ -1,14 +1,15 @@  + + - netstandard2.0 True Debug;Release;CheckInBuild true - + diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.csproj index 68512157edf..a3f9e02ce8b 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.csproj @@ -1,7 +1,8 @@ + + - netstandard2.0 True true Debug;Release;CheckInBuild diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/Microsoft.Azure.Devices.Edge.Agent.Edgelet.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/Microsoft.Azure.Devices.Edge.Agent.Edgelet.csproj index 5328c6c0177..8c1f7e7142f 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/Microsoft.Azure.Devices.Edge.Agent.Edgelet.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/Microsoft.Azure.Devices.Edge.Agent.Edgelet.csproj @@ -1,14 +1,15 @@ + + - netstandard2.0 True Debug;Release;CheckInBuild true - + diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_01_30/ModuleManagementHttpClient.cs b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_01_30/ModuleManagementHttpClient.cs index f4beda3e6fd..31332f5b7c2 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_01_30/ModuleManagementHttpClient.cs +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_01_30/ModuleManagementHttpClient.cs @@ -184,7 +184,7 @@ public override async Task PrepareUpdateAsync(ModuleSpec moduleSpec) using (HttpClient httpClient = HttpClientHelper.GetHttpClient(this.ManagementUri)) { var edgeletHttpClient = new EdgeletHttpClient(httpClient) { BaseUrl = HttpClientHelper.GetBaseUrl(this.ManagementUri) }; - await this.Execute(() => edgeletHttpClient.PrepareUpdateModuleAsync(this.Version.Name, moduleSpec.Name, MapToModuleSpec(moduleSpec)), $"prepare update for module module {moduleSpec.Name}"); + await this.Execute(() => edgeletHttpClient.PrepareUpdateModuleAsync(this.Version.Name, moduleSpec.Name, MapToModuleSpec(moduleSpec)), $"prepare update for module {moduleSpec.Name}"); } } diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_10_22/ModuleManagementHttpClient.cs b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_10_22/ModuleManagementHttpClient.cs index e19a89956f4..120a8ccce95 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_10_22/ModuleManagementHttpClient.cs +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_10_22/ModuleManagementHttpClient.cs @@ -184,7 +184,7 @@ public override async Task PrepareUpdateAsync(ModuleSpec moduleSpec) using (HttpClient httpClient = HttpClientHelper.GetHttpClient(this.ManagementUri)) { var edgeletHttpClient = new EdgeletHttpClient(httpClient) { BaseUrl = HttpClientHelper.GetBaseUrl(this.ManagementUri) }; - await this.Execute(() => edgeletHttpClient.PrepareUpdateModuleAsync(this.Version.Name, moduleSpec.Name, MapToModuleSpec(moduleSpec)), $"prepare update for module module {moduleSpec.Name}"); + await this.Execute(() => edgeletHttpClient.PrepareUpdateModuleAsync(this.Version.Name, moduleSpec.Name, MapToModuleSpec(moduleSpec)), $"prepare update for module {moduleSpec.Name}"); } } diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_11_05/ModuleManagementHttpClient.cs b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_11_05/ModuleManagementHttpClient.cs index d9546c7c649..27a7749fbe8 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_11_05/ModuleManagementHttpClient.cs +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_11_05/ModuleManagementHttpClient.cs @@ -198,7 +198,7 @@ public override async Task PrepareUpdateAsync(ModuleSpec moduleSpec) using (HttpClient httpClient = HttpClientHelper.GetHttpClient(this.ManagementUri)) { var edgeletHttpClient = new EdgeletHttpClient(httpClient) { BaseUrl = HttpClientHelper.GetBaseUrl(this.ManagementUri) }; - await this.Execute(() => edgeletHttpClient.PrepareUpdateModuleAsync(this.Version.Name, moduleSpec.Name, MapToModuleSpec(moduleSpec)), $"prepare update for module module {moduleSpec.Name}"); + await this.Execute(() => edgeletHttpClient.PrepareUpdateModuleAsync(this.Version.Name, moduleSpec.Name, MapToModuleSpec(moduleSpec)), $"prepare update for module {moduleSpec.Name}"); } } diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/Microsoft.Azure.Devices.Edge.Agent.IoTHub.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/Microsoft.Azure.Devices.Edge.Agent.IoTHub.csproj index d1c5d4dc299..f9a3f66d996 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/Microsoft.Azure.Devices.Edge.Agent.IoTHub.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/Microsoft.Azure.Devices.Edge.Agent.IoTHub.csproj @@ -1,7 +1,8 @@  + + - netstandard2.0 True Debug;Release;CheckInBuild true diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Kubernetes/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Kubernetes/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.csproj index 036b0d7de5b..a836529af5f 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Kubernetes/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Kubernetes/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + True diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Service/Microsoft.Azure.Devices.Edge.Agent.Service.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Service/Microsoft.Azure.Devices.Edge.Agent.Service.csproj index 7c7f16193c5..1094a16d2fb 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Service/Microsoft.Azure.Devices.Edge.Agent.Service.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Service/Microsoft.Azure.Devices.Edge.Agent.Service.csproj @@ -1,11 +1,5 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + Exe @@ -16,9 +10,9 @@ - - - + + + diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Core.Test/Microsoft.Azure.Devices.Edge.Agent.Core.Test.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Core.Test/Microsoft.Azure.Devices.Edge.Agent.Core.Test.csproj index 04622040ec0..429b211a1a4 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Core.Test/Microsoft.Azure.Devices.Edge.Agent.Core.Test.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Core.Test/Microsoft.Azure.Devices.Edge.Agent.Core.Test.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + True diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Core.Test/commands/LoggingCommandFactoryTest.cs b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Core.Test/commands/LoggingCommandFactoryTest.cs index f2675bc46ce..98861f4a408 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Core.Test/commands/LoggingCommandFactoryTest.cs +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Core.Test/commands/LoggingCommandFactoryTest.cs @@ -102,8 +102,8 @@ public async Task ExecuteSuccessfulTests( // Assert decorated command is executed, and command is logged. factoryMock.Verify(commandMethodBeingTested); - logMock.Verify(l => l.Log(LogLevel.Information, It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); - logMock.Verify(l => l.Log(LogLevel.Debug, It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); + logMock.Verify(l => l.Log(LogLevel.Information, It.IsAny(), It.IsAny(), It.IsAny(), (Func)It.IsAny()), Times.Once); + logMock.Verify(l => l.Log(LogLevel.Debug, It.IsAny(), It.IsAny(), It.IsAny(), (Func)It.IsAny()), Times.Once); } [Theory] @@ -132,8 +132,8 @@ public async Task ExecuteFailureTests( await Assert.ThrowsAsync(() => create.ExecuteAsync(token)); factoryMock.Verify(commandMethodBeingTested); - logMock.Verify(l => l.Log(LogLevel.Information, It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); - logMock.Verify(l => l.Log(LogLevel.Error, It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); + logMock.Verify(l => l.Log(LogLevel.Information, It.IsAny(), It.IsAny(), It.IsAny(), (Func)It.IsAny()), Times.Once); + logMock.Verify(l => l.Log(LogLevel.Error, It.IsAny(), It.IsAny(), It.IsAny(), (Func)It.IsAny()), Times.Once); } [Theory] @@ -162,8 +162,8 @@ public async Task UndoSuccessTests( await create.UndoAsync(token); factoryMock.Verify(commandMethodBeingTested); - logMock.Verify(l => l.Log(LogLevel.Information, It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); - logMock.Verify(l => l.Log(LogLevel.Debug, It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); + logMock.Verify(l => l.Log(LogLevel.Information, It.IsAny(), It.IsAny(), It.IsAny(), (Func)It.IsAny()), Times.Once); + logMock.Verify(l => l.Log(LogLevel.Debug, It.IsAny(), It.IsAny(), It.IsAny(), (Func)It.IsAny()), Times.Once); } [Theory] @@ -191,8 +191,8 @@ public async Task UndoFailureTests( await Assert.ThrowsAsync(() => create.UndoAsync(token)); factoryMock.Verify(commandMethodBeingTested); - logMock.Verify(l => l.Log(LogLevel.Information, It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); - logMock.Verify(l => l.Log(LogLevel.Error, It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); + logMock.Verify(l => l.Log(LogLevel.Information, It.IsAny(), It.IsAny(), It.IsAny(), (Func)It.IsAny()), Times.Once); + logMock.Verify(l => l.Log(LogLevel.Error, It.IsAny(), It.IsAny(), It.IsAny(), (Func)It.IsAny()), Times.Once); } public static IEnumerable CreateTestData() diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.Test/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.Test.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.Test/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.Test.csproj index 8a2cb9953d5..0eff369fd16 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.Test/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.Test.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.Test/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.Test.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + True diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Docker.E2E.Test/Microsoft.Azure.Devices.Edge.Agent.Docker.E2E.Test.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Docker.E2E.Test/Microsoft.Azure.Devices.Edge.Agent.Docker.E2E.Test.csproj index 1ad22a7c69e..599a3657014 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Docker.E2E.Test/Microsoft.Azure.Devices.Edge.Agent.Docker.E2E.Test.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Docker.E2E.Test/Microsoft.Azure.Devices.Edge.Agent.Docker.E2E.Test.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + True @@ -15,8 +9,8 @@ - - + + diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Docker.Test/Microsoft.Azure.Devices.Edge.Agent.Docker.Test.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Docker.Test/Microsoft.Azure.Devices.Edge.Agent.Docker.Test.csproj index ebba920d6ec..b5bb22fc0b3 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Docker.Test/Microsoft.Azure.Devices.Edge.Agent.Docker.Test.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Docker.Test/Microsoft.Azure.Devices.Edge.Agent.Docker.Test.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + True diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.Test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.Test.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.Test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.Test.csproj index e9116ce0ae1..ef4d5768b0d 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.Test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.Test.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.Test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.Test.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + false diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test/EdgeletFixture.cs b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test/EdgeletFixture.cs index bd91682e1f8..473757cc2e5 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test/EdgeletFixture.cs +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test/EdgeletFixture.cs @@ -4,9 +4,9 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test using System; using System.Threading; using System.Threading.Tasks; - using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test.TestServer; + using Microsoft.Extensions.Hosting; public class EdgeletFixture : IDisposable { @@ -29,7 +29,7 @@ class ServiceHost ServiceHost() { - this.webHostTask = BuildWebHost(new string[0], DefaultPort).RunAsync(this.cancellationTokenSource.Token); + this.webHostTask = CreateHostBuilder(new string[0], DefaultPort).Build().RunAsync(this.cancellationTokenSource.Token); this.Url = $"http://localhost:{DefaultPort}"; } @@ -37,11 +37,14 @@ class ServiceHost public string Url { get; } - static IWebHost BuildWebHost(string[] args, int port) => - WebHost.CreateDefaultBuilder(args) - .UseUrls($"http://*:{port}") - .UseStartup() - .Build(); + static IHostBuilder CreateHostBuilder(string[] args, int port) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder + .UseUrls($"http://*:{port}") + .UseStartup(); + }); } } } diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test.csproj index 4ad173b2e3e..d7fd8f6f972 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test.csproj @@ -1,11 +1,5 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + True @@ -14,7 +8,8 @@ - + + @@ -24,12 +19,8 @@ - - - - - - + + diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test/TestServer/Startup.cs b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test/TestServer/Startup.cs index 07acd0b5ecc..3b1a8364ed0 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test/TestServer/Startup.cs +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test/TestServer/Startup.cs @@ -6,6 +6,7 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test.TestServer using Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test.TestServer.Controllers; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.Hosting; public class Startup { @@ -19,22 +20,23 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc(); + services.AddControllers().AddNewtonsoftJson(); services.AddSingleton(); } - // TODO: Remove warning disable for Obsolete when project is moved to dotnetcore 3.0 -#pragma warning disable 612, 618 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - app.UseMvc(); + app.UseRouting(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); } -#pragma warning restore 612, 618 } } diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Integration.Test/Microsoft.Azure.Devices.Edge.Agent.Integration.Test.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Integration.Test/Microsoft.Azure.Devices.Edge.Agent.Integration.Test.csproj index 42daebae0b8..b9829bbffb3 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Integration.Test/Microsoft.Azure.Devices.Edge.Agent.Integration.Test.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Integration.Test/Microsoft.Azure.Devices.Edge.Agent.Integration.Test.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + True @@ -15,8 +9,8 @@ - - + + diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.IoTHub.Test/Microsoft.Azure.Devices.Edge.Agent.IoTHub.Test.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.IoTHub.Test/Microsoft.Azure.Devices.Edge.Agent.IoTHub.Test.csproj index a0a273fea11..431954e6872 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.IoTHub.Test/Microsoft.Azure.Devices.Edge.Agent.IoTHub.Test.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.IoTHub.Test/Microsoft.Azure.Devices.Edge.Agent.IoTHub.Test.csproj @@ -1,11 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + + True diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.IntegrationTest/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.IntegrationTest.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.IntegrationTest/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.IntegrationTest.csproj index 06bbe7682d4..ea2776063c1 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.IntegrationTest/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.IntegrationTest.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.IntegrationTest/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.IntegrationTest.csproj @@ -1,14 +1,8 @@ - - netcoreapp2.1 - - - - netcoreapp3.0 - + - + True Debug;Release;CheckInBuild true diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test.csproj index 4781bf5766a..4b275054780 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + True @@ -22,11 +16,8 @@ - - - - - + + diff --git a/edge-hub/docker/linux/amd64/Dockerfile b/edge-hub/docker/linux/amd64/Dockerfile index 2c95931e9a7..697a9dacdf4 100644 --- a/edge-hub/docker/linux/amd64/Dockerfile +++ b/edge-hub/docker/linux/amd64/Dockerfile @@ -1,7 +1,7 @@ -ARG base_tag=2.1.13-alpine3.10 -FROM azureiotedge/azureiotedge-runtime-base:1.2-linux-amd64 as builder +ARG base_tag=3.1.2-alpine3.10 +FROM azureiotedge/azureiotedge-runtime-base:1.2-linux-amd64 as builder -FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} +FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} ARG EXE_DIR=. diff --git a/edge-hub/docker/linux/arm32v7/Dockerfile b/edge-hub/docker/linux/arm32v7/Dockerfile index 1df6b91dcb4..c18d67b9a6a 100644 --- a/edge-hub/docker/linux/arm32v7/Dockerfile +++ b/edge-hub/docker/linux/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm32v7 +ARG base_tag=1.0.5-linux-arm32v7 FROM azureiotedge/azureiotedge-hub-base:${base_tag} ARG EXE_DIR=. diff --git a/edge-hub/docker/linux/arm32v7/base/Dockerfile b/edge-hub/docker/linux/arm32v7/base/Dockerfile index abc5ed10c03..c957b76f4db 100644 --- a/edge-hub/docker/linux/arm32v7/base/Dockerfile +++ b/edge-hub/docker/linux/arm32v7/base/Dockerfile @@ -1,5 +1,5 @@ -ARG base_tag=2.1.16-bionic-arm32v7 -FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} +ARG base_tag=3.1.2-bionic-arm32v7 +FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} # Add an unprivileged user account for running Edge Hub ARG EDGEHUBUSER_ID=1000 diff --git a/edge-hub/docker/linux/arm64v8/Dockerfile b/edge-hub/docker/linux/arm64v8/Dockerfile index c58dad5d2a2..327cd23865e 100644 --- a/edge-hub/docker/linux/arm64v8/Dockerfile +++ b/edge-hub/docker/linux/arm64v8/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm64v8 +ARG base_tag=1.0.5-linux-arm64v8 FROM azureiotedge/azureiotedge-hub-base:${base_tag} ARG EXE_DIR=. diff --git a/edge-hub/docker/linux/arm64v8/base/Dockerfile b/edge-hub/docker/linux/arm64v8/base/Dockerfile index a91a462769d..f7f72ba8acd 100644 --- a/edge-hub/docker/linux/arm64v8/base/Dockerfile +++ b/edge-hub/docker/linux/arm64v8/base/Dockerfile @@ -1,5 +1,5 @@ -ARG base_tag=3.0.3-bionic-arm64v8 -FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} +ARG base_tag=3.1.2-bionic-arm64v8 +FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} # Add an unprivileged user account for running Edge Hub ARG EDGEHUBUSER_ID=1000 diff --git a/edge-hub/docker/windows/amd64/Dockerfile b/edge-hub/docker/windows/amd64/Dockerfile index b2f7d83be8a..f2a80f0c8cd 100644 --- a/edge-hub/docker/windows/amd64/Dockerfile +++ b/edge-hub/docker/windows/amd64/Dockerfile @@ -1,5 +1,5 @@ -ARG base_tag=2.1.15-nanoserver-1809 -FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} +ARG base_tag=3.1.2-nanoserver-1809 +FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} ARG EXE_DIR=. diff --git a/edge-hub/docker/windows/arm32v7/Dockerfile b/edge-hub/docker/windows/arm32v7/Dockerfile index fd821f8ddfc..288a907fe9e 100644 --- a/edge-hub/docker/windows/arm32v7/Dockerfile +++ b/edge-hub/docker/windows/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-windows-arm32v7 +ARG base_tag=1.0.5-windows-arm32v7 ARG base_registry FROM ${base_registry}/azureiotedge/azureiotedge-hub-base:${base_tag} diff --git a/edge-hub/docker/windows/arm32v7/base/Dockerfile b/edge-hub/docker/windows/arm32v7/base/Dockerfile index 8bbb0100eee..371e9a1911f 100644 --- a/edge-hub/docker/windows/arm32v7/base/Dockerfile +++ b/edge-hub/docker/windows/arm32v7/base/Dockerfile @@ -1,7 +1,7 @@ # Base image for arm32v7 dotnet-runtime container FROM mcr.microsoft.com/windows/nanoserver:1809-arm32v7 -ENV DOTNET_VERSION 2.1.13 +ENV DOTNET_VERSION 3.1.2 ENV DOTNET_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-runtime-${DOTNET_VERSION}-win-arm.zip RUN curl -SL %DOTNET_DOWNLOAD_URL% --output dotnet.zip \ diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj index 97977b80aa2..28bdaafbf49 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj @@ -1,6 +1,7 @@  + + - netstandard2.0 True Debug;Release;CheckInBuild true diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.CloudProxy/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.CloudProxy/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.csproj index 58d27baed11..ff5a23d5588 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.CloudProxy/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.CloudProxy/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.csproj @@ -1,7 +1,8 @@  + + - netstandard2.0 True Debug;Release;CheckInBuild true diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Microsoft.Azure.Devices.Edge.Hub.Core.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Microsoft.Azure.Devices.Edge.Hub.Core.csproj index 20da210e8ee..00878518694 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Microsoft.Azure.Devices.Edge.Hub.Core.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Microsoft.Azure.Devices.Edge.Hub.Core.csproj @@ -1,7 +1,8 @@  + + - netstandard2.0 latest True Debug;Release;CheckInBuild diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/HttpProtocolHead.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/HttpProtocolHead.cs index a464d9c24e7..5a5a671d8e1 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/HttpProtocolHead.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/HttpProtocolHead.cs @@ -3,18 +3,18 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Http { using System.Threading; using System.Threading.Tasks; - using Microsoft.AspNetCore.Hosting; using Microsoft.Azure.Devices.Edge.Hub.Core; using Microsoft.Azure.Devices.Edge.Util; + using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; public class HttpProtocolHead : IProtocolHead { - readonly IWebHost webHost; + readonly IHost host; - public HttpProtocolHead(IWebHost webHost) + public HttpProtocolHead(IHost host) { - this.webHost = Preconditions.CheckNotNull(webHost, nameof(webHost)); + this.host = Preconditions.CheckNotNull(host, nameof(host)); } public string Name => "HTTP"; @@ -22,18 +22,18 @@ public HttpProtocolHead(IWebHost webHost) public async Task StartAsync() { Events.Starting(); - await this.webHost.StartAsync(); + await this.host.StartAsync(); Events.Started(); } public async Task CloseAsync(CancellationToken token) { Events.Closing(); - await this.webHost.StopAsync(token); + await this.host.StopAsync(token); Events.Closed(); } - public void Dispose() => this.webHost?.Dispose(); + public void Dispose() => this.host?.Dispose(); static class Events { diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj index 2db965f6514..906be687193 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj @@ -1,7 +1,8 @@  + + - netstandard2.0 True Debug;Release;CheckInBuild true diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs index fa4a7d50b2f..3d7c9bc1786 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs @@ -211,9 +211,9 @@ static IDictionary ParseDeviceClientType(string queryParameterSt .Select(s => s.Split(kvsep, 2)) // split each param into a key/value pair .GroupBy(s => s[0]) // group duplicates (by key) together... .Select(s => s.First()) // ...and keep only the first one - .ToDictionary( // convert to Dictionary + .ToDictionary( s => s[0], - s => Uri.UnescapeDataString(s.ElementAtOrEmpty(1))); + s => Uri.UnescapeDataString(s.ElementAtOrEmpty(1))); // convert to Dictionary return queryParameters; } diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj index 744e1df609e..9b2ec0d4613 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj @@ -1,7 +1,8 @@  + + - netstandard2.0 True Debug;Release;CheckInBuild true @@ -9,7 +10,7 @@ - + diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index a8a3768607a..be482b81aa7 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -11,18 +11,19 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service using Microsoft.Azure.Devices.Edge.Hub.Http.Extensions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.Hosting; public class Hosting { - Hosting(IWebHost webHost, IContainer container) + Hosting(IHost host, IContainer container) { - this.WebHost = webHost; + this.Host = host; this.Container = container; } public IContainer Container { get; } - public IWebHost WebHost { get; } + public IHost Host { get; } public static Hosting Initialize( IConfigurationRoot configuration, @@ -33,36 +34,41 @@ public static Hosting Initialize( { int port = configuration.GetValue("httpSettings:port", 443); var certificateMode = clientCertAuthEnabled ? ClientCertificateMode.AllowCertificate : ClientCertificateMode.NoCertificate; - IWebHostBuilder webHostBuilder = new WebHostBuilder() - .UseKestrel( - options => - { - options.Listen( - !Socket.OSSupportsIPv6 ? IPAddress.Any : IPAddress.IPv6Any, - port, - listenOptions => + + IHost host = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder() + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder + .UseKestrel( + options => { - listenOptions.UseHttpsExtensions( - new HttpsConnectionAdapterOptions() + options.Listen( + !Socket.OSSupportsIPv6 ? IPAddress.Any : IPAddress.IPv6Any, + port, + listenOptions => { - ServerCertificate = serverCertificate, - ClientCertificateValidation = (clientCert, chain, policyErrors) => true, - ClientCertificateMode = certificateMode, - SslProtocols = sslProtocols + listenOptions.UseHttpsExtensions( + new HttpsConnectionAdapterOptions() + { + ServerCertificate = serverCertificate, + ClientCertificateValidation = (clientCert, chain, policyErrors) => true, + ClientCertificateMode = certificateMode, + SslProtocols = sslProtocols + }); }); - }); - }) - .UseSockets() - .ConfigureServices( - serviceCollection => - { - serviceCollection.AddSingleton(configuration); - serviceCollection.AddSingleton(dependencyManager); - }) - .UseStartup(); - IWebHost webHost = webHostBuilder.Build(); - IContainer container = webHost.Services.GetService(typeof(IStartup)) is Startup startup ? startup.Container : null; - return new Hosting(webHost, container); + }) + .UseSockets() + .ConfigureServices( + serviceCollection => + { + serviceCollection.AddSingleton(configuration); + serviceCollection.AddSingleton(dependencyManager); + }) + .UseStartup(); + }).Build(); + + IContainer container = host.Services.GetService(typeof(IStartup)) is Startup startup ? startup.Container : null; + return new Hosting(host, container); } } } diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Microsoft.Azure.Devices.Edge.Hub.Service.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Microsoft.Azure.Devices.Edge.Hub.Service.csproj index fb2249da9ca..d3990a63752 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Microsoft.Azure.Devices.Edge.Hub.Service.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Microsoft.Azure.Devices.Edge.Hub.Service.csproj @@ -1,10 +1,8 @@  - - netcoreapp2.1 - - - netcoreapp3.0 + + + + + - netstandard2.0 True Debug;Release;CheckInBuild true diff --git a/edge-util/src/Microsoft.Azure.Devices.Edge.Storage/Microsoft.Azure.Devices.Edge.Storage.csproj b/edge-util/src/Microsoft.Azure.Devices.Edge.Storage/Microsoft.Azure.Devices.Edge.Storage.csproj index 6f7ce266cff..e944f05f498 100644 --- a/edge-util/src/Microsoft.Azure.Devices.Edge.Storage/Microsoft.Azure.Devices.Edge.Storage.csproj +++ b/edge-util/src/Microsoft.Azure.Devices.Edge.Storage/Microsoft.Azure.Devices.Edge.Storage.csproj @@ -1,7 +1,8 @@  + + - netstandard2.0 True Debug;Release;CheckInBuild true diff --git a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/Microsoft.Azure.Devices.Edge.Util.csproj b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/Microsoft.Azure.Devices.Edge.Util.csproj index 772b672887c..20411f7b3c8 100644 --- a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/Microsoft.Azure.Devices.Edge.Util.csproj +++ b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/Microsoft.Azure.Devices.Edge.Util.csproj @@ -1,7 +1,8 @@  + + - netstandard2.0 True Debug;Release;CheckInBuild true @@ -12,7 +13,7 @@ - + diff --git a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/SslProtocolsHelper.cs b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/SslProtocolsHelper.cs index e5091013ba3..39c13c694c2 100644 --- a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/SslProtocolsHelper.cs +++ b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/SslProtocolsHelper.cs @@ -47,15 +47,6 @@ public static SslProtocols Parse(string protocols, SslProtocols defaultSslProtoc public static string Print(this SslProtocols sslProtocols) { var sslProtocolsList = new List(); - if ((sslProtocols & SslProtocols.Ssl2) > 0) - { - sslProtocolsList.Add($"{SslProtocols.Ssl2}"); - } - - if ((sslProtocols & SslProtocols.Ssl3) > 0) - { - sslProtocolsList.Add($"{SslProtocols.Ssl3}"); - } if ((sslProtocols & SslProtocols.Tls) > 0) { diff --git a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2018_06_28/generatedCode/HttpWorkloadClient.cs b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2018_06_28/generatedCode/HttpWorkloadClient.cs index 44cae8645a5..1ebad095627 100644 --- a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2018_06_28/generatedCode/HttpWorkloadClient.cs +++ b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2018_06_28/generatedCode/HttpWorkloadClient.cs @@ -1,46 +1,125 @@ -// Copyright (c) Microsoft. All rights reserved. //---------------------- // -// Generated using the NSwag toolchain v11.17.6.0 (NJsonSchema v9.10.46.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0)) (http://NSwag.org) // //---------------------- -// Note: Code manually changed to replace System.Uri.EscapeDataString with System.Net.WebUtility.UrlEncode + +#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended." +#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword." +#pragma warning disable 472 // Disable "CS0472 The result of the expression is always 'false' since a value of type 'Int32' is never equal to 'null' of type 'Int32?' +#pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ... +#pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..." namespace Microsoft.Azure.Devices.Edge.Util.Edged.Version_2018_06_28.GeneratedCode { -#pragma warning disable // Disable all warnings - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.17.6.0 (NJsonSchema v9.10.46.0 (Newtonsoft.Json v9.0.0.0))")] - public partial class HttpWorkloadClient + using System = global::System; + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0))")] + public partial class HttpWorkloadClient { private string _baseUrl = "http://"; private System.Net.Http.HttpClient _httpClient; private System.Lazy _settings; - + public HttpWorkloadClient(System.Net.Http.HttpClient httpClient) { - _httpClient = httpClient; - _settings = new System.Lazy(() => - { - var settings = new Newtonsoft.Json.JsonSerializerSettings(); - UpdateJsonSerializerSettings(settings); - return settings; - }); + _httpClient = httpClient; + _settings = new System.Lazy(CreateSerializerSettings); } - - public string BaseUrl + + private Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings() + { + var settings = new Newtonsoft.Json.JsonSerializerSettings(); + UpdateJsonSerializerSettings(settings); + return settings; + } + + public string BaseUrl { get { return _baseUrl; } set { _baseUrl = value; } } - + protected Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get { return _settings.Value; } } - + partial void UpdateJsonSerializerSettings(Newtonsoft.Json.JsonSerializerSettings settings); partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, string url); partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder); partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response); - + + /// List modules. + /// The version of the API. + /// Ok + /// A server side error occurred. + public System.Threading.Tasks.Task ListModulesAsync(string api_version) + { + return ListModulesAsync(api_version, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// List modules. + /// The version of the API. + /// Ok + /// A server side error occurred. + public async System.Threading.Tasks.Task ListModulesAsync(string api_version, System.Threading.CancellationToken cancellationToken) + { + if (api_version == null) + throw new System.ArgumentNullException("api_version"); + + var urlBuilder_ = new System.Text.StringBuilder(); + urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules?"); + urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Length--; + + var client_ = _httpClient; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + PrepareRequest(client_, request_, urlBuilder_); + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + try + { + var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value); + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = ((int)response_.StatusCode).ToString(); + if (status_ == "200") + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + return objectResponse_.Object; + } + else + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + } + finally + { + if (response_ != null) + response_.Dispose(); + } + } + } + finally + { + } + } + /// The version of the API. /// The name of the module on whose behalf the payload will be signed. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. @@ -51,32 +130,32 @@ public System.Threading.Tasks.Task SignAsync(string api_version, s { return SignAsync(api_version, name, genid, payload, System.Threading.CancellationToken.None); } - + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// The version of the API. /// The name of the module on whose behalf the payload will be signed. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// The data to be signed. /// Ok /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task SignAsync(string api_version, string name, string genid, SignRequest payload, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - + if (genid == null) throw new System.ArgumentNullException("genid"); - + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/sign?"); - urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{genid}", System.Uri.EscapeDataString(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { @@ -86,13 +165,13 @@ public async System.Threading.Tasks.Task SignAsync(string api_vers content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -102,55 +181,26 @@ public async System.Threading.Tasks.Task SignAsync(string api_vers foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") + if (status_ == "200") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(SignResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - return result_; - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + return objectResponse_.Object; } else - if (status_ == "404") + if (status_ == "404") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } - - return default(SignResponse); } finally { @@ -163,7 +213,7 @@ public async System.Threading.Tasks.Task SignAsync(string api_vers { } } - + /// The version of the API. /// The name of the module on whose behalf the plaintext will be encrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. @@ -174,32 +224,32 @@ public System.Threading.Tasks.Task EncryptAsync(string api_vers { return EncryptAsync(api_version, name, genid, payload, System.Threading.CancellationToken.None); } - + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// The version of the API. /// The name of the module on whose behalf the plaintext will be encrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// The data to be encrypted. /// OK /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task EncryptAsync(string api_version, string name, string genid, EncryptRequest payload, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - + if (genid == null) throw new System.ArgumentNullException("genid"); - + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/encrypt?"); - urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{genid}", System.Uri.EscapeDataString(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { @@ -209,13 +259,13 @@ public async System.Threading.Tasks.Task EncryptAsync(string ap content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -225,55 +275,26 @@ public async System.Threading.Tasks.Task EncryptAsync(string ap foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") + if (status_ == "200") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(EncryptResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - return result_; - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + return objectResponse_.Object; } else - if (status_ == "404") + if (status_ == "404") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } - - return default(EncryptResponse); } finally { @@ -286,7 +307,7 @@ public async System.Threading.Tasks.Task EncryptAsync(string ap { } } - + /// The version of the API. /// The name of the module on whose behalf the ciphertext will be decrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. @@ -297,32 +318,32 @@ public System.Threading.Tasks.Task DecryptAsync(string api_vers { return DecryptAsync(api_version, name, genid, payload, System.Threading.CancellationToken.None); } - + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// The version of the API. /// The name of the module on whose behalf the ciphertext will be decrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// The data to be decrypted. /// OK /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task DecryptAsync(string api_version, string name, string genid, DecryptRequest payload, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - + if (genid == null) throw new System.ArgumentNullException("genid"); - + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/decrypt?"); - urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{genid}", System.Uri.EscapeDataString(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { @@ -332,13 +353,13 @@ public async System.Threading.Tasks.Task DecryptAsync(string ap content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -348,55 +369,26 @@ public async System.Threading.Tasks.Task DecryptAsync(string ap foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") + if (status_ == "200") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(DecryptResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - return result_; - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + return objectResponse_.Object; } else - if (status_ == "404") + if (status_ == "404") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } - - return default(DecryptResponse); } finally { @@ -409,55 +401,53 @@ public async System.Threading.Tasks.Task DecryptAsync(string ap { } } - + /// The version of the API. - /// The name of the module to get certificate. (urlencoded) - /// The generation identifier for the module as generated by IoT Hub. + /// The name of the module needed to obtain the certificate. (urlencoded) + /// Parameters for certificate creation. /// Ok /// A server side error occurred. - public System.Threading.Tasks.Task CreateIdentityCertificateAsync(string api_version, string name, string genid) + public System.Threading.Tasks.Task CreateIdentityCertificateAsync(string api_version, string name, IdentityCertificateRequest request) { - return CreateIdentityCertificateAsync(api_version, name, genid, System.Threading.CancellationToken.None); + return CreateIdentityCertificateAsync(api_version, name, request, System.Threading.CancellationToken.None); } - + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// The version of the API. - /// The name of the module to get certificate. (urlencoded) - /// The generation identifier for the module as generated by IoT Hub. + /// The name of the module needed to obtain the certificate. (urlencoded) + /// Parameters for certificate creation. /// Ok /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - public async System.Threading.Tasks.Task CreateIdentityCertificateAsync(string api_version, string name, string genid, System.Threading.CancellationToken cancellationToken) + public async System.Threading.Tasks.Task CreateIdentityCertificateAsync(string api_version, string name, IdentityCertificateRequest request, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - - if (genid == null) - throw new System.ArgumentNullException("genid"); - + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/certificate/identity?"); - urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/certificate/identity?"); + urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { using (var request_ = new System.Net.Http.HttpRequestMessage()) { - request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json"); + var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(request, _settings.Value)); + content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -467,55 +457,26 @@ public async System.Threading.Tasks.Task CreateIdentityCert foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") + if (status_ == "201") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(CertificateResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - return result_; - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + return objectResponse_.Object; } else - if (status_ == "404") + if (status_ == "404") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } - - return default(CertificateResponse); } finally { @@ -528,7 +489,7 @@ public async System.Threading.Tasks.Task CreateIdentityCert { } } - + /// The version of the API. /// The name of the module to get certificate. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. @@ -539,32 +500,32 @@ public System.Threading.Tasks.Task CreateServerCertificateA { return CreateServerCertificateAsync(api_version, name, genid, request, System.Threading.CancellationToken.None); } - + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// The version of the API. /// The name of the module to get certificate. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// Parameters for certificate creation. /// Ok /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task CreateServerCertificateAsync(string api_version, string name, string genid, ServerCertificateRequest request, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - + if (genid == null) throw new System.ArgumentNullException("genid"); - + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/certificate/server?"); - urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{genid}", System.Uri.EscapeDataString(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { @@ -574,13 +535,13 @@ public async System.Threading.Tasks.Task CreateServerCertif content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -590,55 +551,26 @@ public async System.Threading.Tasks.Task CreateServerCertif foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "201") + if (status_ == "201") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(CertificateResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - return result_; - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + return objectResponse_.Object; } else - if (status_ == "404") + if (status_ == "404") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } - - return default(CertificateResponse); } finally { @@ -651,7 +583,7 @@ public async System.Threading.Tasks.Task CreateServerCertif { } } - + /// The version of the API. /// Ok /// A server side error occurred. @@ -659,34 +591,34 @@ public System.Threading.Tasks.Task TrustBundleAsync(string { return TrustBundleAsync(api_version, System.Threading.CancellationToken.None); } - + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// The version of the API. /// Ok /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task TrustBundleAsync(string api_version, System.Threading.CancellationToken cancellationToken) { if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/trust-bundle?"); - urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { using (var request_ = new System.Net.Http.HttpRequestMessage()) { request_.Method = new System.Net.Http.HttpMethod("GET"); - request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -696,40 +628,20 @@ public async System.Threading.Tasks.Task TrustBundleAsync(s foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") + if (status_ == "200") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(TrustBundleResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - return result_; - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + return objectResponse_.Object; } else { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } - - return default(TrustBundleResponse); } finally { @@ -742,7 +654,64 @@ public async System.Threading.Tasks.Task TrustBundleAsync(s { } } - + + protected struct ObjectResponseResult + { + public ObjectResponseResult(T responseObject, string responseText) + { + this.Object = responseObject; + this.Text = responseText; + } + + public T Object { get; } + + public string Text { get; } + } + + public bool ReadResponseAsString { get; set; } + + protected virtual async System.Threading.Tasks.Task> ReadObjectResponseAsync(System.Net.Http.HttpResponseMessage response, System.Collections.Generic.IReadOnlyDictionary> headers) + { + if (response == null || response.Content == null) + { + return new ObjectResponseResult(default(T), string.Empty); + } + + if (ReadResponseAsString) + { + var responseText = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + var typedBody = Newtonsoft.Json.JsonConvert.DeserializeObject(responseText, JsonSerializerSettings); + return new ObjectResponseResult(typedBody, responseText); + } + catch (Newtonsoft.Json.JsonException exception) + { + var message = "Could not deserialize the response body string as " + typeof(T).FullName + "."; + throw new IoTEdgedException(message, (int)response.StatusCode, responseText, headers, exception); + } + } + else + { + try + { + using (var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false)) + using (var streamReader = new System.IO.StreamReader(responseStream)) + using (var jsonTextReader = new Newtonsoft.Json.JsonTextReader(streamReader)) + { + var serializer = Newtonsoft.Json.JsonSerializer.Create(JsonSerializerSettings); + var typedBody = serializer.Deserialize(jsonTextReader); + return new ObjectResponseResult(typedBody, string.Empty); + } + } + catch (Newtonsoft.Json.JsonException exception) + { + var message = "Could not deserialize the response body stream as " + typeof(T).FullName + "."; + throw new IoTEdgedException(message, (int)response.StatusCode, string.Empty, headers, exception); + } + } + } + private string ConvertToString(object value, System.Globalization.CultureInfo cultureInfo) { if (value is System.Enum) @@ -753,659 +722,348 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu var field = System.Reflection.IntrospectionExtensions.GetTypeInfo(value.GetType()).GetDeclaredField(name); if (field != null) { - var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute)) + var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute)) as System.Runtime.Serialization.EnumMemberAttribute; if (attribute != null) { - return attribute.Value; + return attribute.Value != null ? attribute.Value : name; } } } } + else if (value is bool) { + return System.Convert.ToString(value, cultureInfo).ToLowerInvariant(); + } else if (value is byte[]) { - return System.Convert.ToBase64String((byte[])value); + return System.Convert.ToBase64String((byte[]) value); } - else if (value.GetType().IsArray) + else if (value != null && value.GetType().IsArray) { - var array = System.Linq.Enumerable.OfType((System.Array)value); + var array = System.Linq.Enumerable.OfType((System.Array) value); return string.Join(",", System.Linq.Enumerable.Select(array, o => ConvertToString(o, cultureInfo))); } - + return System.Convert.ToString(value, cultureInfo); } } - - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class SignRequest : System.ComponentModel.INotifyPropertyChanged + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class ModuleList + { + [Newtonsoft.Json.JsonProperty("modules", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required] + public System.Collections.Generic.ICollection Modules { get; set; } = new System.Collections.ObjectModel.Collection(); + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class ModuleDetails + { + /// System generated unique identitier. + [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Id { get; set; } + + /// The name of the module. + [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Name { get; set; } + + /// The type of a module. + [Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Type { get; set; } + + [Newtonsoft.Json.JsonProperty("config", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required] + public Config Config { get; set; } = new Config(); + + [Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required] + public Status Status { get; set; } = new Status(); + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class Config + { + [Newtonsoft.Json.JsonProperty("settings", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required] + public object Settings { get; set; } = new object(); + + [Newtonsoft.Json.JsonProperty("env", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.ICollection Env { get; set; } + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class Status + { + [Newtonsoft.Json.JsonProperty("startTime", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.DateTimeOffset? StartTime { get; set; } + + [Newtonsoft.Json.JsonProperty("exitStatus", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public ExitStatus ExitStatus { get; set; } + + [Newtonsoft.Json.JsonProperty("runtimeStatus", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required] + public RuntimeStatus RuntimeStatus { get; set; } = new RuntimeStatus(); + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class EnvVar + { + [Newtonsoft.Json.JsonProperty("key", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Key { get; set; } + + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Value { get; set; } + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class ExitStatus + { + [Newtonsoft.Json.JsonProperty("exitTime", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public System.DateTimeOffset ExitTime { get; set; } + + [Newtonsoft.Json.JsonProperty("statusCode", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string StatusCode { get; set; } + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class RuntimeStatus + { + [Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Status { get; set; } + + [Newtonsoft.Json.JsonProperty("description", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Description { get; set; } + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class SignRequest { - private string _keyId; - private SignRequestAlgo _algo; - private byte[] _data; - /// Name of key to perform sign operation. [Newtonsoft.Json.JsonProperty("keyId", Required = Newtonsoft.Json.Required.Always)] - public string KeyId - { - get { return _keyId; } - set - { - if (_keyId != value) - { - _keyId = value; - RaisePropertyChanged(); - } - } - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string KeyId { get; set; } + /// Sign algorithm to be used. [Newtonsoft.Json.JsonProperty("algo", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public SignRequestAlgo Algo - { - get { return _algo; } - set - { - if (_algo != value) - { - _algo = value; - RaisePropertyChanged(); - } - } - } - + public SignRequestAlgo Algo { get; set; } + /// Data to be signed. [Newtonsoft.Json.JsonProperty("data", Required = Newtonsoft.Json.Required.Always)] - public byte[] Data - { - get { return _data; } - set - { - if (_data != value) - { - _data = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static SignRequest FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] Data { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class SignResponse : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class SignResponse { - private byte[] _digest; - /// Signature of the data. [Newtonsoft.Json.JsonProperty("digest", Required = Newtonsoft.Json.Required.Always)] - public byte[] Digest - { - get { return _digest; } - set - { - if (_digest != value) - { - _digest = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static SignResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] Digest { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class EncryptRequest : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class EncryptRequest { - private byte[] _plaintext; - private byte[] _initializationVector; - /// The data to be encrypted. [Newtonsoft.Json.JsonProperty("plaintext", Required = Newtonsoft.Json.Required.Always)] - public byte[] Plaintext - { - get { return _plaintext; } - set - { - if (_plaintext != value) - { - _plaintext = value; - RaisePropertyChanged(); - } - } - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] Plaintext { get; set; } + /// An initialization vector used to encrypt the data. [Newtonsoft.Json.JsonProperty("initializationVector", Required = Newtonsoft.Json.Required.Always)] - public byte[] InitializationVector - { - get { return _initializationVector; } - set - { - if (_initializationVector != value) - { - _initializationVector = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static EncryptRequest FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] InitializationVector { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class EncryptResponse : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class EncryptResponse { - private byte[] _ciphertext; - /// The encrypted form of the data encoded in base 64. [Newtonsoft.Json.JsonProperty("ciphertext", Required = Newtonsoft.Json.Required.Always)] - public byte[] Ciphertext - { - get { return _ciphertext; } - set - { - if (_ciphertext != value) - { - _ciphertext = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static EncryptResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] Ciphertext { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class DecryptRequest : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class DecryptRequest { - private byte[] _ciphertext; - private byte[] _initializationVector; - /// The data to be decrypted. [Newtonsoft.Json.JsonProperty("ciphertext", Required = Newtonsoft.Json.Required.Always)] - public byte[] Ciphertext - { - get { return _ciphertext; } - set - { - if (_ciphertext != value) - { - _ciphertext = value; - RaisePropertyChanged(); - } - } - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] Ciphertext { get; set; } + /// An initialization vector used to decrypt the data. [Newtonsoft.Json.JsonProperty("initializationVector", Required = Newtonsoft.Json.Required.Always)] - public byte[] InitializationVector - { - get { return _initializationVector; } - set - { - if (_initializationVector != value) - { - _initializationVector = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static DecryptRequest FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] InitializationVector { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class DecryptResponse : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class DecryptResponse { - private byte[] _plaintext; - /// The decrypted form of the data encoded in base 64. [Newtonsoft.Json.JsonProperty("plaintext", Required = Newtonsoft.Json.Required.Always)] - public byte[] Plaintext - { - get { return _plaintext; } - set - { - if (_plaintext != value) - { - _plaintext = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static DecryptResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] Plaintext { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class ServerCertificateRequest : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class ServerCertificateRequest { - private string _commonName; - private System.DateTime _expiration; - /// Subject common name [Newtonsoft.Json.JsonProperty("commonName", Required = Newtonsoft.Json.Required.Always)] - public string CommonName - { - get { return _commonName; } - set - { - if (_commonName != value) - { - _commonName = value; - RaisePropertyChanged(); - } - } - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string CommonName { get; set; } + /// Certificate expiration date-time (ISO 8601) [Newtonsoft.Json.JsonProperty("expiration", Required = Newtonsoft.Json.Required.Always)] - public System.DateTime Expiration - { - get { return _expiration; } - set - { - if (_expiration != value) - { - _expiration = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static ServerCertificateRequest FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public System.DateTimeOffset Expiration { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class CertificateResponse : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class IdentityCertificateRequest + { + /// Certificate expiration date-time (ISO 8601) + [Newtonsoft.Json.JsonProperty("expiration", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.DateTimeOffset? Expiration { get; set; } + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class CertificateResponse { - private PrivateKey _privateKey = new PrivateKey(); - private string _certificate; - private System.DateTime _expiration; - [Newtonsoft.Json.JsonProperty("privateKey", Required = Newtonsoft.Json.Required.Always)] - public PrivateKey PrivateKey - { - get { return _privateKey; } - set - { - if (_privateKey != value) - { - _privateKey = value; - RaisePropertyChanged(); - } - } - } - + [System.ComponentModel.DataAnnotations.Required] + public PrivateKey PrivateKey { get; set; } = new PrivateKey(); + /// Base64 encoded PEM formatted byte array containing the certificate and its chain. [Newtonsoft.Json.JsonProperty("certificate", Required = Newtonsoft.Json.Required.Always)] - public string Certificate - { - get { return _certificate; } - set - { - if (_certificate != value) - { - _certificate = value; - RaisePropertyChanged(); - } - } - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Certificate { get; set; } + /// Certificate expiration date-time (ISO 8601) [Newtonsoft.Json.JsonProperty("expiration", Required = Newtonsoft.Json.Required.Always)] - public System.DateTime Expiration - { - get { return _expiration; } - set - { - if (_expiration != value) - { - _expiration = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static CertificateResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public System.DateTimeOffset Expiration { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class TrustBundleResponse : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class TrustBundleResponse { - private string _certificate; - /// Base64 encoded PEM formatted byte array containing the trusted certificates. [Newtonsoft.Json.JsonProperty("certificate", Required = Newtonsoft.Json.Required.Always)] - public string Certificate - { - get { return _certificate; } - set - { - if (_certificate != value) - { - _certificate = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static TrustBundleResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Certificate { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class PrivateKey : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class PrivateKey { - private PrivateKeyType _type; - private string _ref; - private string _bytes; - /// Indicates format of the key (present in PEM formatted bytes or a reference) [Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public PrivateKeyType Type - { - get { return _type; } - set - { - if (_type != value) - { - _type = value; - RaisePropertyChanged(); - } - } - } - + public PrivateKeyType Type { get; set; } + /// Reference to private key. [Newtonsoft.Json.JsonProperty("ref", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Ref - { - get { return _ref; } - set - { - if (_ref != value) - { - _ref = value; - RaisePropertyChanged(); - } - } - } - + public string Ref { get; set; } + /// Base64 encoded PEM formatted byte array [Newtonsoft.Json.JsonProperty("bytes", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Bytes - { - get { return _bytes; } - set - { - if (_bytes != value) - { - _bytes = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static PrivateKey FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + public string Bytes { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class ErrorResponse : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class ErrorResponse { - private string _message; - [Newtonsoft.Json.JsonProperty("message", Required = Newtonsoft.Json.Required.Always)] - public string Message - { - get { return _message; } - set - { - if (_message != value) - { - _message = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static ErrorResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Message { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] public enum SignRequestAlgo { - [System.Runtime.Serialization.EnumMember(Value = "HMACSHA256")] + [System.Runtime.Serialization.EnumMember(Value = @"HMACSHA256")] HMACSHA256 = 0, - + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] public enum PrivateKeyType { - [System.Runtime.Serialization.EnumMember(Value = "ref")] + [System.Runtime.Serialization.EnumMember(Value = @"ref")] Ref = 0, - - [System.Runtime.Serialization.EnumMember(Value = "key")] + + [System.Runtime.Serialization.EnumMember(Value = @"key")] Key = 1, - + } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.17.6.0 (NJsonSchema v9.10.46.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0))")] public partial class IoTEdgedException : System.Exception { public int StatusCode { get; private set; } public string Response { get; private set; } - public System.Collections.Generic.Dictionary> Headers { get; private set; } + public System.Collections.Generic.IReadOnlyDictionary> Headers { get; private set; } - public IoTEdgedException(string message, int statusCode, string response, System.Collections.Generic.Dictionary> headers, System.Exception innerException) - : base(message, innerException) + public IoTEdgedException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, System.Exception innerException) + : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + response.Substring(0, response.Length >= 512 ? 512 : response.Length), innerException) { StatusCode = statusCode; - Response = response; + Response = response; Headers = headers; } @@ -1415,12 +1073,12 @@ public override string ToString() } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.17.6.0 (NJsonSchema v9.10.46.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0))")] public partial class IoTEdgedException : IoTEdgedException { public TResult Result { get; private set; } - public IoTEdgedException(string message, int statusCode, string response, System.Collections.Generic.Dictionary> headers, TResult result, System.Exception innerException) + public IoTEdgedException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, TResult result, System.Exception innerException) : base(message, statusCode, response, headers, innerException) { Result = result; @@ -1428,3 +1086,9 @@ public IoTEdgedException(string message, int statusCode, string response, System } } + +#pragma warning restore 1591 +#pragma warning restore 1573 +#pragma warning restore 472 +#pragma warning restore 114 +#pragma warning restore 108 diff --git a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2019_01_30/generatedCode/HttpWorkloadClient.cs b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2019_01_30/generatedCode/HttpWorkloadClient.cs index c22b0ef0a36..1e7438c7568 100644 --- a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2019_01_30/generatedCode/HttpWorkloadClient.cs +++ b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2019_01_30/generatedCode/HttpWorkloadClient.cs @@ -1,45 +1,125 @@ //---------------------- // -// Generated using the NSwag toolchain v11.17.6.0 (NJsonSchema v9.10.46.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0)) (http://NSwag.org) // //---------------------- -// Note: Code manually changed to replace System.Uri.EscapeDataString with System.Net.WebUtility.UrlEncode + +#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended." +#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword." +#pragma warning disable 472 // Disable "CS0472 The result of the expression is always 'false' since a value of type 'Int32' is never equal to 'null' of type 'Int32?' +#pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ... +#pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..." namespace Microsoft.Azure.Devices.Edge.Util.Edged.Version_2019_01_30.GeneratedCode { -#pragma warning disable // Disable all warnings - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.17.6.0 (NJsonSchema v9.10.46.0 (Newtonsoft.Json v9.0.0.0))")] - public partial class HttpWorkloadClient + using System = global::System; + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0))")] + public partial class HttpWorkloadClient { private string _baseUrl = "http://"; private System.Net.Http.HttpClient _httpClient; private System.Lazy _settings; - + public HttpWorkloadClient(System.Net.Http.HttpClient httpClient) { - _httpClient = httpClient; - _settings = new System.Lazy(() => - { - var settings = new Newtonsoft.Json.JsonSerializerSettings(); - UpdateJsonSerializerSettings(settings); - return settings; - }); + _httpClient = httpClient; + _settings = new System.Lazy(CreateSerializerSettings); } - - public string BaseUrl + + private Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings() + { + var settings = new Newtonsoft.Json.JsonSerializerSettings(); + UpdateJsonSerializerSettings(settings); + return settings; + } + + public string BaseUrl { get { return _baseUrl; } set { _baseUrl = value; } } - + protected Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get { return _settings.Value; } } - + partial void UpdateJsonSerializerSettings(Newtonsoft.Json.JsonSerializerSettings settings); partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, string url); partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder); partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response); - + + /// List modules. + /// The version of the API. + /// Ok + /// A server side error occurred. + public System.Threading.Tasks.Task ListModulesAsync(string api_version) + { + return ListModulesAsync(api_version, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// List modules. + /// The version of the API. + /// Ok + /// A server side error occurred. + public async System.Threading.Tasks.Task ListModulesAsync(string api_version, System.Threading.CancellationToken cancellationToken) + { + if (api_version == null) + throw new System.ArgumentNullException("api_version"); + + var urlBuilder_ = new System.Text.StringBuilder(); + urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules?"); + urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Length--; + + var client_ = _httpClient; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + PrepareRequest(client_, request_, urlBuilder_); + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + try + { + var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value); + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = ((int)response_.StatusCode).ToString(); + if (status_ == "200") + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + return objectResponse_.Object; + } + else + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + } + finally + { + if (response_ != null) + response_.Dispose(); + } + } + } + finally + { + } + } + /// The version of the API. /// The name of the module on whose behalf the payload will be signed. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. @@ -50,32 +130,32 @@ public System.Threading.Tasks.Task SignAsync(string api_version, s { return SignAsync(api_version, name, genid, payload, System.Threading.CancellationToken.None); } - + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// The version of the API. /// The name of the module on whose behalf the payload will be signed. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// The data to be signed. /// Ok /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task SignAsync(string api_version, string name, string genid, SignRequest payload, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - + if (genid == null) throw new System.ArgumentNullException("genid"); - + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/sign?"); - urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{genid}", System.Uri.EscapeDataString(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { @@ -85,13 +165,13 @@ public async System.Threading.Tasks.Task SignAsync(string api_vers content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -101,55 +181,26 @@ public async System.Threading.Tasks.Task SignAsync(string api_vers foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") + if (status_ == "200") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(SignResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - return result_; - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + return objectResponse_.Object; } else - if (status_ == "404") + if (status_ == "404") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } - - return default(SignResponse); } finally { @@ -162,7 +213,7 @@ public async System.Threading.Tasks.Task SignAsync(string api_vers { } } - + /// The version of the API. /// The name of the module on whose behalf the plaintext will be encrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. @@ -173,32 +224,32 @@ public System.Threading.Tasks.Task EncryptAsync(string api_vers { return EncryptAsync(api_version, name, genid, payload, System.Threading.CancellationToken.None); } - + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// The version of the API. /// The name of the module on whose behalf the plaintext will be encrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// The data to be encrypted. /// OK /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task EncryptAsync(string api_version, string name, string genid, EncryptRequest payload, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - + if (genid == null) throw new System.ArgumentNullException("genid"); - + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/encrypt?"); - urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{genid}", System.Uri.EscapeDataString(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { @@ -208,13 +259,13 @@ public async System.Threading.Tasks.Task EncryptAsync(string ap content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -224,55 +275,26 @@ public async System.Threading.Tasks.Task EncryptAsync(string ap foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") + if (status_ == "200") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(EncryptResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - return result_; - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + return objectResponse_.Object; } else - if (status_ == "404") + if (status_ == "404") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } - - return default(EncryptResponse); } finally { @@ -285,7 +307,7 @@ public async System.Threading.Tasks.Task EncryptAsync(string ap { } } - + /// The version of the API. /// The name of the module on whose behalf the ciphertext will be decrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. @@ -296,32 +318,32 @@ public System.Threading.Tasks.Task DecryptAsync(string api_vers { return DecryptAsync(api_version, name, genid, payload, System.Threading.CancellationToken.None); } - + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// The version of the API. /// The name of the module on whose behalf the ciphertext will be decrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// The data to be decrypted. /// OK /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task DecryptAsync(string api_version, string name, string genid, DecryptRequest payload, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - + if (genid == null) throw new System.ArgumentNullException("genid"); - + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/decrypt?"); - urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{genid}", System.Uri.EscapeDataString(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { @@ -331,13 +353,13 @@ public async System.Threading.Tasks.Task DecryptAsync(string ap content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -347,55 +369,26 @@ public async System.Threading.Tasks.Task DecryptAsync(string ap foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") + if (status_ == "200") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(DecryptResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - return result_; - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + return objectResponse_.Object; } else - if (status_ == "404") + if (status_ == "404") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } - - return default(DecryptResponse); } finally { @@ -408,55 +401,53 @@ public async System.Threading.Tasks.Task DecryptAsync(string ap { } } - + /// The version of the API. - /// The name of the module to get certificate. (urlencoded) - /// The generation identifier for the module as generated by IoT Hub. + /// The name of the module needed to obtain the certificate. (urlencoded) + /// Parameters for certificate creation. /// Ok /// A server side error occurred. - public System.Threading.Tasks.Task CreateIdentityCertificateAsync(string api_version, string name, string genid) + public System.Threading.Tasks.Task CreateIdentityCertificateAsync(string api_version, string name, IdentityCertificateRequest request) { - return CreateIdentityCertificateAsync(api_version, name, genid, System.Threading.CancellationToken.None); + return CreateIdentityCertificateAsync(api_version, name, request, System.Threading.CancellationToken.None); } - + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// The version of the API. - /// The name of the module to get certificate. (urlencoded) - /// The generation identifier for the module as generated by IoT Hub. + /// The name of the module needed to obtain the certificate. (urlencoded) + /// Parameters for certificate creation. /// Ok /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - public async System.Threading.Tasks.Task CreateIdentityCertificateAsync(string api_version, string name, string genid, System.Threading.CancellationToken cancellationToken) + public async System.Threading.Tasks.Task CreateIdentityCertificateAsync(string api_version, string name, IdentityCertificateRequest request, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - - if (genid == null) - throw new System.ArgumentNullException("genid"); - + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/certificate/identity?"); - urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/certificate/identity?"); + urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { using (var request_ = new System.Net.Http.HttpRequestMessage()) { - request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json"); + var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(request, _settings.Value)); + content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -466,55 +457,26 @@ public async System.Threading.Tasks.Task CreateIdentityCert foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") + if (status_ == "201") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(CertificateResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - return result_; - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + return objectResponse_.Object; } else - if (status_ == "404") + if (status_ == "404") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } - - return default(CertificateResponse); } finally { @@ -527,7 +489,7 @@ public async System.Threading.Tasks.Task CreateIdentityCert { } } - + /// The version of the API. /// The name of the module to get certificate. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. @@ -538,32 +500,32 @@ public System.Threading.Tasks.Task CreateServerCertificateA { return CreateServerCertificateAsync(api_version, name, genid, request, System.Threading.CancellationToken.None); } - + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// The version of the API. /// The name of the module to get certificate. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// Parameters for certificate creation. /// Ok /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task CreateServerCertificateAsync(string api_version, string name, string genid, ServerCertificateRequest request, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - + if (genid == null) throw new System.ArgumentNullException("genid"); - + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/certificate/server?"); - urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{genid}", System.Uri.EscapeDataString(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { @@ -573,13 +535,13 @@ public async System.Threading.Tasks.Task CreateServerCertif content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -589,55 +551,26 @@ public async System.Threading.Tasks.Task CreateServerCertif foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "201") + if (status_ == "201") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(CertificateResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - return result_; - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + return objectResponse_.Object; } else - if (status_ == "404") + if (status_ == "404") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } - - return default(CertificateResponse); } finally { @@ -650,7 +583,7 @@ public async System.Threading.Tasks.Task CreateServerCertif { } } - + /// The version of the API. /// Ok /// A server side error occurred. @@ -658,34 +591,34 @@ public System.Threading.Tasks.Task TrustBundleAsync(string { return TrustBundleAsync(api_version, System.Threading.CancellationToken.None); } - + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// The version of the API. /// Ok /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task TrustBundleAsync(string api_version, System.Threading.CancellationToken cancellationToken) { if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/trust-bundle?"); - urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { using (var request_ = new System.Net.Http.HttpRequestMessage()) { request_.Method = new System.Net.Http.HttpMethod("GET"); - request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); - + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -695,40 +628,20 @@ public async System.Threading.Tasks.Task TrustBundleAsync(s foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") + if (status_ == "200") { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(TrustBundleResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - return result_; - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + return objectResponse_.Object; } else { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); } - - return default(TrustBundleResponse); } finally { @@ -741,7 +654,64 @@ public async System.Threading.Tasks.Task TrustBundleAsync(s { } } - + + protected struct ObjectResponseResult + { + public ObjectResponseResult(T responseObject, string responseText) + { + this.Object = responseObject; + this.Text = responseText; + } + + public T Object { get; } + + public string Text { get; } + } + + public bool ReadResponseAsString { get; set; } + + protected virtual async System.Threading.Tasks.Task> ReadObjectResponseAsync(System.Net.Http.HttpResponseMessage response, System.Collections.Generic.IReadOnlyDictionary> headers) + { + if (response == null || response.Content == null) + { + return new ObjectResponseResult(default(T), string.Empty); + } + + if (ReadResponseAsString) + { + var responseText = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + var typedBody = Newtonsoft.Json.JsonConvert.DeserializeObject(responseText, JsonSerializerSettings); + return new ObjectResponseResult(typedBody, responseText); + } + catch (Newtonsoft.Json.JsonException exception) + { + var message = "Could not deserialize the response body string as " + typeof(T).FullName + "."; + throw new IoTEdgedException(message, (int)response.StatusCode, responseText, headers, exception); + } + } + else + { + try + { + using (var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false)) + using (var streamReader = new System.IO.StreamReader(responseStream)) + using (var jsonTextReader = new Newtonsoft.Json.JsonTextReader(streamReader)) + { + var serializer = Newtonsoft.Json.JsonSerializer.Create(JsonSerializerSettings); + var typedBody = serializer.Deserialize(jsonTextReader); + return new ObjectResponseResult(typedBody, string.Empty); + } + } + catch (Newtonsoft.Json.JsonException exception) + { + var message = "Could not deserialize the response body stream as " + typeof(T).FullName + "."; + throw new IoTEdgedException(message, (int)response.StatusCode, string.Empty, headers, exception); + } + } + } + private string ConvertToString(object value, System.Globalization.CultureInfo cultureInfo) { if (value is System.Enum) @@ -752,659 +722,348 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu var field = System.Reflection.IntrospectionExtensions.GetTypeInfo(value.GetType()).GetDeclaredField(name); if (field != null) { - var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute)) + var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute)) as System.Runtime.Serialization.EnumMemberAttribute; if (attribute != null) { - return attribute.Value; + return attribute.Value != null ? attribute.Value : name; } } } } + else if (value is bool) { + return System.Convert.ToString(value, cultureInfo).ToLowerInvariant(); + } else if (value is byte[]) { - return System.Convert.ToBase64String((byte[])value); + return System.Convert.ToBase64String((byte[]) value); } - else if (value.GetType().IsArray) + else if (value != null && value.GetType().IsArray) { - var array = System.Linq.Enumerable.OfType((System.Array)value); + var array = System.Linq.Enumerable.OfType((System.Array) value); return string.Join(",", System.Linq.Enumerable.Select(array, o => ConvertToString(o, cultureInfo))); } - + return System.Convert.ToString(value, cultureInfo); } } - - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class SignRequest : System.ComponentModel.INotifyPropertyChanged + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class ModuleList + { + [Newtonsoft.Json.JsonProperty("modules", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required] + public System.Collections.Generic.ICollection Modules { get; set; } = new System.Collections.ObjectModel.Collection(); + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class ModuleDetails + { + /// System generated unique identitier. + [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Id { get; set; } + + /// The name of the module. + [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Name { get; set; } + + /// The type of a module. + [Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Type { get; set; } + + [Newtonsoft.Json.JsonProperty("config", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required] + public Config Config { get; set; } = new Config(); + + [Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required] + public Status Status { get; set; } = new Status(); + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class Config + { + [Newtonsoft.Json.JsonProperty("settings", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required] + public object Settings { get; set; } = new object(); + + [Newtonsoft.Json.JsonProperty("env", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.ICollection Env { get; set; } + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class Status + { + [Newtonsoft.Json.JsonProperty("startTime", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.DateTimeOffset? StartTime { get; set; } + + [Newtonsoft.Json.JsonProperty("exitStatus", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public ExitStatus ExitStatus { get; set; } + + [Newtonsoft.Json.JsonProperty("runtimeStatus", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required] + public RuntimeStatus RuntimeStatus { get; set; } = new RuntimeStatus(); + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class EnvVar + { + [Newtonsoft.Json.JsonProperty("key", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Key { get; set; } + + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Value { get; set; } + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class ExitStatus + { + [Newtonsoft.Json.JsonProperty("exitTime", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public System.DateTimeOffset ExitTime { get; set; } + + [Newtonsoft.Json.JsonProperty("statusCode", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string StatusCode { get; set; } + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class RuntimeStatus + { + [Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Status { get; set; } + + [Newtonsoft.Json.JsonProperty("description", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Description { get; set; } + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class SignRequest { - private string _keyId; - private SignRequestAlgo _algo; - private byte[] _data; - /// Name of key to perform sign operation. [Newtonsoft.Json.JsonProperty("keyId", Required = Newtonsoft.Json.Required.Always)] - public string KeyId - { - get { return _keyId; } - set - { - if (_keyId != value) - { - _keyId = value; - RaisePropertyChanged(); - } - } - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string KeyId { get; set; } + /// Sign algorithm to be used. [Newtonsoft.Json.JsonProperty("algo", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public SignRequestAlgo Algo - { - get { return _algo; } - set - { - if (_algo != value) - { - _algo = value; - RaisePropertyChanged(); - } - } - } - + public SignRequestAlgo Algo { get; set; } + /// Data to be signed. [Newtonsoft.Json.JsonProperty("data", Required = Newtonsoft.Json.Required.Always)] - public byte[] Data - { - get { return _data; } - set - { - if (_data != value) - { - _data = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static SignRequest FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] Data { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class SignResponse : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class SignResponse { - private byte[] _digest; - /// Signature of the data. [Newtonsoft.Json.JsonProperty("digest", Required = Newtonsoft.Json.Required.Always)] - public byte[] Digest - { - get { return _digest; } - set - { - if (_digest != value) - { - _digest = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static SignResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] Digest { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class EncryptRequest : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class EncryptRequest { - private byte[] _plaintext; - private byte[] _initializationVector; - /// The data to be encrypted. [Newtonsoft.Json.JsonProperty("plaintext", Required = Newtonsoft.Json.Required.Always)] - public byte[] Plaintext - { - get { return _plaintext; } - set - { - if (_plaintext != value) - { - _plaintext = value; - RaisePropertyChanged(); - } - } - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] Plaintext { get; set; } + /// An initialization vector used to encrypt the data. [Newtonsoft.Json.JsonProperty("initializationVector", Required = Newtonsoft.Json.Required.Always)] - public byte[] InitializationVector - { - get { return _initializationVector; } - set - { - if (_initializationVector != value) - { - _initializationVector = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static EncryptRequest FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] InitializationVector { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class EncryptResponse : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class EncryptResponse { - private byte[] _ciphertext; - /// The encrypted form of the data encoded in base 64. [Newtonsoft.Json.JsonProperty("ciphertext", Required = Newtonsoft.Json.Required.Always)] - public byte[] Ciphertext - { - get { return _ciphertext; } - set - { - if (_ciphertext != value) - { - _ciphertext = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static EncryptResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] Ciphertext { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class DecryptRequest : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class DecryptRequest { - private byte[] _ciphertext; - private byte[] _initializationVector; - /// The data to be decrypted. [Newtonsoft.Json.JsonProperty("ciphertext", Required = Newtonsoft.Json.Required.Always)] - public byte[] Ciphertext - { - get { return _ciphertext; } - set - { - if (_ciphertext != value) - { - _ciphertext = value; - RaisePropertyChanged(); - } - } - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] Ciphertext { get; set; } + /// An initialization vector used to decrypt the data. [Newtonsoft.Json.JsonProperty("initializationVector", Required = Newtonsoft.Json.Required.Always)] - public byte[] InitializationVector - { - get { return _initializationVector; } - set - { - if (_initializationVector != value) - { - _initializationVector = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static DecryptRequest FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] InitializationVector { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class DecryptResponse : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class DecryptResponse { - private byte[] _plaintext; - /// The decrypted form of the data encoded in base 64. [Newtonsoft.Json.JsonProperty("plaintext", Required = Newtonsoft.Json.Required.Always)] - public byte[] Plaintext - { - get { return _plaintext; } - set - { - if (_plaintext != value) - { - _plaintext = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static DecryptResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] Plaintext { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class ServerCertificateRequest : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class ServerCertificateRequest { - private string _commonName; - private System.DateTime _expiration; - /// Subject common name [Newtonsoft.Json.JsonProperty("commonName", Required = Newtonsoft.Json.Required.Always)] - public string CommonName - { - get { return _commonName; } - set - { - if (_commonName != value) - { - _commonName = value; - RaisePropertyChanged(); - } - } - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string CommonName { get; set; } + /// Certificate expiration date-time (ISO 8601) [Newtonsoft.Json.JsonProperty("expiration", Required = Newtonsoft.Json.Required.Always)] - public System.DateTime Expiration - { - get { return _expiration; } - set - { - if (_expiration != value) - { - _expiration = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static ServerCertificateRequest FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public System.DateTimeOffset Expiration { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class CertificateResponse : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class IdentityCertificateRequest + { + /// Certificate expiration date-time (ISO 8601) + [Newtonsoft.Json.JsonProperty("expiration", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.DateTimeOffset? Expiration { get; set; } + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class CertificateResponse { - private PrivateKey _privateKey = new PrivateKey(); - private string _certificate; - private System.DateTime _expiration; - [Newtonsoft.Json.JsonProperty("privateKey", Required = Newtonsoft.Json.Required.Always)] - public PrivateKey PrivateKey - { - get { return _privateKey; } - set - { - if (_privateKey != value) - { - _privateKey = value; - RaisePropertyChanged(); - } - } - } - + [System.ComponentModel.DataAnnotations.Required] + public PrivateKey PrivateKey { get; set; } = new PrivateKey(); + /// Base64 encoded PEM formatted byte array containing the certificate and its chain. [Newtonsoft.Json.JsonProperty("certificate", Required = Newtonsoft.Json.Required.Always)] - public string Certificate - { - get { return _certificate; } - set - { - if (_certificate != value) - { - _certificate = value; - RaisePropertyChanged(); - } - } - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Certificate { get; set; } + /// Certificate expiration date-time (ISO 8601) [Newtonsoft.Json.JsonProperty("expiration", Required = Newtonsoft.Json.Required.Always)] - public System.DateTime Expiration - { - get { return _expiration; } - set - { - if (_expiration != value) - { - _expiration = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static CertificateResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public System.DateTimeOffset Expiration { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class TrustBundleResponse : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class TrustBundleResponse { - private string _certificate; - /// Base64 encoded PEM formatted byte array containing the trusted certificates. [Newtonsoft.Json.JsonProperty("certificate", Required = Newtonsoft.Json.Required.Always)] - public string Certificate - { - get { return _certificate; } - set - { - if (_certificate != value) - { - _certificate = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static TrustBundleResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Certificate { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class PrivateKey : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class PrivateKey { - private PrivateKeyType _type; - private string _ref; - private string _bytes; - /// Indicates format of the key (present in PEM formatted bytes or a reference) [Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public PrivateKeyType Type - { - get { return _type; } - set - { - if (_type != value) - { - _type = value; - RaisePropertyChanged(); - } - } - } - + public PrivateKeyType Type { get; set; } + /// Reference to private key. [Newtonsoft.Json.JsonProperty("ref", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Ref - { - get { return _ref; } - set - { - if (_ref != value) - { - _ref = value; - RaisePropertyChanged(); - } - } - } - + public string Ref { get; set; } + /// Base64 encoded PEM formatted byte array [Newtonsoft.Json.JsonProperty("bytes", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Bytes - { - get { return _bytes; } - set - { - if (_bytes != value) - { - _bytes = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static PrivateKey FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + public string Bytes { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class ErrorResponse : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class ErrorResponse { - private string _message; - [Newtonsoft.Json.JsonProperty("message", Required = Newtonsoft.Json.Required.Always)] - public string Message - { - get { return _message; } - set - { - if (_message != value) - { - _message = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static ErrorResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Message { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] public enum SignRequestAlgo { - [System.Runtime.Serialization.EnumMember(Value = "HMACSHA256")] + [System.Runtime.Serialization.EnumMember(Value = @"HMACSHA256")] HMACSHA256 = 0, - + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] public enum PrivateKeyType { - [System.Runtime.Serialization.EnumMember(Value = "ref")] + [System.Runtime.Serialization.EnumMember(Value = @"ref")] Ref = 0, - - [System.Runtime.Serialization.EnumMember(Value = "key")] + + [System.Runtime.Serialization.EnumMember(Value = @"key")] Key = 1, - + } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.17.6.0 (NJsonSchema v9.10.46.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0))")] public partial class IoTEdgedException : System.Exception { public int StatusCode { get; private set; } public string Response { get; private set; } - public System.Collections.Generic.Dictionary> Headers { get; private set; } + public System.Collections.Generic.IReadOnlyDictionary> Headers { get; private set; } - public IoTEdgedException(string message, int statusCode, string response, System.Collections.Generic.Dictionary> headers, System.Exception innerException) - : base(message, innerException) + public IoTEdgedException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, System.Exception innerException) + : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + response.Substring(0, response.Length >= 512 ? 512 : response.Length), innerException) { StatusCode = statusCode; - Response = response; + Response = response; Headers = headers; } @@ -1414,12 +1073,12 @@ public override string ToString() } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.17.6.0 (NJsonSchema v9.10.46.0 (Newtonsoft.Json v9.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0))")] public partial class IoTEdgedException : IoTEdgedException { public TResult Result { get; private set; } - public IoTEdgedException(string message, int statusCode, string response, System.Collections.Generic.Dictionary> headers, TResult result, System.Exception innerException) + public IoTEdgedException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, TResult result, System.Exception innerException) : base(message, statusCode, response, headers, innerException) { Result = result; @@ -1427,3 +1086,9 @@ public IoTEdgedException(string message, int statusCode, string response, System } } + +#pragma warning restore 1591 +#pragma warning restore 1573 +#pragma warning restore 472 +#pragma warning restore 114 +#pragma warning restore 108 diff --git a/edge-util/test/Microsoft.Azure.Devices.Edge.Storage.RocksDb.Test/Microsoft.Azure.Devices.Edge.Storage.RocksDb.Test.csproj b/edge-util/test/Microsoft.Azure.Devices.Edge.Storage.RocksDb.Test/Microsoft.Azure.Devices.Edge.Storage.RocksDb.Test.csproj index 4a28f7bb137..92f0dc7530c 100644 --- a/edge-util/test/Microsoft.Azure.Devices.Edge.Storage.RocksDb.Test/Microsoft.Azure.Devices.Edge.Storage.RocksDb.Test.csproj +++ b/edge-util/test/Microsoft.Azure.Devices.Edge.Storage.RocksDb.Test/Microsoft.Azure.Devices.Edge.Storage.RocksDb.Test.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + false diff --git a/edge-util/test/Microsoft.Azure.Devices.Edge.Storage.Test/Microsoft.Azure.Devices.Edge.Storage.Test.csproj b/edge-util/test/Microsoft.Azure.Devices.Edge.Storage.Test/Microsoft.Azure.Devices.Edge.Storage.Test.csproj index acd74048fea..11e64f9f216 100644 --- a/edge-util/test/Microsoft.Azure.Devices.Edge.Storage.Test/Microsoft.Azure.Devices.Edge.Storage.Test.csproj +++ b/edge-util/test/Microsoft.Azure.Devices.Edge.Storage.Test/Microsoft.Azure.Devices.Edge.Storage.Test.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + false diff --git a/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test.Common/Microsoft.Azure.Devices.Edge.Util.Test.Common.csproj b/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test.Common/Microsoft.Azure.Devices.Edge.Util.Test.Common.csproj index 74fd4d26c30..e3929bfdd99 100644 --- a/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test.Common/Microsoft.Azure.Devices.Edge.Util.Test.Common.csproj +++ b/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test.Common/Microsoft.Azure.Devices.Edge.Util.Test.Common.csproj @@ -1,7 +1,8 @@  + + - netstandard2.0 True Debug;Release;CheckInBuild true @@ -10,9 +11,9 @@ - - - + + + diff --git a/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/Microsoft.Azure.Devices.Edge.Util.Test.csproj b/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/Microsoft.Azure.Devices.Edge.Util.Test.csproj index 17bcbb9b9aa..310d836a7d1 100644 --- a/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/Microsoft.Azure.Devices.Edge.Util.Test.csproj +++ b/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/Microsoft.Azure.Devices.Edge.Util.Test.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + True @@ -15,7 +9,8 @@ - + + @@ -25,12 +20,8 @@ - - - - - - + + diff --git a/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/workloadtestserver/Controllers/Controller.cs b/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/workloadtestserver/Controllers/Controller.cs index bc8f95c49bb..f198aa49844 100644 --- a/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/workloadtestserver/Controllers/Controller.cs +++ b/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/workloadtestserver/Controllers/Controller.cs @@ -1,758 +1,458 @@ -// Copyright (c) Microsoft. All rights reserved. +//---------------------- +// +// Generated using the NSwag toolchain v13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0)) (http://NSwag.org) +// +//---------------------- + +#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended." +#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword." +#pragma warning disable 472 // Disable "CS0472 The result of the expression is always 'false' since a value of type 'Int32' is never equal to 'null' of type 'Int32?' +#pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ... +#pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..." + namespace Microsoft.Azure.Devices.Edge.Util.Test.Common.WorkloadTestServer.Controllers { -#pragma warning disable // Disable all warnings - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.16.1.0 (NJsonSchema v9.10.41.0 (Newtonsoft.Json v9.0.0.0))")] + using System = global::System; + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0))")] public interface IController { + /// List modules. + /// The version of the API. + /// Ok + System.Threading.Tasks.Task ListModulesAsync(string api_version); + /// The version of the API. /// The name of the module on whose behalf the payload will be signed. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// The data to be signed. /// Ok System.Threading.Tasks.Task SignAsync(string api_version, string name, string genid, SignRequest payload); - + /// The version of the API. /// The name of the module on whose behalf the plaintext will be encrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// The data to be encrypted. /// OK System.Threading.Tasks.Task EncryptAsync(string api_version, string name, string genid, EncryptRequest payload); - + /// The version of the API. /// The name of the module on whose behalf the ciphertext will be decrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// The data to be decrypted. /// OK System.Threading.Tasks.Task DecryptAsync(string api_version, string name, string genid, DecryptRequest payload); - + /// The version of the API. - /// The name of the module to get certificate. (urlencoded) - /// The generation identifier for the module as generated by IoT Hub. + /// The name of the module needed to obtain the certificate. (urlencoded) + /// Parameters for certificate creation. /// Ok - System.Threading.Tasks.Task CreateIdentityCertificateAsync(string api_version, string name, string genid); - + System.Threading.Tasks.Task CreateIdentityCertificateAsync(string api_version, string name, IdentityCertificateRequest request); + /// The version of the API. /// The name of the module to get certificate. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// Parameters for certificate creation. /// Ok System.Threading.Tasks.Task CreateServerCertificateAsync(string api_version, string name, string genid, ServerCertificateRequest request); - + /// The version of the API. /// Ok System.Threading.Tasks.Task TrustBundleAsync(string api_version); - + } - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.16.1.0 (NJsonSchema v9.10.41.0 (Newtonsoft.Json v9.0.0.0))")] + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0))")] public partial class Controller : Microsoft.AspNetCore.Mvc.Controller { private IController _implementation; - + public Controller(IController implementation) { _implementation = implementation; } - + + /// List modules. + /// The version of the API. + /// Ok + [Microsoft.AspNetCore.Mvc.HttpGet, Microsoft.AspNetCore.Mvc.Route("modules")] + public System.Threading.Tasks.Task ListModules([Microsoft.AspNetCore.Mvc.FromQuery(Name = "api-version")] string api_version) + { + return _implementation.ListModulesAsync(api_version); + } + /// The version of the API. /// The name of the module on whose behalf the payload will be signed. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// The data to be signed. /// Ok [Microsoft.AspNetCore.Mvc.HttpPost, Microsoft.AspNetCore.Mvc.Route("modules/{name}/genid/{genid}/sign")] - public System.Threading.Tasks.Task Sign(string api_version, string name, string genid, [Microsoft.AspNetCore.Mvc.FromBody] SignRequest payload) + public System.Threading.Tasks.Task Sign([Microsoft.AspNetCore.Mvc.FromQuery(Name = "api-version")] string api_version, string name, string genid, [Microsoft.AspNetCore.Mvc.FromBody] SignRequest payload) { return _implementation.SignAsync(api_version, name, genid, payload); } - + /// The version of the API. /// The name of the module on whose behalf the plaintext will be encrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// The data to be encrypted. /// OK [Microsoft.AspNetCore.Mvc.HttpPost, Microsoft.AspNetCore.Mvc.Route("modules/{name}/genid/{genid}/encrypt")] - public System.Threading.Tasks.Task Encrypt(string api_version, string name, string genid, [Microsoft.AspNetCore.Mvc.FromBody] EncryptRequest payload) + public System.Threading.Tasks.Task Encrypt([Microsoft.AspNetCore.Mvc.FromQuery(Name = "api-version")] string api_version, string name, string genid, [Microsoft.AspNetCore.Mvc.FromBody] EncryptRequest payload) { return _implementation.EncryptAsync(api_version, name, genid, payload); } - + /// The version of the API. /// The name of the module on whose behalf the ciphertext will be decrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// The data to be decrypted. /// OK [Microsoft.AspNetCore.Mvc.HttpPost, Microsoft.AspNetCore.Mvc.Route("modules/{name}/genid/{genid}/decrypt")] - public System.Threading.Tasks.Task Decrypt(string api_version, string name, string genid, [Microsoft.AspNetCore.Mvc.FromBody] DecryptRequest payload) + public System.Threading.Tasks.Task Decrypt([Microsoft.AspNetCore.Mvc.FromQuery(Name = "api-version")] string api_version, string name, string genid, [Microsoft.AspNetCore.Mvc.FromBody] DecryptRequest payload) { return _implementation.DecryptAsync(api_version, name, genid, payload); } - + /// The version of the API. - /// The name of the module to get certificate. (urlencoded) - /// The generation identifier for the module as generated by IoT Hub. + /// The name of the module needed to obtain the certificate. (urlencoded) + /// Parameters for certificate creation. /// Ok - [Microsoft.AspNetCore.Mvc.HttpPost, Microsoft.AspNetCore.Mvc.Route("modules/{name}/genid/{genid}/certificate/identity")] - public System.Threading.Tasks.Task CreateIdentityCertificate(string api_version, string name, string genid) + [Microsoft.AspNetCore.Mvc.HttpPost, Microsoft.AspNetCore.Mvc.Route("modules/{name}/certificate/identity")] + public System.Threading.Tasks.Task CreateIdentityCertificate([Microsoft.AspNetCore.Mvc.FromQuery(Name = "api-version")] string api_version, string name, [Microsoft.AspNetCore.Mvc.FromBody] IdentityCertificateRequest request) { - return _implementation.CreateIdentityCertificateAsync(api_version, name, genid); + return _implementation.CreateIdentityCertificateAsync(api_version, name, request); } - + /// The version of the API. /// The name of the module to get certificate. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// Parameters for certificate creation. /// Ok [Microsoft.AspNetCore.Mvc.HttpPost, Microsoft.AspNetCore.Mvc.Route("modules/{name}/genid/{genid}/certificate/server")] - public async System.Threading.Tasks.Task CreateServerCertificate(string api_version, string name, string genid, [Microsoft.AspNetCore.Mvc.FromBody] ServerCertificateRequest request) + public System.Threading.Tasks.Task CreateServerCertificate([Microsoft.AspNetCore.Mvc.FromQuery(Name = "api-version")] string api_version, string name, string genid, [Microsoft.AspNetCore.Mvc.FromBody] ServerCertificateRequest request) { - var response = await _implementation.CreateServerCertificateAsync(api_version, name, genid, request); - return StatusCode(201, response); + System.Threading.Tasks.Task certificateResponse = _implementation.CreateServerCertificateAsync(api_version, name, genid, request); + this.HttpContext.Response.StatusCode = 201; + return certificateResponse; } - + /// The version of the API. /// Ok [Microsoft.AspNetCore.Mvc.HttpGet, Microsoft.AspNetCore.Mvc.Route("trust-bundle")] - public System.Threading.Tasks.Task TrustBundle(string api_version) + public System.Threading.Tasks.Task TrustBundle([Microsoft.AspNetCore.Mvc.FromQuery(Name = "api-version")] string api_version) { return _implementation.TrustBundleAsync(api_version); } - + } - - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.41.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class SignRequest : System.ComponentModel.INotifyPropertyChanged + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class ModuleList + { + [Newtonsoft.Json.JsonProperty("modules", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required] + public System.Collections.Generic.List Modules { get; set; } = new System.Collections.Generic.List(); + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class ModuleDetails + { + /// System generated unique identitier. + [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Id { get; set; } + + /// The name of the module. + [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Name { get; set; } + + /// The type of a module. + [Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Type { get; set; } + + [Newtonsoft.Json.JsonProperty("config", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required] + public Config Config { get; set; } = new Config(); + + [Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required] + public Status Status { get; set; } = new Status(); + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class Config + { + [Newtonsoft.Json.JsonProperty("settings", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required] + public object Settings { get; set; } = new object(); + + [Newtonsoft.Json.JsonProperty("env", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.List Env { get; set; } + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class Status + { + [Newtonsoft.Json.JsonProperty("startTime", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.DateTimeOffset? StartTime { get; set; } + + [Newtonsoft.Json.JsonProperty("exitStatus", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public ExitStatus ExitStatus { get; set; } + + [Newtonsoft.Json.JsonProperty("runtimeStatus", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required] + public RuntimeStatus RuntimeStatus { get; set; } = new RuntimeStatus(); + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class EnvVar + { + [Newtonsoft.Json.JsonProperty("key", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Key { get; set; } + + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Value { get; set; } + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class ExitStatus + { + [Newtonsoft.Json.JsonProperty("exitTime", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public System.DateTimeOffset ExitTime { get; set; } + + [Newtonsoft.Json.JsonProperty("statusCode", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string StatusCode { get; set; } + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class RuntimeStatus + { + [Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Status { get; set; } + + [Newtonsoft.Json.JsonProperty("description", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Description { get; set; } + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class SignRequest { - private string _keyId; - private SignRequestAlgo _algo; - private byte[] _data; - /// Name of key to perform sign operation. [Newtonsoft.Json.JsonProperty("keyId", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string KeyId - { - get { return _keyId; } - set - { - if (_keyId != value) - { - _keyId = value; - RaisePropertyChanged(); - } - } - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string KeyId { get; set; } + /// Sign algorithm to be used. [Newtonsoft.Json.JsonProperty("algo", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public SignRequestAlgo Algo - { - get { return _algo; } - set - { - if (_algo != value) - { - _algo = value; - RaisePropertyChanged(); - } - } - } - + public SignRequestAlgo Algo { get; set; } + /// Data to be signed. [Newtonsoft.Json.JsonProperty("data", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public byte[] Data - { - get { return _data; } - set - { - if (_data != value) - { - _data = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static SignRequest FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] Data { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.41.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class SignResponse : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class SignResponse { - private byte[] _digest; - /// Signature of the data. [Newtonsoft.Json.JsonProperty("digest", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public byte[] Digest - { - get { return _digest; } - set - { - if (_digest != value) - { - _digest = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static SignResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] Digest { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.41.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class EncryptRequest : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class EncryptRequest { - private byte[] _plaintext; - private byte[] _initializationVector; - /// The data to be encrypted. [Newtonsoft.Json.JsonProperty("plaintext", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public byte[] Plaintext - { - get { return _plaintext; } - set - { - if (_plaintext != value) - { - _plaintext = value; - RaisePropertyChanged(); - } - } - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] Plaintext { get; set; } + /// An initialization vector used to encrypt the data. [Newtonsoft.Json.JsonProperty("initializationVector", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public byte[] InitializationVector - { - get { return _initializationVector; } - set - { - if (_initializationVector != value) - { - _initializationVector = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static EncryptRequest FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] InitializationVector { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.41.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class EncryptResponse : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class EncryptResponse { - private byte[] _ciphertext; - /// The encrypted form of the data encoded in base 64. [Newtonsoft.Json.JsonProperty("ciphertext", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public byte[] Ciphertext - { - get { return _ciphertext; } - set - { - if (_ciphertext != value) - { - _ciphertext = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static EncryptResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] Ciphertext { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.41.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class DecryptRequest : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class DecryptRequest { - private byte[] _ciphertext; - private byte[] _initializationVector; - /// The data to be decrypted. [Newtonsoft.Json.JsonProperty("ciphertext", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public byte[] Ciphertext - { - get { return _ciphertext; } - set - { - if (_ciphertext != value) - { - _ciphertext = value; - RaisePropertyChanged(); - } - } - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] Ciphertext { get; set; } + /// An initialization vector used to decrypt the data. [Newtonsoft.Json.JsonProperty("initializationVector", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public byte[] InitializationVector - { - get { return _initializationVector; } - set - { - if (_initializationVector != value) - { - _initializationVector = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static DecryptRequest FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] InitializationVector { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.41.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class DecryptResponse : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class DecryptResponse { - private byte[] _plaintext; - /// The decrypted form of the data encoded in base 64. [Newtonsoft.Json.JsonProperty("plaintext", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public byte[] Plaintext - { - get { return _plaintext; } - set - { - if (_plaintext != value) - { - _plaintext = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static DecryptResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public byte[] Plaintext { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.41.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class ServerCertificateRequest : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class ServerCertificateRequest { - private string _commonName; - private System.DateTime _expiration; - /// Subject common name [Newtonsoft.Json.JsonProperty("commonName", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string CommonName - { - get { return _commonName; } - set - { - if (_commonName != value) - { - _commonName = value; - RaisePropertyChanged(); - } - } - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string CommonName { get; set; } + /// Certificate expiration date-time (ISO 8601) [Newtonsoft.Json.JsonProperty("expiration", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.DateTime Expiration - { - get { return _expiration; } - set - { - if (_expiration != value) - { - _expiration = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static ServerCertificateRequest FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public System.DateTimeOffset Expiration { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.41.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class CertificateResponse : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class IdentityCertificateRequest + { + /// Certificate expiration date-time (ISO 8601) + [Newtonsoft.Json.JsonProperty("expiration", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.DateTimeOffset? Expiration { get; set; } + + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class CertificateResponse { - private PrivateKey _privateKey = new PrivateKey(); - private string _certificate; - private System.DateTime _expiration; - [Newtonsoft.Json.JsonProperty("privateKey", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] - public PrivateKey PrivateKey - { - get { return _privateKey; } - set - { - if (_privateKey != value) - { - _privateKey = value; - RaisePropertyChanged(); - } - } - } - + public PrivateKey PrivateKey { get; set; } = new PrivateKey(); + /// Base64 encoded PEM formatted byte array containing the certificate and its chain. [Newtonsoft.Json.JsonProperty("certificate", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Certificate - { - get { return _certificate; } - set - { - if (_certificate != value) - { - _certificate = value; - RaisePropertyChanged(); - } - } - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Certificate { get; set; } + /// Certificate expiration date-time (ISO 8601) [Newtonsoft.Json.JsonProperty("expiration", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.DateTime Expiration - { - get { return _expiration; } - set - { - if (_expiration != value) - { - _expiration = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static CertificateResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public System.DateTimeOffset Expiration { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.41.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class TrustBundleResponse : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class TrustBundleResponse { - private string _certificate; - /// Base64 encoded PEM formatted byte array containing the trusted certificates. [Newtonsoft.Json.JsonProperty("certificate", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Certificate - { - get { return _certificate; } - set - { - if (_certificate != value) - { - _certificate = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static TrustBundleResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Certificate { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.41.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class PrivateKey : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class PrivateKey { - private PrivateKeyType _type; - private string _ref; - private string _bytes; - /// Indicates format of the key (present in PEM formatted bytes or a reference) [Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public PrivateKeyType Type - { - get { return _type; } - set - { - if (_type != value) - { - _type = value; - RaisePropertyChanged(); - } - } - } - + public PrivateKeyType Type { get; set; } + /// Reference to private key. [Newtonsoft.Json.JsonProperty("ref", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Ref - { - get { return _ref; } - set - { - if (_ref != value) - { - _ref = value; - RaisePropertyChanged(); - } - } - } - + public string Ref { get; set; } + /// Base64 encoded PEM formatted byte array [Newtonsoft.Json.JsonProperty("bytes", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Bytes - { - get { return _bytes; } - set - { - if (_bytes != value) - { - _bytes = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static PrivateKey FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + public string Bytes { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.41.0 (Newtonsoft.Json v9.0.0.0)")] - public partial class ErrorResponse : System.ComponentModel.INotifyPropertyChanged + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + public partial class ErrorResponse { - private string _message; - [Newtonsoft.Json.JsonProperty("message", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string Message - { - get { return _message; } - set - { - if (_message != value) - { - _message = value; - RaisePropertyChanged(); - } - } - } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static ErrorResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) - { - var handler = PropertyChanged; - if (handler != null) - handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Message { get; set; } + + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.41.0 (Newtonsoft.Json v9.0.0.0)")] + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] public enum SignRequestAlgo { - [System.Runtime.Serialization.EnumMember(Value = "HMACSHA256")] + [System.Runtime.Serialization.EnumMember(Value = @"HMACSHA256")] HMACSHA256 = 0, - + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.41.0 (Newtonsoft.Json v9.0.0.0)")] + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] public enum PrivateKeyType { - [System.Runtime.Serialization.EnumMember(Value = "ref")] + [System.Runtime.Serialization.EnumMember(Value = @"ref")] Ref = 0, - - [System.Runtime.Serialization.EnumMember(Value = "key")] + + [System.Runtime.Serialization.EnumMember(Value = @"key")] Key = 1, - + } } + +#pragma warning restore 1591 +#pragma warning restore 1573 +#pragma warning restore 472 +#pragma warning restore 114 +#pragma warning restore 108 \ No newline at end of file diff --git a/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/workloadtestserver/Startup.cs b/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/workloadtestserver/Startup.cs index 335f22310c9..c1f52617332 100644 --- a/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/workloadtestserver/Startup.cs +++ b/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/workloadtestserver/Startup.cs @@ -6,6 +6,7 @@ namespace Microsoft.Azure.Devices.Edge.Util.Test.Common.WorkloadTestServer using Microsoft.Azure.Devices.Edge.Util.Test.Common.WorkloadTestServer.Controllers; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.Hosting; public class Startup { @@ -19,22 +20,23 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc(); + services.AddControllers().AddNewtonsoftJson(); services.AddSingleton(); } - // TODO: Remove warning disable for Obsolete when project is moved to dotnetcore 3.0 -#pragma warning disable 612, 618 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - app.UseMvc(); + app.UseRouting(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); } -#pragma warning restore 612, 618 } } diff --git a/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/workloadtestserver/WorkloadFixture.cs b/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/workloadtestserver/WorkloadFixture.cs index 761dd5a7272..ff1e7817f8b 100644 --- a/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/workloadtestserver/WorkloadFixture.cs +++ b/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/workloadtestserver/WorkloadFixture.cs @@ -4,8 +4,8 @@ namespace Microsoft.Azure.Devices.Edge.Util.Test.Common.WorkloadTestServer using System; using System.Threading; using System.Threading.Tasks; - using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; + using Microsoft.Extensions.Hosting; public class WorkloadFixture : IDisposable { @@ -28,7 +28,7 @@ class ServiceHost ServiceHost() { - this.webHostTask = BuildWebHost(new string[0], DefaultPort).RunAsync(this.cancellationTokenSource.Token); + this.webHostTask = CreateHostBuilder(new string[0], DefaultPort).Build().RunAsync(this.cancellationTokenSource.Token); this.Url = $"http://localhost:{DefaultPort}"; } @@ -36,11 +36,14 @@ class ServiceHost public string Url { get; } - static IWebHost BuildWebHost(string[] args, int port) => - WebHost.CreateDefaultBuilder(args) - .UseUrls($"http://*:{port}") - .UseStartup() - .Build(); + static IHostBuilder CreateHostBuilder(string[] args, int port) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder + .UseUrls($"http://*:{port}") + .UseStartup(); + }); } } } diff --git a/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/workloadtestserver/WorkloadTestImplementation.cs b/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/workloadtestserver/WorkloadTestImplementation.cs index 6c9aac56cc9..4ca5fc15649 100644 --- a/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/workloadtestserver/WorkloadTestImplementation.cs +++ b/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/workloadtestserver/WorkloadTestImplementation.cs @@ -9,6 +9,8 @@ namespace Microsoft.Azure.Devices.Edge.Util.Test.Common.WorkloadTestServer class WorkloadTestImplementation : IController { + public Task ListModulesAsync(string api_version) => throw new NotImplementedException(); + public Task SignAsync(string api_version, string name, string genid, SignRequest payload) { using (var algorithm = new HMACSHA256(Encoding.UTF8.GetBytes("key"))) @@ -34,7 +36,7 @@ public Task DecryptAsync(string api_version, string name, strin return Task.FromResult(new DecryptResponse() { Plaintext = Encoding.UTF8.GetBytes(dencrypted) }); } - public Task CreateIdentityCertificateAsync(string api_version, string name, string genid) => throw new NotImplementedException(); + public Task CreateIdentityCertificateAsync(string api_version, string name, IdentityCertificateRequest identityCertificateRequest) => throw new NotImplementedException(); public Task CreateServerCertificateAsync(string api_version, string name, string genid, ServerCertificateRequest request) { diff --git a/samples/dotnet/EdgeDownstreamDevice/EdgeDownstreamDevice.csproj b/samples/dotnet/EdgeDownstreamDevice/EdgeDownstreamDevice.csproj index c55d7a811a3..c213cc12fbf 100644 --- a/samples/dotnet/EdgeDownstreamDevice/EdgeDownstreamDevice.csproj +++ b/samples/dotnet/EdgeDownstreamDevice/EdgeDownstreamDevice.csproj @@ -1,12 +1,6 @@ - - netcoreapp2.1 - - - - netcoreapp3.0 - + Exe diff --git a/samples/dotnet/EdgeX509AuthDownstreamDevice/EdgeX509AuthDownstreamDevice.csproj b/samples/dotnet/EdgeX509AuthDownstreamDevice/EdgeX509AuthDownstreamDevice.csproj index 5102b98e457..d73d1a4e65a 100644 --- a/samples/dotnet/EdgeX509AuthDownstreamDevice/EdgeX509AuthDownstreamDevice.csproj +++ b/samples/dotnet/EdgeX509AuthDownstreamDevice/EdgeX509AuthDownstreamDevice.csproj @@ -1,9 +1,11 @@ + + Exe - netcoreapp2.1 EdgeDownstreamDevice + Debug;Release;CheckInBuild diff --git a/samples/dotnet/Microsoft.Azure.Devices.Edge.Samples.sln b/samples/dotnet/Microsoft.Azure.Devices.Edge.Samples.sln deleted file mode 100644 index e0e8a72af57..00000000000 --- a/samples/dotnet/Microsoft.Azure.Devices.Edge.Samples.sln +++ /dev/null @@ -1,36 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.168 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EdgeDownstreamDevice", "EdgeDownstreamDevice\EdgeDownstreamDevice.csproj", "{5DF80137-0A95-4B09-89F8-2105310D3D8B}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EdgeX509AuthDownstreamDevice", "EdgeX509AuthDownstreamDevice\EdgeX509AuthDownstreamDevice.csproj", "{97E1F9D5-557A-40BB-A0A5-60E24F8A6CED}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - CheckInBuild|Any CPU = CheckInBuild|Any CPU - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5DF80137-0A95-4B09-89F8-2105310D3D8B}.CheckInBuild|Any CPU.ActiveCfg = CheckInBuild|Any CPU - {5DF80137-0A95-4B09-89F8-2105310D3D8B}.CheckInBuild|Any CPU.Build.0 = CheckInBuild|Any CPU - {5DF80137-0A95-4B09-89F8-2105310D3D8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5DF80137-0A95-4B09-89F8-2105310D3D8B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5DF80137-0A95-4B09-89F8-2105310D3D8B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5DF80137-0A95-4B09-89F8-2105310D3D8B}.Release|Any CPU.Build.0 = Release|Any CPU - {97E1F9D5-557A-40BB-A0A5-60E24F8A6CED}.CheckInBuild|Any CPU.ActiveCfg = Debug|Any CPU - {97E1F9D5-557A-40BB-A0A5-60E24F8A6CED}.CheckInBuild|Any CPU.Build.0 = Debug|Any CPU - {97E1F9D5-557A-40BB-A0A5-60E24F8A6CED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {97E1F9D5-557A-40BB-A0A5-60E24F8A6CED}.Debug|Any CPU.Build.0 = Debug|Any CPU - {97E1F9D5-557A-40BB-A0A5-60E24F8A6CED}.Release|Any CPU.ActiveCfg = Release|Any CPU - {97E1F9D5-557A-40BB-A0A5-60E24F8A6CED}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {D76838A6-A1D2-4F9E-B7A9-6725D97DBB6D} - EndGlobalSection -EndGlobal diff --git a/samples/dotnet/Microsoft.Azure.Devices.Edge.Samples.sln.DotSettings b/samples/dotnet/Microsoft.Azure.Devices.Edge.Samples.sln.DotSettings deleted file mode 100644 index c55047d4645..00000000000 --- a/samples/dotnet/Microsoft.Azure.Devices.Edge.Samples.sln.DotSettings +++ /dev/null @@ -1,6 +0,0 @@ - - C:\git\iotedge\Azure.IoT.Edge.DotSettings - ..\..\..\Azure.IoT.Edge.DotSettings - True - True - 1 \ No newline at end of file diff --git a/scripts/linux/buildBranch.sh b/scripts/linux/buildBranch.sh index 81602713623..855bfa06ca1 100755 --- a/scripts/linux/buildBranch.sh +++ b/scripts/linux/buildBranch.sh @@ -26,7 +26,7 @@ FUNCTIONS_SAMPLE_DIR=$ROOT_FOLDER/edge-modules/functions/samples VERSIONINFO_FILE_PATH=$BUILD_REPOSITORY_LOCALPATH/versionInfo.json CONNECTIVITY_TEST_SCRIPT_DIR=$ROOT_FOLDER/test/connectivity/scripts DOTNETBUILD_OS= -DOTNET_RUNTIME=netcoreapp2.1 +DOTNET_RUNTIME=netcoreapp3.1 usage() { @@ -161,7 +161,7 @@ publish_app() publish_lib() { local name="$1" - publish_project library "$name" netstandard2.0 $CONFIGURATION "$PUBLISH_FOLDER/$name" + publish_project library "$name" netcoreapp3.1 $CONFIGURATION "$PUBLISH_FOLDER/$name" } publish_quickstart() @@ -225,11 +225,6 @@ build_solution() RES=1 fi - echo "Building IoT Edge Samples solution" - $DOTNET_ROOT_PATH/dotnet build \ - -c $CONFIGURATION \ - -o "$BUILD_BINARIESDIRECTORY" \ - "$ROOT_FOLDER/samples/dotnet/Microsoft.Azure.Devices.Edge.Samples.sln" if [ $? -gt 0 ]; then RES=1 fi diff --git a/scripts/linux/buildManifest.sh b/scripts/linux/buildManifest.sh index b59e7110c9a..56aed09bd7c 100755 --- a/scripts/linux/buildManifest.sh +++ b/scripts/linux/buildManifest.sh @@ -96,6 +96,7 @@ process_args() "--tags" ) save_next_arg=6;; "-n" | "--namespace" ) save_next_arg=7;; "-i" | "--image-name" ) save_next_arg=8;; + "-w" | "--win-arm32-enabled" ) WIN_ARM32_ENABLED=1;; "--ignore-missing" ) IGNORE_MISSING="--ignore-missing";; * ) usage;; esac @@ -156,9 +157,13 @@ cat $manifest echo "Done Building And Pushing Docker Images" -curl -Lo /tmp/manifest-tool 'https://edgebuild.blob.core.windows.net/iotedge-win-arm32v7-tools/manifest-tool-linux-amd64' && - chmod +x /tmp/manifest-tool && - /tmp/manifest-tool --debug push from-spec $IGNORE_MISSING $manifest + +if [ $WIN_ARM32_ENABLED -eq 1 ]; then + curl -Lo /tmp/manifest-tool 'https://edgebuild.blob.core.windows.net/iotedge-win-arm32v7-tools/manifest-tool-linux-amd64' && + chmod +x /tmp/manifest-tool && + /tmp/manifest-tool --debug push from-spec $IGNORE_MISSING $manifest +fi + [ $? -eq 0 ] || exit $? # Remove the temp file diff --git a/scripts/linux/installPrereqs.sh b/scripts/linux/installPrereqs.sh index 82f184cc1d8..8558a762b99 100755 --- a/scripts/linux/installPrereqs.sh +++ b/scripts/linux/installPrereqs.sh @@ -1,53 +1,6 @@ #!/bin/bash -# Installs the pre-reqs (currently only .Net Core) on the Windwos machine. - -if [ -z "${AGENT_WORKFOLDER}" ]; then - echo Error: Environment variable AGENT_WORKFOLDER is not defined. - exit 1 -fi - -DOTNET_SDK_PACKAGE_NAME='dotnet.tar.gz' -DOTNET_ROOT_PATH=$AGENT_WORKFOLDER/dotnet - -if [ ! -d "${AGENT_WORKFOLDER}" ]; then - echo Path $AGENT_WORKFOLDER does not exist” 1>&2 - exit 1 -fi - -usage() -{ - echo "Missing arguments. Usage: $0 -u " 1>&2 - exit 1 -} - -while getopts ":u:" o; do - case "${o}" in - u) - DOTNET_SDK_PACKAGE=${OPTARG} - ;; - esac -done -shift $((OPTIND-1)) - -if [ -z "${DOTNET_SDK_PACKAGE}" ]; then - usage -fi - -rm -rf $DOTNET_ROOT_PATH -mkdir $DOTNET_ROOT_PATH - -echo Downloading package $DOTNET_SDK_PACKAGE -if wget -q $DOTNET_SDK_PACKAGE -O /tmp/$DOTNET_SDK_PACKAGE_NAME ; then - echo Downloaded .Net Core package -else - echo Error downloading .Net Core package - exit 1 -fi - -echo Unzip and binplace dotnet -tar -xzf /tmp/$DOTNET_SDK_PACKAGE_NAME -C $DOTNET_ROOT_PATH -chmod +x $DOTNET_ROOT_PATH/dotnet +# Installs the pre-reqs (currently only libsnappy) on the machine. echo Install Libsnappy sudo apt-get update diff --git a/scripts/linux/runTests.sh b/scripts/linux/runTests.sh index 66f421eab29..a4798c12fa9 100755 --- a/scripts/linux/runTests.sh +++ b/scripts/linux/runTests.sh @@ -20,6 +20,10 @@ BUILD_CONFIG="$2" SUFFIX='Microsoft.Azure*test.dll' OUTPUT_FOLDER=$BUILD_BINARIESDIRECTORY +echo 'dotnet version:' +dotnet --version +/opt/hostedtoolcache/dotnet/dotnet --version + if [ ! -f "$DOTNET_ROOT_PATH" ]; then dotnet_path=$(command -v dotnet) if [ $? -eq 0 ]; then diff --git a/scripts/windows/build/Publish-Branch.ps1 b/scripts/windows/build/Publish-Branch.ps1 index c0d3096396f..bd59b02caee 100644 --- a/scripts/windows/build/Publish-Branch.ps1 +++ b/scripts/windows/build/Publish-Branch.ps1 @@ -23,6 +23,8 @@ param ( [ValidateNotNull()] [String] $BuildSourceVersion = $Env:BUILD_SOURCEVERSION, + [Switch] $PublishWinArm32, + [Switch] $UpdateVersion ) @@ -125,14 +127,6 @@ if ($LASTEXITCODE -ne 0) { throw "Failed building IoT Edge solution." } -$IoTEdgeSamplesSolutionPath = Join-Path $BuildRepositoryLocalPath "samples\dotnet\Microsoft.Azure.Devices.Edge.Samples.sln" -Write-Host "`nBuilding IoT Edge Samples solution [$IoTEdgeSamplesSolutionPath]`n" -&$DOTNET_PATH build -c $Configuration -o $BuildBinariesDirectory $IoTEdgeSamplesSolutionPath | - Write-Host -if ($LASTEXITCODE -ne 0) { - throw "Failed building IoT Edge Samples solution." -} - <# # Publish applications #> @@ -173,7 +167,7 @@ foreach ($appProjectFileName in $appProjectList) { Write-Host "Publishing App Project - $appProjectFilePath" $ProjectPublishPath = Join-Path $PUBLISH_FOLDER ($appProjectFileName -replace @(".csproj", "")) - &$DOTNET_PATH publish -f netcoreapp2.1 -c $Configuration -o $ProjectPublishPath $appProjectFilePath | + &$DOTNET_PATH publish -f netcoreapp3.1 -c $Configuration -o $ProjectPublishPath $appProjectFilePath | Write-Host if ($LASTEXITCODE -ne 0) { throw "Failed app publishing $appProjectFilePath." @@ -208,7 +202,7 @@ foreach ($libProjectFileName in $libProjectList) { Write-Host "Publishing Lib Project - $libProjectFilePath" $ProjectPublishPath = Join-Path $PUBLISH_FOLDER ($libProjectFileName -replace @(".csproj", "")) - &$DOTNET_PATH publish -f netstandard2.0 -c $Configuration -o $ProjectPublishPath $libProjectFilePath | + &$DOTNET_PATH publish -f netcoreapp3.1 -c $Configuration -o $ProjectPublishPath $libProjectFilePath | Write-Host if ($LASTEXITCODE -ne 0) { throw "Failed lib publishing $libProjectFilePath." @@ -239,7 +233,7 @@ $IotEdgeQuickstartPublishBaseFolder = Join-Path $PUBLISH_FOLDER "IotEdgeQuicksta Write-Host "Publishing - IotEdgeQuickstart x64" $ProjectPublishPath = Join-Path $IotEdgeQuickstartPublishBaseFolder "x64" -&$DOTNET_PATH publish -f netcoreapp2.1 -r "win10-x64" -c $Configuration -o $ProjectPublishPath $IotEdgeQuickstartProjectFolder | +&$DOTNET_PATH publish -f netcoreapp3.1 -r "win10-x64" -c $Configuration -o $ProjectPublishPath $IotEdgeQuickstartProjectFolder | Write-Host if ($LASTEXITCODE -ne 0) { throw "Failed publishing IotEdgeQuickstart x64." @@ -247,7 +241,7 @@ if ($LASTEXITCODE -ne 0) { Write-Host "Publishing - IotEdgeQuickstart arm32" $ProjectPublishPath = Join-Path $IotEdgeQuickstartPublishBaseFolder "arm32v7" -&$DOTNET_PATH publish -f netcoreapp2.1 -r "win10-arm" -c $Configuration -o $ProjectPublishPath $IotEdgeQuickstartProjectFolder | +&$DOTNET_PATH publish -f netcoreapp3.1 -r "win10-arm" -c $Configuration -o $ProjectPublishPath $IotEdgeQuickstartProjectFolder | Write-Host if ($LASTEXITCODE -ne 0) { throw "Failed publishing IotEdgeQuickstart arm32." @@ -261,16 +255,19 @@ $LeafDevicePublishBaseFolder = Join-Path $PUBLISH_FOLDER "LeafDevice" Write-Host "Publishing - LeafDevice x64" $ProjectPublishPath = Join-Path $LeafDevicePublishBaseFolder "x64" -&$DOTNET_PATH publish -f netcoreapp2.1 -r "win10-x64" -c $Configuration -o $ProjectPublishPath $LeafDeviceProjectFolder | +&$DOTNET_PATH publish -f netcoreapp3.1 -r "win10-x64" -c $Configuration -o $ProjectPublishPath $LeafDeviceProjectFolder | Write-Host if ($LASTEXITCODE -ne 0) { throw "Failed publishing LeafDevice x64." } -Write-Host "Publishing - LeafDevice arm32" -$ProjectPublishPath = Join-Path $LeafDevicePublishBaseFolder "arm32v7" -&$DOTNET_PATH publish -f netcoreapp2.1 -r "win10-arm" -c $Configuration -o $ProjectPublishPath $LeafDeviceProjectFolder | - Write-Host -if ($LASTEXITCODE -ne 0) { - throw "Failed publishing LeafDevice arm32." +if ($PublishWinArm32 -eq 1) +{ + Write-Host "Publishing - LeafDevice arm32" + $ProjectPublishPath = Join-Path $LeafDevicePublishBaseFolder "arm32v7" + &$DOTNET_PATH publish -f netcoreapp3.1 -r "win10-arm" -c $Configuration -o $ProjectPublishPath $LeafDeviceProjectFolder | + Write-Host + if ($LASTEXITCODE -ne 0) { + throw "Failed publishing LeafDevice arm32." + } } diff --git a/scripts/windows/setup/Install-Prerequisites.ps1 b/scripts/windows/setup/Install-Prerequisites.ps1 index ccef1849a40..84852b42d45 100644 --- a/scripts/windows/setup/Install-Prerequisites.ps1 +++ b/scripts/windows/setup/Install-Prerequisites.ps1 @@ -3,10 +3,6 @@ #> param ( - [ValidateNotNullOrEmpty()] - [ValidateScript( {Invoke-WebRequest $_ -DisableKeepAlive -UseBasicParsing -Method "Head"})] - [String]$DotnetSdkUrl = "https://download.microsoft.com/download/D/C/F/DCFA73BE-93CE-4DA0-AB76-98972FD6E475/dotnet-sdk-2.1.101-win-x64.zip", - [ValidateNotNullOrEmpty()] [ValidateScript( {Invoke-WebRequest $_ -DisableKeepAlive -UseBasicParsing -Method "Head"})] [String]$NugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe", @@ -23,7 +19,6 @@ param ( [ValidateScript( {Test-Path $_ -PathType Container})] [String]$BuildRepositoryLocalPath = $Env:BUILD_REPOSITORY_LOCALPATH, - [Switch]$Dotnet, [Switch]$Python, [Switch]$Nuget ) @@ -45,33 +40,10 @@ if (-not $BuildRepositoryLocalPath) { $BuildRepositoryLocalPath = DefaultBuildRepositoryLocalPath } -$All = -not $Dotnet -and -not $Python -and -not $Nuget +$All = -not $Python -and -not $Nuget [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -<# - # Install .NET Core - #> - -if ($Dotnet -or $All) { - $DotnetInstallPath = Join-Path $AgentWorkFolder "dotnet" - if (Test-Path $DotnetInstallPath) { - Remove-Item $DotnetInstallPath -Force -Recurse - } - New-Item $DotnetInstallPath -ItemType "Directory" -Force - - Write-Host "Downloading .NET Core package." - $DotnetZip = Join-Path $Env:TEMP "dotnet.zip" - (New-Object System.Net.WebClient).DownloadFile($DotnetSdkUrl, $DotnetZip) - - Write-Host "Extracting .NET Core package to $DotnetInstallPath." - Add-Type -A System.IO.Compression.FileSystem - [IO.Compression.ZipFile]::ExtractToDirectory($DotnetZip, $DotnetInstallPath) - - Write-Host "Cleaning up .NET Core installation." - Remove-Item $DotnetZip -} - <# # Install Nuget #> diff --git a/smoke/IotEdgeQuickstart/IotEdgeQuickstart.csproj b/smoke/IotEdgeQuickstart/IotEdgeQuickstart.csproj index 7343f3cd2af..7d0c7beb334 100644 --- a/smoke/IotEdgeQuickstart/IotEdgeQuickstart.csproj +++ b/smoke/IotEdgeQuickstart/IotEdgeQuickstart.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + Exe diff --git a/smoke/LeafDevice/LeafDevice.csproj b/smoke/LeafDevice/LeafDevice.csproj index 1da1c9c904a..bcec08db417 100644 --- a/smoke/LeafDevice/LeafDevice.csproj +++ b/smoke/LeafDevice/LeafDevice.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + Exe diff --git a/stylecop.props b/stylecop.props index 18097e6cf06..8bdcbbc763d 100644 --- a/stylecop.props +++ b/stylecop.props @@ -1,6 +1,6 @@ - + all runtime; build; native; contentfiles; analyzers diff --git a/stylecop.ruleset b/stylecop.ruleset index 9961250f148..57cf90a3cf2 100644 --- a/stylecop.ruleset +++ b/stylecop.ruleset @@ -30,5 +30,9 @@ + + + + \ No newline at end of file diff --git a/test/Microsoft.Azure.Devices.Edge.Test.Common/Microsoft.Azure.Devices.Edge.Test.Common.csproj b/test/Microsoft.Azure.Devices.Edge.Test.Common/Microsoft.Azure.Devices.Edge.Test.Common.csproj index 2e9dfa20dc6..5c9d2db1b34 100644 --- a/test/Microsoft.Azure.Devices.Edge.Test.Common/Microsoft.Azure.Devices.Edge.Test.Common.csproj +++ b/test/Microsoft.Azure.Devices.Edge.Test.Common/Microsoft.Azure.Devices.Edge.Test.Common.csproj @@ -1,15 +1,9 @@ - - netcoreapp2.1 - Debug;Release;CheckInBuild - - - - netcoreapp3.0 - + + Debug;Release;CheckInBuild True diff --git a/test/Microsoft.Azure.Devices.Edge.Test/Microsoft.Azure.Devices.Edge.Test.csproj b/test/Microsoft.Azure.Devices.Edge.Test/Microsoft.Azure.Devices.Edge.Test.csproj index 331175b115b..42f800f5501 100644 --- a/test/Microsoft.Azure.Devices.Edge.Test/Microsoft.Azure.Devices.Edge.Test.csproj +++ b/test/Microsoft.Azure.Devices.Edge.Test/Microsoft.Azure.Devices.Edge.Test.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + True @@ -16,9 +10,9 @@ - - - + + + diff --git a/test/Microsoft.Azure.Devices.Edge.Test/Provisioning.cs b/test/Microsoft.Azure.Devices.Edge.Test/Provisioning.cs index d6d947a6e74..91c7a603cb1 100644 --- a/test/Microsoft.Azure.Devices.Edge.Test/Provisioning.cs +++ b/test/Microsoft.Azure.Devices.Edge.Test/Provisioning.cs @@ -2,7 +2,6 @@ namespace Microsoft.Azure.Devices.Edge.Test { using System; - using System.IO; using System.Security.Cryptography; using System.Text; using System.Threading; diff --git a/test/connectivity/modules/NetworkController/NetworkController.csproj b/test/connectivity/modules/NetworkController/NetworkController.csproj index 8efb1e6c097..6d8e437aa74 100644 --- a/test/connectivity/modules/NetworkController/NetworkController.csproj +++ b/test/connectivity/modules/NetworkController/NetworkController.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + Exe @@ -29,10 +23,10 @@ - - - - + + + + diff --git a/test/connectivity/modules/NetworkController/NetworkStatusReporter.cs b/test/connectivity/modules/NetworkController/NetworkStatusReporter.cs index f9e20227c60..f835e4f2850 100644 --- a/test/connectivity/modules/NetworkController/NetworkStatusReporter.cs +++ b/test/connectivity/modules/NetworkController/NetworkStatusReporter.cs @@ -52,6 +52,5 @@ static void RetryingReportTestResult(RetryingEventArgs retryingEventArgs) { Log.LogDebug($"Retrying ReportTestResult {retryingEventArgs.CurrentRetryCount} times because of error - {retryingEventArgs.LastException}"); } - } } diff --git a/test/connectivity/modules/NetworkController/docker/linux/amd64/Dockerfile b/test/connectivity/modules/NetworkController/docker/linux/amd64/Dockerfile index 1dbb00b65fa..fc3370e6dbc 100644 --- a/test/connectivity/modules/NetworkController/docker/linux/amd64/Dockerfile +++ b/test/connectivity/modules/NetworkController/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.13-alpine3.10 +ARG base_tag=3.1.2-alpine3.10 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/connectivity/modules/NetworkController/docker/linux/arm32v7/base/Dockerfile b/test/connectivity/modules/NetworkController/docker/linux/arm32v7/base/Dockerfile index 8ad2b787033..837a6b5a5e1 100644 --- a/test/connectivity/modules/NetworkController/docker/linux/arm32v7/base/Dockerfile +++ b/test/connectivity/modules/NetworkController/docker/linux/arm32v7/base/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.13-bionic-arm32v7 +ARG base_tag=3.1.2-bionic-arm32v7 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} RUN apt-get update && apt-get install -y --no-install-recommends iproute2 net-tools \ No newline at end of file diff --git a/test/connectivity/modules/NetworkController/docker/linux/arm64v8/Dockerfile b/test/connectivity/modules/NetworkController/docker/linux/arm64v8/Dockerfile index 78b762d24f8..ea735102987 100644 --- a/test/connectivity/modules/NetworkController/docker/linux/arm64v8/Dockerfile +++ b/test/connectivity/modules/NetworkController/docker/linux/arm64v8/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm64v8 +ARG base_tag=1.0.5-linux-arm64v8 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/connectivity/modules/NetworkController/docker/windows/amd64/Dockerfile b/test/connectivity/modules/NetworkController/docker/windows/amd64/Dockerfile index eb964e1441e..aaa2d6c2872 100644 --- a/test/connectivity/modules/NetworkController/docker/windows/amd64/Dockerfile +++ b/test/connectivity/modules/NetworkController/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.15-nanoserver-1809 +ARG base_tag=3.1.2-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/connectivity/modules/NetworkController/docker/windows/arm32v7/Dockerfile b/test/connectivity/modules/NetworkController/docker/windows/arm32v7/Dockerfile index 0873233c6cc..2199c8d2076 100644 --- a/test/connectivity/modules/NetworkController/docker/windows/arm32v7/Dockerfile +++ b/test/connectivity/modules/NetworkController/docker/windows/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-windows-arm32v7 +ARG base_tag=1.0.5-windows-arm32v7 ARG base_registry FROM ${base_registry}/azureiotedge/azureiotedge-module-base:${base_tag} diff --git a/test/modules/CloudToDeviceMessageTester/CloudToDeviceMessageTester.csproj b/test/modules/CloudToDeviceMessageTester/CloudToDeviceMessageTester.csproj index 98536865f76..3ffd1e9029b 100644 --- a/test/modules/CloudToDeviceMessageTester/CloudToDeviceMessageTester.csproj +++ b/test/modules/CloudToDeviceMessageTester/CloudToDeviceMessageTester.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + Exe @@ -22,12 +16,12 @@ - - - - - - + + + + + + diff --git a/test/modules/CloudToDeviceMessageTester/docker/linux/amd64/Dockerfile b/test/modules/CloudToDeviceMessageTester/docker/linux/amd64/Dockerfile index 38bd7d1d919..aa153ac31e9 100644 --- a/test/modules/CloudToDeviceMessageTester/docker/linux/amd64/Dockerfile +++ b/test/modules/CloudToDeviceMessageTester/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.13-alpine3.10 +ARG base_tag=3.1.2-alpine3.10 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/CloudToDeviceMessageTester/docker/linux/arm32v7/Dockerfile b/test/modules/CloudToDeviceMessageTester/docker/linux/arm32v7/Dockerfile index ae3c4ddf8c3..e8b7cc9d305 100644 --- a/test/modules/CloudToDeviceMessageTester/docker/linux/arm32v7/Dockerfile +++ b/test/modules/CloudToDeviceMessageTester/docker/linux/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm32v7 +ARG base_tag=1.0.5-linux-arm32v7 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/CloudToDeviceMessageTester/docker/linux/arm64v8/Dockerfile b/test/modules/CloudToDeviceMessageTester/docker/linux/arm64v8/Dockerfile index 1cf637eed39..38aab788ed2 100644 --- a/test/modules/CloudToDeviceMessageTester/docker/linux/arm64v8/Dockerfile +++ b/test/modules/CloudToDeviceMessageTester/docker/linux/arm64v8/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm64v8 +ARG base_tag=1.0.5-linux-arm64v8 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/CloudToDeviceMessageTester/docker/windows/amd64/Dockerfile b/test/modules/CloudToDeviceMessageTester/docker/windows/amd64/Dockerfile index 209f40f73df..3889db34348 100644 --- a/test/modules/CloudToDeviceMessageTester/docker/windows/amd64/Dockerfile +++ b/test/modules/CloudToDeviceMessageTester/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.15-nanoserver-1809 +ARG base_tag=3.1.2-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ENV MODULE_NAME "CloudToDeviceMessageTester.dll" diff --git a/test/modules/CloudToDeviceMessageTester/docker/windows/arm32v7/Dockerfile b/test/modules/CloudToDeviceMessageTester/docker/windows/arm32v7/Dockerfile index aad09fda1fa..815935f51e1 100644 --- a/test/modules/CloudToDeviceMessageTester/docker/windows/arm32v7/Dockerfile +++ b/test/modules/CloudToDeviceMessageTester/docker/windows/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-windows-arm32v7 +ARG base_tag=1.0.5-windows-arm32v7 ARG base_registry FROM ${base_registry}/azureiotedge/azureiotedge-module-base:${base_tag} diff --git a/test/modules/DeploymentTester/DeploymentTester.csproj b/test/modules/DeploymentTester/DeploymentTester.csproj index faef3af4cef..42ac8ca0366 100644 --- a/test/modules/DeploymentTester/DeploymentTester.csproj +++ b/test/modules/DeploymentTester/DeploymentTester.csproj @@ -1,12 +1,6 @@ - - netcoreapp2.1 - - - - netcoreapp3.0 - + Exe @@ -21,13 +15,13 @@ - - - - - - - + + + + + + + diff --git a/test/modules/DeploymentTester/docker/linux/amd64/Dockerfile b/test/modules/DeploymentTester/docker/linux/amd64/Dockerfile index 9d0d559ef55..a20d6bfda54 100644 --- a/test/modules/DeploymentTester/docker/linux/amd64/Dockerfile +++ b/test/modules/DeploymentTester/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.13-alpine3.10 +ARG base_tag=3.1.2-alpine3.10 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/DeploymentTester/docker/linux/arm32v7/Dockerfile b/test/modules/DeploymentTester/docker/linux/arm32v7/Dockerfile index efe3fb16b46..4b92fa34206 100644 --- a/test/modules/DeploymentTester/docker/linux/arm32v7/Dockerfile +++ b/test/modules/DeploymentTester/docker/linux/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm32v7 +ARG base_tag=1.0.5-linux-arm32v7 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/DeploymentTester/docker/linux/arm64v8/Dockerfile b/test/modules/DeploymentTester/docker/linux/arm64v8/Dockerfile index cfd53cec9b1..2058c368ec9 100644 --- a/test/modules/DeploymentTester/docker/linux/arm64v8/Dockerfile +++ b/test/modules/DeploymentTester/docker/linux/arm64v8/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm64v8 +ARG base_tag=1.0.5-linux-arm64v8 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/DeploymentTester/docker/windows/amd64/Dockerfile b/test/modules/DeploymentTester/docker/windows/amd64/Dockerfile index 806145b5ee7..8e8ea427ead 100644 --- a/test/modules/DeploymentTester/docker/windows/amd64/Dockerfile +++ b/test/modules/DeploymentTester/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.15-nanoserver-1809 +ARG base_tag=3.1.2-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ENV MODULE_NAME "DeploymentTester.dll" diff --git a/test/modules/DeploymentTester/docker/windows/arm32v7/Dockerfile b/test/modules/DeploymentTester/docker/windows/arm32v7/Dockerfile index 6117ba16db5..154bfa779ae 100644 --- a/test/modules/DeploymentTester/docker/windows/arm32v7/Dockerfile +++ b/test/modules/DeploymentTester/docker/windows/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-windows-arm32v7 +ARG base_tag=1.0.5-windows-arm32v7 ARG base_registry FROM ${base_registry}/azureiotedge/azureiotedge-module-base:${base_tag} diff --git a/test/modules/DirectMethodReceiver/DirectMethodReceiver.csproj b/test/modules/DirectMethodReceiver/DirectMethodReceiver.csproj index 1c2a1d8bf53..330c5ee184b 100644 --- a/test/modules/DirectMethodReceiver/DirectMethodReceiver.csproj +++ b/test/modules/DirectMethodReceiver/DirectMethodReceiver.csproj @@ -1,11 +1,5 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + Exe @@ -20,12 +14,12 @@ - - - - - - + + + + + + diff --git a/test/modules/DirectMethodReceiver/docker/linux/amd64/Dockerfile b/test/modules/DirectMethodReceiver/docker/linux/amd64/Dockerfile index f3ec0b606f5..befe28ced8e 100644 --- a/test/modules/DirectMethodReceiver/docker/linux/amd64/Dockerfile +++ b/test/modules/DirectMethodReceiver/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.13-alpine3.10 +ARG base_tag=3.1.2-alpine3.10 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/DirectMethodReceiver/docker/linux/arm32v7/Dockerfile b/test/modules/DirectMethodReceiver/docker/linux/arm32v7/Dockerfile index 3c20ffdae2f..ceba2aa7c4c 100644 --- a/test/modules/DirectMethodReceiver/docker/linux/arm32v7/Dockerfile +++ b/test/modules/DirectMethodReceiver/docker/linux/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm32v7 +ARG base_tag=1.0.5-linux-arm32v7 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/DirectMethodReceiver/docker/linux/arm64v8/Dockerfile b/test/modules/DirectMethodReceiver/docker/linux/arm64v8/Dockerfile index 4cace118083..704acfa4668 100644 --- a/test/modules/DirectMethodReceiver/docker/linux/arm64v8/Dockerfile +++ b/test/modules/DirectMethodReceiver/docker/linux/arm64v8/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm64v8 +ARG base_tag=1.0.5-linux-arm64v8 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/DirectMethodReceiver/docker/windows/amd64/Dockerfile b/test/modules/DirectMethodReceiver/docker/windows/amd64/Dockerfile index 6ef1a07bc3b..19b96127307 100644 --- a/test/modules/DirectMethodReceiver/docker/windows/amd64/Dockerfile +++ b/test/modules/DirectMethodReceiver/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.15-nanoserver-1809 +ARG base_tag=3.1.2-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/DirectMethodReceiver/docker/windows/arm32v7/Dockerfile b/test/modules/DirectMethodReceiver/docker/windows/arm32v7/Dockerfile index 5ec6cdcfedc..a8f6bd06d21 100644 --- a/test/modules/DirectMethodReceiver/docker/windows/arm32v7/Dockerfile +++ b/test/modules/DirectMethodReceiver/docker/windows/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-windows-arm32v7 +ARG base_tag=1.0.5-windows-arm32v7 ARG base_registry FROM ${base_registry}/azureiotedge/azureiotedge-module-base:${base_tag} diff --git a/test/modules/DirectMethodSender/DirectMethodSender.csproj b/test/modules/DirectMethodSender/DirectMethodSender.csproj index 1ead670b4c7..527f330a3c5 100644 --- a/test/modules/DirectMethodSender/DirectMethodSender.csproj +++ b/test/modules/DirectMethodSender/DirectMethodSender.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + Exe @@ -22,12 +16,12 @@ - - - - - - + + + + + + diff --git a/test/modules/DirectMethodSender/docker/linux/amd64/Dockerfile b/test/modules/DirectMethodSender/docker/linux/amd64/Dockerfile index 000f212d32e..1b360e6b8c8 100644 --- a/test/modules/DirectMethodSender/docker/linux/amd64/Dockerfile +++ b/test/modules/DirectMethodSender/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.13-alpine3.10 +ARG base_tag=3.1.2-alpine3.10 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/DirectMethodSender/docker/linux/arm32v7/Dockerfile b/test/modules/DirectMethodSender/docker/linux/arm32v7/Dockerfile index f6cd7d6e4cb..469e205ba99 100644 --- a/test/modules/DirectMethodSender/docker/linux/arm32v7/Dockerfile +++ b/test/modules/DirectMethodSender/docker/linux/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm32v7 +ARG base_tag=1.0.5-linux-arm32v7 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/DirectMethodSender/docker/linux/arm64v8/Dockerfile b/test/modules/DirectMethodSender/docker/linux/arm64v8/Dockerfile index 8ef96e7f869..06c30acfcd5 100644 --- a/test/modules/DirectMethodSender/docker/linux/arm64v8/Dockerfile +++ b/test/modules/DirectMethodSender/docker/linux/arm64v8/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm64v8 +ARG base_tag=1.0.5-linux-arm64v8 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/DirectMethodSender/docker/windows/amd64/Dockerfile b/test/modules/DirectMethodSender/docker/windows/amd64/Dockerfile index 53ccb4aad0c..5ede88893b9 100644 --- a/test/modules/DirectMethodSender/docker/windows/amd64/Dockerfile +++ b/test/modules/DirectMethodSender/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.15-nanoserver-1809 +ARG base_tag=3.1.2-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/DirectMethodSender/docker/windows/arm32v7/Dockerfile b/test/modules/DirectMethodSender/docker/windows/arm32v7/Dockerfile index 357ac814949..919ecd5833c 100644 --- a/test/modules/DirectMethodSender/docker/windows/arm32v7/Dockerfile +++ b/test/modules/DirectMethodSender/docker/windows/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-windows-arm32v7 +ARG base_tag=1.0.5-windows-arm32v7 ARG base_registry FROM ${base_registry}/azureiotedge/azureiotedge-module-base:${base_tag} diff --git a/test/modules/EdgeHubRestartTester/EdgeHubRestartTester.csproj b/test/modules/EdgeHubRestartTester/EdgeHubRestartTester.csproj index 6106b9e567b..b43bb812afd 100644 --- a/test/modules/EdgeHubRestartTester/EdgeHubRestartTester.csproj +++ b/test/modules/EdgeHubRestartTester/EdgeHubRestartTester.csproj @@ -1,12 +1,6 @@ - - netcoreapp2.1 - - - - netcoreapp3.0 - + Exe @@ -35,12 +29,12 @@ - - - - - - + + + + + + diff --git a/test/modules/EdgeHubRestartTester/docker/linux/arm32v7/Dockerfile b/test/modules/EdgeHubRestartTester/docker/linux/arm32v7/Dockerfile index 9f2b1d093b4..f766ef722fb 100644 --- a/test/modules/EdgeHubRestartTester/docker/linux/arm32v7/Dockerfile +++ b/test/modules/EdgeHubRestartTester/docker/linux/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm32v7 +ARG base_tag=1.0.5-linux-arm32v7 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/EdgeHubRestartTester/docker/linux/arm64v8/Dockerfile b/test/modules/EdgeHubRestartTester/docker/linux/arm64v8/Dockerfile index 603e27b001b..13260674a98 100644 --- a/test/modules/EdgeHubRestartTester/docker/linux/arm64v8/Dockerfile +++ b/test/modules/EdgeHubRestartTester/docker/linux/arm64v8/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm64v8 +ARG base_tag=1.0.5-linux-arm64v8 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/MetricsValidator/MetricsValidator.csproj b/test/modules/MetricsValidator/MetricsValidator.csproj index 3b405e7cbe6..f43d86edb43 100644 --- a/test/modules/MetricsValidator/MetricsValidator.csproj +++ b/test/modules/MetricsValidator/MetricsValidator.csproj @@ -1,11 +1,6 @@  - - netcoreapp2.1 - - - netcoreapp3.0 - + Exe @@ -20,12 +15,12 @@ - - - - - - + + + + + + diff --git a/test/modules/MetricsValidator/docker/linux/amd64/Dockerfile b/test/modules/MetricsValidator/docker/linux/amd64/Dockerfile index 62862f7b9c7..790a3272eda 100644 --- a/test/modules/MetricsValidator/docker/linux/amd64/Dockerfile +++ b/test/modules/MetricsValidator/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.13-alpine3.10 +ARG base_tag=3.1.2-alpine3.10 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/MetricsValidator/docker/linux/arm32v7/Dockerfile b/test/modules/MetricsValidator/docker/linux/arm32v7/Dockerfile index e8ace28c9bd..5e27d19209a 100644 --- a/test/modules/MetricsValidator/docker/linux/arm32v7/Dockerfile +++ b/test/modules/MetricsValidator/docker/linux/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm32v7 +ARG base_tag=1.0.5-linux-arm32v7 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/MetricsValidator/docker/linux/arm64v8/Dockerfile b/test/modules/MetricsValidator/docker/linux/arm64v8/Dockerfile index 253fc88a589..6d7e8a5a714 100644 --- a/test/modules/MetricsValidator/docker/linux/arm64v8/Dockerfile +++ b/test/modules/MetricsValidator/docker/linux/arm64v8/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm64v8 +ARG base_tag=1.0.5-linux-arm64v8 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/MetricsValidator/docker/windows/amd64/Dockerfile b/test/modules/MetricsValidator/docker/windows/amd64/Dockerfile index f48e9dd4143..64c7139cde2 100644 --- a/test/modules/MetricsValidator/docker/windows/amd64/Dockerfile +++ b/test/modules/MetricsValidator/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.13-nanoserver-1809 +ARG base_tag=3.1.2-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/MetricsValidator/docker/windows/arm32v7/Dockerfile b/test/modules/MetricsValidator/docker/windows/arm32v7/Dockerfile index c07a3f0b939..fe113816f63 100644 --- a/test/modules/MetricsValidator/docker/windows/arm32v7/Dockerfile +++ b/test/modules/MetricsValidator/docker/windows/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.3-windows-arm32v7 +ARG base_tag=1.0.5-windows-arm32v7 ARG base_registry FROM ${base_registry}/azureiotedge/azureiotedge-module-base:${base_tag} diff --git a/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj b/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj index 5e53b875e54..976a9499145 100644 --- a/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj +++ b/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj @@ -1,13 +1,6 @@  - - netcoreapp2.1 - Debug;Release;CheckInBuild - - - - netcoreapp3.0 - + @@ -24,6 +17,7 @@ ..\..\..\stylecop.ruleset Microsoft.Azure.Devices.Edge.ModuleUtil Microsoft.Azure.Devices.Edge.ModuleUtil + Debug;Release;CheckInBuild diff --git a/test/modules/ModuleRestarter/ModuleRestarter.csproj b/test/modules/ModuleRestarter/ModuleRestarter.csproj index bf6f9b0b1e7..a4df47eb0ca 100644 --- a/test/modules/ModuleRestarter/ModuleRestarter.csproj +++ b/test/modules/ModuleRestarter/ModuleRestarter.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + Exe @@ -22,12 +16,12 @@ - - - - - - + + + + + + diff --git a/test/modules/ModuleRestarter/docker/linux/arm32v7/Dockerfile b/test/modules/ModuleRestarter/docker/linux/arm32v7/Dockerfile index b3bd66288cf..7c26b46dc74 100644 --- a/test/modules/ModuleRestarter/docker/linux/arm32v7/Dockerfile +++ b/test/modules/ModuleRestarter/docker/linux/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm32v7 +ARG base_tag=1.0.5-linux-arm32v7 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/ModuleRestarter/docker/linux/arm64v8/Dockerfile b/test/modules/ModuleRestarter/docker/linux/arm64v8/Dockerfile index e0795ab6ede..5d443a5c93d 100644 --- a/test/modules/ModuleRestarter/docker/linux/arm64v8/Dockerfile +++ b/test/modules/ModuleRestarter/docker/linux/arm64v8/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm64v8 +ARG base_tag=1.0.5-linux-arm64v8 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/Modules.Test/Modules.Test.csproj b/test/modules/Modules.Test/Modules.Test.csproj index cf9ec6d2f7c..c6afa0332d5 100644 --- a/test/modules/Modules.Test/Modules.Test.csproj +++ b/test/modules/Modules.Test/Modules.Test.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + True diff --git a/test/modules/Relayer/Relayer.csproj b/test/modules/Relayer/Relayer.csproj index 8f547f62ec6..a6a16699f97 100644 --- a/test/modules/Relayer/Relayer.csproj +++ b/test/modules/Relayer/Relayer.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + Exe @@ -21,13 +15,13 @@ - - - - - - - + + + + + + + diff --git a/test/modules/Relayer/docker/linux/amd64/Dockerfile b/test/modules/Relayer/docker/linux/amd64/Dockerfile index 7b170390f78..4ff627c4f18 100644 --- a/test/modules/Relayer/docker/linux/amd64/Dockerfile +++ b/test/modules/Relayer/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.13-alpine3.10 +ARG base_tag=3.1.2-alpine3.10 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/Relayer/docker/linux/arm32v7/Dockerfile b/test/modules/Relayer/docker/linux/arm32v7/Dockerfile index 7e3e2107503..c40ca4808a5 100644 --- a/test/modules/Relayer/docker/linux/arm32v7/Dockerfile +++ b/test/modules/Relayer/docker/linux/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm32v7 +ARG base_tag=1.0.5-linux-arm32v7 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/Relayer/docker/linux/arm64v8/Dockerfile b/test/modules/Relayer/docker/linux/arm64v8/Dockerfile index 1cb67b05071..0d3ac8a3a5a 100644 --- a/test/modules/Relayer/docker/linux/arm64v8/Dockerfile +++ b/test/modules/Relayer/docker/linux/arm64v8/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm64v8 +ARG base_tag=1.0.5-linux-arm64v8 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/Relayer/docker/windows/amd64/Dockerfile b/test/modules/Relayer/docker/windows/amd64/Dockerfile index 957cd83f98f..3ab066b6430 100644 --- a/test/modules/Relayer/docker/windows/amd64/Dockerfile +++ b/test/modules/Relayer/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.15-nanoserver-1809 +ARG base_tag=3.1.2-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ENV MODULE_NAME "Relayer.dll" diff --git a/test/modules/Relayer/docker/windows/arm32v7/Dockerfile b/test/modules/Relayer/docker/windows/arm32v7/Dockerfile index 9b5f28efa52..3de912ad860 100644 --- a/test/modules/Relayer/docker/windows/arm32v7/Dockerfile +++ b/test/modules/Relayer/docker/windows/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-windows-arm32v7 +ARG base_tag=1.0.5-windows-arm32v7 ARG base_registry FROM ${base_registry}/azureiotedge/azureiotedge-module-base:${base_tag} diff --git a/test/modules/TemperatureFilter/TemperatureFilter.csproj b/test/modules/TemperatureFilter/TemperatureFilter.csproj index c6d13ed0348..583aa831cd5 100644 --- a/test/modules/TemperatureFilter/TemperatureFilter.csproj +++ b/test/modules/TemperatureFilter/TemperatureFilter.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + Exe @@ -21,11 +15,11 @@ - - - - - + + + + + diff --git a/test/modules/TemperatureFilter/docker/linux/amd64/Dockerfile b/test/modules/TemperatureFilter/docker/linux/amd64/Dockerfile index 61a218eb9e2..52096042924 100644 --- a/test/modules/TemperatureFilter/docker/linux/amd64/Dockerfile +++ b/test/modules/TemperatureFilter/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.13-alpine3.10 +ARG base_tag=3.1.2-alpine3.10 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TemperatureFilter/docker/linux/arm32v7/Dockerfile b/test/modules/TemperatureFilter/docker/linux/arm32v7/Dockerfile index c113e3532e6..0e909a93337 100644 --- a/test/modules/TemperatureFilter/docker/linux/arm32v7/Dockerfile +++ b/test/modules/TemperatureFilter/docker/linux/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm32v7 +ARG base_tag=1.0.5-linux-arm32v7 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TemperatureFilter/docker/linux/arm64v8/Dockerfile b/test/modules/TemperatureFilter/docker/linux/arm64v8/Dockerfile index cc397005395..d77049c2dfe 100644 --- a/test/modules/TemperatureFilter/docker/linux/arm64v8/Dockerfile +++ b/test/modules/TemperatureFilter/docker/linux/arm64v8/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm64v8 +ARG base_tag=1.0.5-linux-arm64v8 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TemperatureFilter/docker/windows/amd64/Dockerfile b/test/modules/TemperatureFilter/docker/windows/amd64/Dockerfile index 360ba0c05f3..81ecc173267 100644 --- a/test/modules/TemperatureFilter/docker/windows/amd64/Dockerfile +++ b/test/modules/TemperatureFilter/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.15-nanoserver-1809 +ARG base_tag=3.1.2-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TemperatureFilter/docker/windows/arm32v7/Dockerfile b/test/modules/TemperatureFilter/docker/windows/arm32v7/Dockerfile index d53274aa6c6..7c1459b47dd 100644 --- a/test/modules/TemperatureFilter/docker/windows/arm32v7/Dockerfile +++ b/test/modules/TemperatureFilter/docker/windows/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-windows-arm32v7 +ARG base_tag=1.0.5-windows-arm32v7 ARG base_registry FROM ${base_registry}/azureiotedge/azureiotedge-module-base:${base_tag} diff --git a/test/modules/TestAnalyzer/Program.cs b/test/modules/TestAnalyzer/Program.cs index 2c5e09a1a7e..24f5cd852b0 100644 --- a/test/modules/TestAnalyzer/Program.cs +++ b/test/modules/TestAnalyzer/Program.cs @@ -7,11 +7,11 @@ namespace TestAnalyzer using System.Runtime.Loader; using System.Threading; using System.Threading.Tasks; - using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Azure.Devices.Common; using Microsoft.Azure.Devices.Edge.ModuleUtil; using Microsoft.Azure.EventHubs; + using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; class Program @@ -31,7 +31,7 @@ static async Task Main(string[] args) var tcs = new TaskCompletionSource(); cts.Token.Register(s => ((TaskCompletionSource)s).SetResult(true), tcs); - await CreateWebHostBuilder(args).Build().RunAsync(cts.Token); + await CreateHostBuilder(args).Build().RunAsync(cts.Token); } static async Task LoadStartupTimeFromStorageAsync() @@ -53,10 +53,14 @@ static async Task LoadStartupTimeFromStorageAsync() return lastReceivedAt; } - static IWebHostBuilder CreateWebHostBuilder(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseUrls($"http://*:{Settings.Current.WebhostPort}") - .UseStartup(); + static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder + .UseUrls($"http://*:{Settings.Current.WebhostPort}") + .UseStartup(); + }); static async Task ReceiveMessagesAsync(DateTime lastReceivedMesssage) { diff --git a/test/modules/TestAnalyzer/Startup.cs b/test/modules/TestAnalyzer/Startup.cs index 54209a21eda..242eaebdde5 100644 --- a/test/modules/TestAnalyzer/Startup.cs +++ b/test/modules/TestAnalyzer/Startup.cs @@ -5,6 +5,7 @@ namespace TestAnalyzer using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.Hosting; class Startup { @@ -18,21 +19,22 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc(); + services.AddControllers(); } - // TODO: Remove warning disable for Obsolete when project is moved to dotnetcore 3.0 -#pragma warning disable 612, 618 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - app.UseMvc(); + app.UseRouting(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); } -#pragma warning restore 612, 618 } } diff --git a/test/modules/TestAnalyzer/TestAnalyzer.csproj b/test/modules/TestAnalyzer/TestAnalyzer.csproj index 2baee6df2e1..990f65f9744 100644 --- a/test/modules/TestAnalyzer/TestAnalyzer.csproj +++ b/test/modules/TestAnalyzer/TestAnalyzer.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + Exe @@ -18,21 +12,19 @@ - + + + + + - - - - - - - - - - - + + + + + diff --git a/test/modules/TestAnalyzer/docker/linux/amd64/Dockerfile b/test/modules/TestAnalyzer/docker/linux/amd64/Dockerfile index 94b4208ae38..8e982550aa3 100644 --- a/test/modules/TestAnalyzer/docker/linux/amd64/Dockerfile +++ b/test/modules/TestAnalyzer/docker/linux/amd64/Dockerfile @@ -1,7 +1,7 @@ -ARG base_tag=2.1.13-alpine3.10 +ARG base_tag=3.1.2-alpine3.10 FROM azureiotedge/azureiotedge-runtime-base:1.1-linux-amd64 as builder -FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} +FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TestAnalyzer/docker/linux/arm32v7/Dockerfile b/test/modules/TestAnalyzer/docker/linux/arm32v7/Dockerfile index 1e41b3d62b5..d51af17f2cc 100644 --- a/test/modules/TestAnalyzer/docker/linux/arm32v7/Dockerfile +++ b/test/modules/TestAnalyzer/docker/linux/arm32v7/Dockerfile @@ -1,5 +1,5 @@ -ARG base_tag=1.0.4-linux-arm32v7 -FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-rocksdb:${base_tag} +ARG base_tag=1.0.5-linux-arm32v7 +FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-rocksdb-aspnet:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile b/test/modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile index 11276678c71..b471299c69a 100644 --- a/test/modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile +++ b/test/modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile @@ -1,5 +1,5 @@ -ARG base_tag=2.1.16-bionic-arm32v7 -FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} +ARG base_tag=3.1.2-bionic-arm32v7 +FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} RUN apt-get update && apt-get install -y libcap2-bin libsnappy1v5 && \ ln -s /lib/arm-linux-gnueabihf/libdl.so.2 /usr/lib/arm-linux-gnueabihf/libdl.so && \ diff --git a/test/modules/TestAnalyzer/docker/linux/arm64v8/Dockerfile b/test/modules/TestAnalyzer/docker/linux/arm64v8/Dockerfile index 8bd2ae05eb0..8ca3689632a 100644 --- a/test/modules/TestAnalyzer/docker/linux/arm64v8/Dockerfile +++ b/test/modules/TestAnalyzer/docker/linux/arm64v8/Dockerfile @@ -1,5 +1,5 @@ -ARG base_tag=1.0.4-linux-arm64v8 -FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-rocksdb:${base_tag} +ARG base_tag=1.0.5-linux-arm64v8 +FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-rocksdb-aspnet:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TestAnalyzer/docker/linux/arm64v8/base/Dockerfile b/test/modules/TestAnalyzer/docker/linux/arm64v8/base/Dockerfile index 69916c45ffd..5219eff65d5 100644 --- a/test/modules/TestAnalyzer/docker/linux/arm64v8/base/Dockerfile +++ b/test/modules/TestAnalyzer/docker/linux/arm64v8/base/Dockerfile @@ -1,5 +1,5 @@ -ARG base_tag=3.0.3-bionic-arm64v8 -FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} +ARG base_tag=3.1.2-bionic-arm64v8 +FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} RUN apt-get update && \ apt-get install -y libsnappy1v5 && \ diff --git a/test/modules/TestAnalyzer/docker/windows/amd64/Dockerfile b/test/modules/TestAnalyzer/docker/windows/amd64/Dockerfile index 2650216c1d7..95e591ed52c 100644 --- a/test/modules/TestAnalyzer/docker/windows/amd64/Dockerfile +++ b/test/modules/TestAnalyzer/docker/windows/amd64/Dockerfile @@ -1,5 +1,5 @@ -ARG base_tag=2.1.15-nanoserver-1809 -FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} +ARG base_tag=3.1.2-nanoserver-1809 +FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TestAnalyzer/docker/windows/arm32v7/Dockerfile b/test/modules/TestAnalyzer/docker/windows/arm32v7/Dockerfile index 69fa935b83c..367ddda3fb9 100644 --- a/test/modules/TestAnalyzer/docker/windows/arm32v7/Dockerfile +++ b/test/modules/TestAnalyzer/docker/windows/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-windows-arm32v7 +ARG base_tag=1.0.5-windows-arm32v7 ARG base_registry FROM ${base_registry}/azureiotedge/azureiotedge-module-base:${base_tag} diff --git a/test/modules/TestResultCoordinator/Program.cs b/test/modules/TestResultCoordinator/Program.cs index 097642e2b3c..a8199d7cab0 100644 --- a/test/modules/TestResultCoordinator/Program.cs +++ b/test/modules/TestResultCoordinator/Program.cs @@ -4,10 +4,10 @@ namespace TestResultCoordinator using System; using System.Threading; using System.Threading.Tasks; - using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Azure.Devices.Edge.ModuleUtil; using Microsoft.Azure.Devices.Edge.Util; + using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; class Program @@ -21,7 +21,7 @@ static async Task Main(string[] args) (CancellationTokenSource cts, ManualResetEventSlim completed, Option handler) = ShutdownHandler.Init(TimeSpan.FromSeconds(5), Logger); Logger.LogInformation("Creating WebHostBuilder..."); - Task webHost = CreateWebHostBuilder(args).Build().RunAsync(cts.Token); + Task webHost = CreateHostBuilder(args).Build().RunAsync(cts.Token); await Task.WhenAny(cts.Token.WhenCanceled(), webHost); @@ -30,10 +30,14 @@ static async Task Main(string[] args) Logger.LogInformation("TestResultCoordinator Main() exited."); } - static IWebHostBuilder CreateWebHostBuilder(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseUrls($"http://*:{Settings.Current.WebHostPort}") - .UseSockets() - .UseStartup(); + static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder + .UseUrls($"http://*:{Settings.Current.WebHostPort}") + .UseSockets() + .UseStartup(); + }); } } diff --git a/test/modules/TestResultCoordinator/Startup.cs b/test/modules/TestResultCoordinator/Startup.cs index 0f14b7fe487..cdbb46b0d96 100644 --- a/test/modules/TestResultCoordinator/Startup.cs +++ b/test/modules/TestResultCoordinator/Startup.cs @@ -33,7 +33,7 @@ public void ConfigureServices(IServiceCollection services) { Logger.LogInformation("Calling Startup.ConfigureServices"); - services.AddMvc(); + services.AddControllers(); HashSet sources = Settings.Current.GetResultSourcesAsync(Logger).Result; Logger.LogInformation($"Result sources defined:{Environment.NewLine} {string.Join(Environment.NewLine + Enumerable.Repeat(" ", 5), sources)}"); @@ -80,7 +80,11 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) app.UseDeveloperExceptionPage(); } - app.UseMvc(); + app.UseRouting(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); } #pragma warning restore 612, 618 diff --git a/test/modules/TestResultCoordinator/TestResultCoordinator.csproj b/test/modules/TestResultCoordinator/TestResultCoordinator.csproj index 5a6d5aa2b0c..953f70b2e31 100644 --- a/test/modules/TestResultCoordinator/TestResultCoordinator.csproj +++ b/test/modules/TestResultCoordinator/TestResultCoordinator.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + Exe @@ -19,17 +13,15 @@ + + + + - - - - - - - + diff --git a/test/modules/TestResultCoordinator/docker/linux/amd64/Dockerfile b/test/modules/TestResultCoordinator/docker/linux/amd64/Dockerfile index e1dc2c60682..f0b08484a6a 100644 --- a/test/modules/TestResultCoordinator/docker/linux/amd64/Dockerfile +++ b/test/modules/TestResultCoordinator/docker/linux/amd64/Dockerfile @@ -1,7 +1,7 @@ -ARG base_tag=2.1.13-alpine3.10 +ARG base_tag=3.1.2-alpine3.10 FROM azureiotedge/azureiotedge-runtime-base:1.1-linux-amd64 as builder -FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} +FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TestResultCoordinator/docker/linux/arm32v7/Dockerfile b/test/modules/TestResultCoordinator/docker/linux/arm32v7/Dockerfile index 46f9f5e3479..35b37f3cdd5 100644 --- a/test/modules/TestResultCoordinator/docker/linux/arm32v7/Dockerfile +++ b/test/modules/TestResultCoordinator/docker/linux/arm32v7/Dockerfile @@ -1,5 +1,5 @@ -ARG base_tag=1.0.4-linux-arm32v7 -FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-rocksdb:${base_tag} +ARG base_tag=1.0.5-linux-arm32v7 +FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-rocksdb-aspnet:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TestResultCoordinator/docker/linux/arm64v8/Dockerfile b/test/modules/TestResultCoordinator/docker/linux/arm64v8/Dockerfile index e245987d781..5612c036c43 100644 --- a/test/modules/TestResultCoordinator/docker/linux/arm64v8/Dockerfile +++ b/test/modules/TestResultCoordinator/docker/linux/arm64v8/Dockerfile @@ -1,5 +1,5 @@ -ARG base_tag=1.0.4-linux-arm64v8 -FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-rocksdb:${base_tag} +ARG base_tag=1.0.5-linux-arm64v8 +FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-rocksdb-aspnet:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TestResultCoordinator/docker/windows/amd64/Dockerfile b/test/modules/TestResultCoordinator/docker/windows/amd64/Dockerfile index bdb00f3ca79..4e14440abd8 100644 --- a/test/modules/TestResultCoordinator/docker/windows/amd64/Dockerfile +++ b/test/modules/TestResultCoordinator/docker/windows/amd64/Dockerfile @@ -1,5 +1,5 @@ -ARG base_tag=2.1.13-nanoserver-1809 -FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} +ARG base_tag=3.1.2-nanoserver-1809 +FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TestResultCoordinator/docker/windows/arm32v7/Dockerfile b/test/modules/TestResultCoordinator/docker/windows/arm32v7/Dockerfile index dde8c03602a..c643e359ff3 100644 --- a/test/modules/TestResultCoordinator/docker/windows/arm32v7/Dockerfile +++ b/test/modules/TestResultCoordinator/docker/windows/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.3-windows-arm32v7 +ARG base_tag=1.0.5-windows-arm32v7 ARG base_registry FROM ${base_registry}/azureiotedge/azureiotedge-module-base:${base_tag} diff --git a/test/modules/TwinTester/TwinTester.csproj b/test/modules/TwinTester/TwinTester.csproj index 2885db37c2b..0b87947ec96 100644 --- a/test/modules/TwinTester/TwinTester.csproj +++ b/test/modules/TwinTester/TwinTester.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + Exe @@ -22,13 +16,13 @@ - - - - - - - + + + + + + + diff --git a/test/modules/TwinTester/docker/linux/amd64/Dockerfile b/test/modules/TwinTester/docker/linux/amd64/Dockerfile index 5604bd0aef8..92cb3eece1d 100644 --- a/test/modules/TwinTester/docker/linux/amd64/Dockerfile +++ b/test/modules/TwinTester/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.13-alpine3.10 +ARG base_tag=3.1.2-alpine3.10 FROM azureiotedge/azureiotedge-runtime-base:1.1-linux-amd64 as builder FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} diff --git a/test/modules/TwinTester/docker/linux/arm32v7/Dockerfile b/test/modules/TwinTester/docker/linux/arm32v7/Dockerfile index 3690395c48d..72fcaf5cac9 100644 --- a/test/modules/TwinTester/docker/linux/arm32v7/Dockerfile +++ b/test/modules/TwinTester/docker/linux/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm32v7 +ARG base_tag=1.0.5-linux-arm32v7 FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-rocksdb:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TwinTester/docker/linux/arm64v8/Dockerfile b/test/modules/TwinTester/docker/linux/arm64v8/Dockerfile index bf8aad444b5..02d1cc2dc2e 100644 --- a/test/modules/TwinTester/docker/linux/arm64v8/Dockerfile +++ b/test/modules/TwinTester/docker/linux/arm64v8/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm64v8 +ARG base_tag=1.0.5-linux-arm64v8 FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-rocksdb:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TwinTester/docker/windows/amd64/Dockerfile b/test/modules/TwinTester/docker/windows/amd64/Dockerfile index 52b702f5039..6b54ce299da 100644 --- a/test/modules/TwinTester/docker/windows/amd64/Dockerfile +++ b/test/modules/TwinTester/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.15-nanoserver-1809 +ARG base_tag=3.1.2-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TwinTester/docker/windows/arm32v7/Dockerfile b/test/modules/TwinTester/docker/windows/arm32v7/Dockerfile index 81d759d2ce3..2d18a9de6cd 100644 --- a/test/modules/TwinTester/docker/windows/arm32v7/Dockerfile +++ b/test/modules/TwinTester/docker/windows/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-windows-arm32v7 +ARG base_tag=1.0.5-windows-arm32v7 ARG base_registry FROM ${base_registry}/azureiotedge/azureiotedge-module-base:${base_tag} diff --git a/test/modules/load-gen/docker/linux/amd64/Dockerfile b/test/modules/load-gen/docker/linux/amd64/Dockerfile index 867a86333a9..c65176076e9 100644 --- a/test/modules/load-gen/docker/linux/amd64/Dockerfile +++ b/test/modules/load-gen/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.13-alpine3.10 +ARG base_tag=3.1.2-alpine3.10 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/load-gen/docker/linux/arm32v7/Dockerfile b/test/modules/load-gen/docker/linux/arm32v7/Dockerfile index 2a62937f017..adee543b505 100644 --- a/test/modules/load-gen/docker/linux/arm32v7/Dockerfile +++ b/test/modules/load-gen/docker/linux/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm32v7 +ARG base_tag=1.0.5-linux-arm32v7 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/load-gen/docker/linux/arm64v8/Dockerfile b/test/modules/load-gen/docker/linux/arm64v8/Dockerfile index a9e62344b51..3035bdb5001 100644 --- a/test/modules/load-gen/docker/linux/arm64v8/Dockerfile +++ b/test/modules/load-gen/docker/linux/arm64v8/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-linux-arm64v8 +ARG base_tag=1.0.5-linux-arm64v8 FROM azureiotedge/azureiotedge-module-base:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/load-gen/docker/windows/amd64/Dockerfile b/test/modules/load-gen/docker/windows/amd64/Dockerfile index 447cc490f95..8c220300dfb 100644 --- a/test/modules/load-gen/docker/windows/amd64/Dockerfile +++ b/test/modules/load-gen/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.15-nanoserver-1809 +ARG base_tag=3.1.2-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/load-gen/docker/windows/arm32v7/Dockerfile b/test/modules/load-gen/docker/windows/arm32v7/Dockerfile index 4609ef38b7f..eb20ec2fe72 100644 --- a/test/modules/load-gen/docker/windows/arm32v7/Dockerfile +++ b/test/modules/load-gen/docker/windows/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.4-windows-arm32v7 +ARG base_tag=1.0.5-windows-arm32v7 ARG base_registry FROM ${base_registry}/azureiotedge/azureiotedge-module-base:${base_tag} diff --git a/test/modules/load-gen/load-gen.csproj b/test/modules/load-gen/load-gen.csproj index 30d6f15ad42..d73126d28dd 100644 --- a/test/modules/load-gen/load-gen.csproj +++ b/test/modules/load-gen/load-gen.csproj @@ -1,12 +1,6 @@  - - netcoreapp2.1 - - - - netcoreapp3.0 - + Exe @@ -22,13 +16,13 @@ - - - - - - - + + + + + + + From 6366d0f417c9a2132bef59f62f5b0b6241209698 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 28 Apr 2020 15:18:53 -0700 Subject: [PATCH 002/111] refactor images release yaml --- builds/misc/images-release.yaml | 41 +++++++++++++++------------------ 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/builds/misc/images-release.yaml b/builds/misc/images-release.yaml index 9aa0fbd9f22..67750c04e26 100644 --- a/builds/misc/images-release.yaml +++ b/builds/misc/images-release.yaml @@ -31,34 +31,32 @@ jobs: docker login '$(build.registry.address)' --username '$(build.registry.user)' --password '$(build.registry.password)' docker login '$(registry.address)' --username '$(registry.user)' --password '$(registry.password)' displayName: 'Docker Login' - - displayName: "Install Rust" + - task: Bash@3 + displayName: "Install Rust" inputs: arguments: "--package-arm" filePath: ./edgelet/build/linux/install.sh targetType: filePath - task: Bash@3 - bash: "echo \"##vso[task.setvariable variable=PATH;]$HOME/.cargo/bin:$PATH\"" displayName: "Modify path" - - displayName: "Install .NET Core - 3.1.3" - inputs: - version: "3.1.201" - task: DotNetCoreInstaller@0 - - displayName: "Install build prerequisites" + - template: ../templates/install-dotnet3.yaml + - task: ShellScript@2 + displayName: "Install build prerequisites" inputs: scriptPath: scripts/linux/installPrereqs.sh - task: ShellScript@2 - bash: "cargo install --git https://github.com/arsing/cross.git --branch set-path" displayName: "Install cross (fork with docker fix)" - - displayName: "Build Azure-IoT-Edge-Core" + - task: ShellScript@2 + displayName: "Build Azure-IoT-Edge-Core" inputs: args: "-c Release" scriptPath: scripts/linux/buildBranch.sh - task: ShellScript@2 - - displayName: "Install .NET Core 2.1" + - task: DotNetCoreInstaller@0 + displayName: "Install .NET Core 2.1" inputs: version: "2.1.700" - task: DotNetCoreInstaller@0 - - displayName: "Edge Agent Code Sign" + - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + displayName: "Edge Agent Code Sign" inputs: ConnectedServiceName: "Azure IoT Edge Code Sign 2" FolderPath: $(Build.BinariesDirectory)/publish/Microsoft.Azure.Devices.Edge.Agent.Service @@ -112,8 +110,8 @@ jobs: } ] signConfigType: inlineSignParams - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - - displayName: "Edge Hub Code Sign" + - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + displayName: "Edge Hub Code Sign" inputs: ConnectedServiceName: "Azure IoT Edge Code Sign 2" FolderPath: $(Build.BinariesDirectory)/publish/Microsoft.Azure.Devices.Edge.Hub.Service @@ -167,8 +165,8 @@ jobs: } ] signConfigType: inlineSignParams - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - - displayName: "Temp Sensor Code Sign" + - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + displayName: "Temp Sensor Code Sign" inputs: ConnectedServiceName: "Azure IoT Edge Code Sign 2" FolderPath: $(Build.BinariesDirectory)/publish/SimulatedTemperatureSensor @@ -222,8 +220,8 @@ jobs: } ] signConfigType: inlineSignParams - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - - displayName: "Functions Binding Code Sign" + - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + displayName: "Functions Binding Code Sign" inputs: ConnectedServiceName: "Azure IoT Edge Code Sign 2" FolderPath: $(Build.BinariesDirectory)/publish/Microsoft.Azure.WebJobs.Extensions.EdgeHub @@ -277,11 +275,10 @@ jobs: } ] signConfigType: inlineSignParams - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - - displayName: "Install .NET Core - 3.1.3" + - task: DotNetCoreInstaller@0 + displayName: "Install .NET Core - 3.1.3" inputs: version: "3.1.201" - task: DotNetCoreInstaller@0 - displayName: "Functions Binding nuget package" inputs: buildProperties: OutDir=$(Build.BinariesDirectory)/publish/Microsoft.Azure.WebJobs.Extensions.EdgeHub From 14d69b94d932bce220384792090fd0651703fd25 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 28 Apr 2020 15:27:04 -0700 Subject: [PATCH 003/111] refactor images release yaml --- builds/misc/images-release.yaml | 76 ++++++++++++++++----------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/builds/misc/images-release.yaml b/builds/misc/images-release.yaml index 67750c04e26..79de8b4a3c3 100644 --- a/builds/misc/images-release.yaml +++ b/builds/misc/images-release.yaml @@ -279,7 +279,8 @@ jobs: displayName: "Install .NET Core - 3.1.3" inputs: version: "3.1.201" - - displayName: "Functions Binding nuget package" + - task: DotNetCoreCLI@2 + displayName: "Functions Binding nuget package" inputs: buildProperties: OutDir=$(Build.BinariesDirectory)/publish/Microsoft.Azure.WebJobs.Extensions.EdgeHub command: pack @@ -288,12 +289,12 @@ jobs: packagesToPack: "**/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj" versionEnvVar: version versioningScheme: byEnvVar - task: DotNetCoreCLI@2 - - displayName: "Install .NET Core 2.1" + - task: DotNetCoreInstaller@0 + displayName: "Install .NET Core 2.1" inputs: version: "2.1.700" - task: DotNetCoreInstaller@0 - - displayName: "Functions Binding nuget package Sign" + - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + displayName: "Functions Binding nuget package Sign" inputs: ConnectedServiceName: "Azure IoT Edge Code Sign 2" FolderPath: $(Build.BinariesDirectory)/publish @@ -316,13 +317,12 @@ jobs: } ] signConfigType: inlineSignParams - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - - displayName: "Build iotedge-diagnostics" + - task: Bash@3 + displayName: "Build iotedge-diagnostics" inputs: arguments: "-i azureiotedge-diagnostics -n microsoft -P iotedge-diagnostics -c $(Build.Configuration)" filePath: ./scripts/linux/buildEdgelet.sh targetType: filePath - task: Bash@3 - bash: | scripts/linux/buildEdgelet.sh -i azureiotedge-diagnostics -n microsoft -P iotedge-diagnostics -c $(configuration) && scripts/linux/buildImage.sh -r $(registry.address) -u $(registry.user) -p $(registry.password) -v $(version) -i azureiotedge-diagnostics -n $(namespace) -P azureiotedge-diagnostics @@ -335,21 +335,21 @@ jobs: scripts/linux/buildEdgelet.sh -i azureiotedge-diagnostics -n microsoft -P iotedge-diagnostics -c $(configuration) --target-arch aarch64 && scripts/linux/buildImage.sh -r $(registry.address) -u $(registry.user) -p $(registry.password) -v $(version) -i azureiotedge-diagnostics -n $(namespace) -P azureiotedge-diagnostics --target-arch aarch64 displayName: 'Build Image - azureiotedge-diagnostics - ARM64' - - parameters: + - template: templates/image-linux.yaml + parameters: imageName: azureiotedge-agent name: "Edge Agent" project: Microsoft.Azure.Devices.Edge.Agent.Service - template: templates/image-linux.yaml - - parameters: + - template: templates/image-linux.yaml + parameters: imageName: azureiotedge-hub name: "Edge Hub" project: Microsoft.Azure.Devices.Edge.Hub.Service - template: templates/image-linux.yaml - - parameters: + - template: templates/image-linux.yaml + parameters: imageName: azureiotedge-simulated-temperature-sensor name: "Temperature Sensor" project: SimulatedTemperatureSensor - template: templates/image-linux.yaml variables: build.registry.address: edgebuilds.azurecr.io build.registry.user: EdgeBuilds @@ -364,23 +364,24 @@ jobs: name: Azure-IoT-Edge-Core pool: ~ steps: - - displayName: "Install .NET Core - 3.1.3" + - task: DotNetCoreInstaller@0 + displayName: "Install .NET Core - 3.1.3" inputs: version: "3.1.201" - task: DotNetCoreInstaller@0 - - displayName: "Build ($(Build.Configuration))" + - powershell: "scripts/windows/build/Publish-Branch.ps1 -Configuration:\"$(Build.Configuration)\" -PublishTests:$False -UpdateVersion" + displayName: "Build ($(Build.Configuration))" name: build - powershell: "scripts/windows/build/Publish-Branch.ps1 -Configuration:\"$(Build.Configuration)\" -PublishTests:$False -UpdateVersion" - script: | docker login $(build.registry.address) -u $(build.registry.user) -p $(build.registry.password) docker login $(registry.address) -u $(registry.user) -p $(registry.password) displayName: 'docker login' - - displayName: "Build iotedge-diagnostics" + - task: PowerShell@2 + displayName: "Build iotedge-diagnostics" inputs: filePath: ./edgelet/build/windows/build-diagnostics.ps1 targetType: filePath - task: PowerShell@2 - - displayName: "azureiotedge-diagnostics Code Sign" + - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + displayName: "azureiotedge-diagnostics Code Sign" inputs: ConnectedServiceName: "Azure IoT Edge Code Sign 2" FolderPath: $(Build.BinariesDirectory)\publish\azureiotedge-diagnostics @@ -434,8 +435,8 @@ jobs: } ] signConfigType: inlineSignParams - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - - displayName: "Edge Agent Code Sign" + - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + displayName: "Edge Agent Code Sign" inputs: ConnectedServiceName: "Azure IoT Edge Code Sign 2" FolderPath: $(Build.BinariesDirectory)\publish\Microsoft.Azure.Devices.Edge.Agent.Service @@ -489,8 +490,8 @@ jobs: } ] signConfigType: inlineSignParams - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - - displayName: "Edge Hub Code Sign" + - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + displayName: "Edge Hub Code Sign" inputs: ConnectedServiceName: "Azure IoT Edge Code Sign 2" FolderPath: $(Build.BinariesDirectory)\publish\Microsoft.Azure.Devices.Edge.Hub.Service @@ -544,8 +545,8 @@ jobs: } ] signConfigType: inlineSignParams - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - - displayName: "Temp Sensor Code Sign" + - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + displayName: "Temp Sensor Code Sign" inputs: ConnectedServiceName: "Azure IoT Edge Code Sign 2" FolderPath: $(Build.BinariesDirectory)\publish\SimulatedTemperatureSensor @@ -599,36 +600,35 @@ jobs: } ] signConfigType: inlineSignParams - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - - displayName: "Build Image - Edge Agent - amd64" + - task: PowerShell@2 + displayName: "Build Image - Edge Agent - amd64" inputs: arguments: "-Name 'azureiotedge-agent' -Project 'Microsoft.Azure.Devices.Edge.Agent.Service' -Version '$(version)' -Registry '$(registry.address)' -Namespace '$(namespace)' -Push" filePath: ./scripts/windows/build/Publish-DockerImage.ps1 targetType: filePath - task: PowerShell@2 - - displayName: "Build Image - Edge Hub - amd64" + - task: PowerShell@2 + displayName: "Build Image - Edge Hub - amd64" inputs: arguments: "-Name 'azureiotedge-hub' -Project 'Microsoft.Azure.Devices.Edge.Hub.Service' -Version '$(version)' -Registry '$(registry.address)' -Namespace '$(namespace)' -Push" filePath: ./scripts/windows/build/Publish-DockerImage.ps1 targetType: filePath - task: PowerShell@2 - - displayName: "Build Image - Temp Sensor - amd64" + - task: PowerShell@2 + displayName: "Build Image - Temp Sensor - amd64" inputs: arguments: "-Name 'azureiotedge-simulated-temperature-sensor' -Project 'SimulatedTemperatureSensor' -Version '$(version)' -Registry '$(registry.address)' -Namespace '$(namespace)' -Push" filePath: ./scripts/windows/build/Publish-DockerImage.ps1 targetType: filePath - task: PowerShell@2 - - displayName: "Build Image - azureiotedge-diagnostics - amd64" + - task: PowerShell@2 + displayName: "Build Image - azureiotedge-diagnostics - amd64" inputs: arguments: "-Name 'azureiotedge-diagnostics' -Project 'azureiotedge-diagnostics' -Version '$(version)' -Registry '$(registry.address)' -Namespace '$(namespace)' -Push" filePath: ./scripts/windows/build/Publish-DockerImage.ps1 targetType: filePath - task: PowerShell@2 - - displayName: "Publish Artifacts to VSTS" + - task: PublishBuildArtifacts@1 + displayName: "Publish Artifacts to VSTS" inputs: ArtifactName: publish-win PathtoPublish: $(Build.BinariesDirectory)\publish - task: PublishBuildArtifacts@1 variables: build.registry.address: edgebuilds.azurecr.io build.registry.user: EdgeBuilds From 327ecf90406ca8ca201dfd1ff5c0797931695de7 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 28 Apr 2020 17:05:17 -0700 Subject: [PATCH 004/111] fix build images release yaml --- builds/misc/images-release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builds/misc/images-release.yaml b/builds/misc/images-release.yaml index 79de8b4a3c3..073df2192e0 100644 --- a/builds/misc/images-release.yaml +++ b/builds/misc/images-release.yaml @@ -355,12 +355,12 @@ jobs: build.registry.user: EdgeBuilds registry.address: edgerelease.azurecr.io registry.user: EdgeRelease - - demands: + - job: windows + demands: - "Build-Image -equals true" - win-rs5 - DotNetFramework displayName: Windows - job: windows name: Azure-IoT-Edge-Core pool: ~ steps: From c6493b19df86c9ec664a0d3c5eeb2ba0ac3ed0bc Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 28 Apr 2020 17:38:06 -0700 Subject: [PATCH 005/111] fix yaml --- builds/misc/images-release.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/builds/misc/images-release.yaml b/builds/misc/images-release.yaml index 073df2192e0..50956099c92 100644 --- a/builds/misc/images-release.yaml +++ b/builds/misc/images-release.yaml @@ -356,13 +356,13 @@ jobs: registry.address: edgerelease.azurecr.io registry.user: EdgeRelease - job: windows - demands: - - "Build-Image -equals true" - - win-rs5 - - DotNetFramework displayName: Windows - name: Azure-IoT-Edge-Core - pool: ~ + pool: + name: Azure-IoT-Edge-Core + demands: + - "Build-Image -equals true" + - win-rs5 + - DotNetFramework steps: - task: DotNetCoreInstaller@0 displayName: "Install .NET Core - 3.1.3" From 9b05e349ad90ea9c6cbed85c7e948ff5b76df92e Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 29 Apr 2020 12:04:26 -0700 Subject: [PATCH 006/111] replace adapter pattern --- .../HttpsExtensionConnectionAdapter.cs | 287 ------------------ .../Extensions/ListenOptionsExtensions.cs | 16 - ...crosoft.Azure.Devices.Edge.Hub.Http.csproj | 11 +- .../Hosting.cs | 2 +- 4 files changed, 5 insertions(+), 311 deletions(-) delete mode 100644 edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Adapters/HttpsExtensionConnectionAdapter.cs delete mode 100644 edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/ListenOptionsExtensions.cs diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Adapters/HttpsExtensionConnectionAdapter.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Adapters/HttpsExtensionConnectionAdapter.cs deleted file mode 100644 index 371f0a1a2a0..00000000000 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Adapters/HttpsExtensionConnectionAdapter.cs +++ /dev/null @@ -1,287 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -namespace Microsoft.Azure.Devices.Edge.Hub.Http.Adapters -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.IO; - using System.Linq; - using System.Net.Security; - using System.Security.Cryptography; - using System.Security.Cryptography.X509Certificates; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.AspNetCore.Http.Features; - using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal; - using Microsoft.AspNetCore.Server.Kestrel.Https; - using Microsoft.Azure.Devices.Edge.Hub.Http.Extensions; - using Microsoft.Azure.Devices.Edge.Util; - using Microsoft.Extensions.Logging; - - // https://github.com/aspnet/HttpAbstractions/issues/808 - public class HttpsExtensionConnectionAdapter : IConnectionAdapter - { - internal const string DisableHandshakeTimeoutSwitch = "Switch.Microsoft.AspNetCore.Server.Kestrel.Https.DisableHandshakeTimeout"; - - // See http://oid-info.com/get/1.3.6.1.5.5.7.3.1 - // Indicates that a certificate can be used as a SSL server certificate - const string ServerAuthenticationOid = "1.3.6.1.5.5.7.3.1"; - static readonly TimeSpan HandshakeTimeout = TimeSpan.FromSeconds(10); - static readonly ClosedAdaptedConnection ClosedAdaptedConnectionInstance = new ClosedAdaptedConnection(); - readonly HttpsConnectionAdapterOptions options; - readonly X509Certificate2 serverCertificate; - - public HttpsExtensionConnectionAdapter(HttpsConnectionAdapterOptions options) - { - this.options = Preconditions.CheckNotNull(options, nameof(options)); - this.serverCertificate = Preconditions.CheckNotNull(options.ServerCertificate, nameof(options.ServerCertificate)); - EnsureCertificateIsAllowedForServerAuth(this.serverCertificate); - } - - public bool IsHttps => true; - - public Task OnConnectionAsync(ConnectionAdapterContext context) => - Task.Run(() => this.InnerOnConnectionAsync(context)); - - static void EnsureCertificateIsAllowedForServerAuth(X509Certificate2 certificate) - { - /* If the Extended Key Usage extension is included, then we check that the serverAuth usage is included. (http://oid-info.com/get/1.3.6.1.5.5.7.3.1) - * If the Extended Key Usage extension is not included, then we assume the certificate is allowed for all usages. - * - * See also https://blogs.msdn.microsoft.com/kaushal/2012/02/17/client-certificates-vs-server-certificates/ - * - * From https://tools.ietf.org/html/rfc3280#section-4.2.1.13 "Certificate Extensions: Extended Key Usage" - * - * If the (Extended Key Usage) extension is present, then the certificate MUST only be used - * for one of the purposes indicated. If multiple purposes are - * indicated the application need not recognize all purposes indicated, - * as long as the intended purpose is present. Certificate using - * applications MAY require that a particular purpose be indicated in - * order for the certificate to be acceptable to that application. - */ - - bool hasEkuExtension = false; - - foreach (X509EnhancedKeyUsageExtension extension in certificate.Extensions.OfType()) - { - hasEkuExtension = true; - foreach (Oid oid in extension.EnhancedKeyUsages) - { - if (oid.Value.Equals(ServerAuthenticationOid, StringComparison.Ordinal)) - { - return; - } - } - } - - if (hasEkuExtension) - { - throw new InvalidOperationException("InvalidServerCertificateEku"); - } - } - - static void ObserveTaskException(Task task) => _ = task.ContinueWith(t => _ = t.Exception, TaskScheduler.Current); - - async Task InnerOnConnectionAsync(ConnectionAdapterContext context) - { - SslStream sslStream; - bool certificateRequired; - - IList chainElements = new List(); - - if (this.options.ClientCertificateMode == ClientCertificateMode.NoCertificate) - { - sslStream = new SslStream(context.ConnectionStream); - certificateRequired = false; - } - else - { - sslStream = new SslStream( - context.ConnectionStream, - leaveInnerStreamOpen: false, - userCertificateValidationCallback: (sender, certificate, chain, sslPolicyErrors) => - { - if (certificate == null) - { - return this.options.ClientCertificateMode != ClientCertificateMode.RequireCertificate; - } - - if (this.options.ClientCertificateValidation == null) - { - if (sslPolicyErrors != SslPolicyErrors.None) - { - return false; - } - } - else if (!this.options.ClientCertificateValidation(new X509Certificate2(certificate), chain, sslPolicyErrors)) - { - return false; - } - - foreach (X509ChainElement element in chain.ChainElements) - { - chainElements.Add(element.Certificate); - } - - return true; - }); - - certificateRequired = true; - } - - try - { - if (AppContext.TryGetSwitch(DisableHandshakeTimeoutSwitch, out bool handshakeDisabled) && handshakeDisabled) - { - await sslStream.AuthenticateAsServerAsync( - this.serverCertificate, - certificateRequired, - this.options.SslProtocols, - this.options.CheckCertificateRevocation); - } - else - { - try - { - Task handshakeTask = sslStream.AuthenticateAsServerAsync( - this.serverCertificate, - certificateRequired, - this.options.SslProtocols, - this.options.CheckCertificateRevocation); - Task handshakeTimeoutTask = Task.Delay(HandshakeTimeout); - - Task firstTask = await Task.WhenAny(handshakeTask, handshakeTimeoutTask); - - if (firstTask == handshakeTimeoutTask) - { - Events.AuthenticationTimedOut(); - - // Observe any exception that might be raised from AuthenticateAsServerAsync after the timeout. - ObserveTaskException(handshakeTask); - - // This will cause the request processing loop to exit immediately and close the underlying connection. - sslStream.Dispose(); - return ClosedAdaptedConnectionInstance; - } - - // Observe potential handshake failures. - await handshakeTask; - } - catch (OperationCanceledException) - { - Events.AuthenticationTimedOut(); - sslStream.Dispose(); - return ClosedAdaptedConnectionInstance; - } - } - } - catch (Exception) - { - Events.AuthenticationFailed(); - sslStream.Dispose(); - return ClosedAdaptedConnectionInstance; - } - - Events.AuthenticationSuccess(); - - // Always set the feature even though the cert might be null - X509Certificate2 cert = sslStream.RemoteCertificate != null ? new X509Certificate2(sslStream.RemoteCertificate) : null; - - context.Features.Set( - new TlsConnectionFeature - { - ClientCertificate = cert - }); - - context.Features.Set( - new TlsConnectionFeatureExtended - { - ChainElements = chainElements - }); - - return new HttpsAdaptedConnection(sslStream); - } - - internal class ClosedStream : Stream - { - static readonly Task ZeroResultTask = Task.FromResult(result: 0); - - public override bool CanRead => true; - - public override bool CanSeek => false; - - public override bool CanWrite => false; - - public override long Length - { - get { throw new NotSupportedException(); } - } - - public override long Position - { - get { throw new NotSupportedException(); } - set { throw new NotSupportedException(); } - } - - public override void Flush() - { - } - - public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException(); - - public override void SetLength(long value) => throw new NotSupportedException(); - - public override int Read(byte[] buffer, int offset, int count) => 0; - - public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) => ZeroResultTask; - - public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException(); - } - - class ClosedAdaptedConnection : IAdaptedConnection - { - public Stream ConnectionStream { get; } = new ClosedStream(); - - [SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", Justification = "Field does not need to be disposed.")] - public void Dispose() - { - } - } - - static class Events - { - const int IdStart = HttpEventIds.HttpsExtensionConnectionAdapter; - static readonly ILogger Log = Logger.Factory.CreateLogger(); - - enum EventIds - { - AuthenticationTimedOut = IdStart, - AuthenticationFailed, - AuthenticationSuccess - } - - public static void AuthenticationTimedOut() => - Log.LogInformation((int)EventIds.AuthenticationTimedOut, "HttpExtensionConnectionAdapter authentication timeout"); - - public static void AuthenticationFailed() => - Log.LogInformation((int)EventIds.AuthenticationFailed, "HttpExtensionConnectionAdapter authentication failed"); - - public static void AuthenticationSuccess() => - Log.LogDebug((int)EventIds.AuthenticationSuccess, "HttpExtensionConnectionAdapter authentication succeeded"); - } - - class HttpsAdaptedConnection : IAdaptedConnection - { - readonly SslStream sslStream; - - public HttpsAdaptedConnection(SslStream sslStream) - { - this.sslStream = sslStream; - } - - public Stream ConnectionStream => this.sslStream; - - public void Dispose() => this.sslStream.Dispose(); - } - } -} diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/ListenOptionsExtensions.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/ListenOptionsExtensions.cs deleted file mode 100644 index ca16daab319..00000000000 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/ListenOptionsExtensions.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -namespace Microsoft.Azure.Devices.Edge.Hub.Http.Extensions -{ - using Microsoft.AspNetCore.Server.Kestrel.Core; - using Microsoft.AspNetCore.Server.Kestrel.Https; - using Microsoft.Azure.Devices.Edge.Hub.Http.Adapters; - - public static class ListenOptionsExtensions - { - public static ListenOptions UseHttpsExtensions(this ListenOptions options, HttpsConnectionAdapterOptions httpsOptions) - { - options.ConnectionAdapters.Add(new HttpsExtensionConnectionAdapter(httpsOptions)); - return options; - } - } -} diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj index 906be687193..ab29d1f3dd4 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj @@ -9,13 +9,10 @@ - - - - - - - + + + + diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index be482b81aa7..1a2d4e16843 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -47,7 +47,7 @@ public static Hosting Initialize( port, listenOptions => { - listenOptions.UseHttpsExtensions( + listenOptions.UseHttps( new HttpsConnectionAdapterOptions() { ServerCertificate = serverCertificate, From 260b6544911c22b17338895030771ec7183fbb30 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 29 Apr 2020 15:12:58 -0700 Subject: [PATCH 007/111] fix twin controller tests --- .../DefaultHttpResponse.cs | 186 ++++++++++++++++++ .../HttpsExtensionConnectionAdapterTest.cs | 78 -------- .../TwinsControllerTest.cs | 7 +- 3 files changed, 189 insertions(+), 82 deletions(-) create mode 100644 edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/DefaultHttpResponse.cs delete mode 100644 edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/HttpsExtensionConnectionAdapterTest.cs diff --git a/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/DefaultHttpResponse.cs b/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/DefaultHttpResponse.cs new file mode 100644 index 00000000000..04bc3d2d15b --- /dev/null +++ b/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/DefaultHttpResponse.cs @@ -0,0 +1,186 @@ +// Copyright (c) Microsoft. All rights reserved. +// This file isn't generated, but this comment is necessary to exclude it from StyleCop analysis. +// Taken from aspnetcore 3.1.3 release: https://github.com/dotnet/aspnetcore/blob/e81033e094d4663ffd227bb4aed30b76b0631e6d/src/Http/Http/src/Internal/DefaultHttpResponse.cs +// +namespace Microsoft.Azure.Devices.Edge.Hub.Http.Test +{ + using System; + using System.IO; + using System.IO.Pipelines; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Http; + using Microsoft.AspNetCore.Http.Features; + using Microsoft.Net.Http.Headers; + + internal sealed class DefaultHttpResponse : HttpResponse + { + // Lambdas hoisted to static readonly fields to improve inlining https://github.com/dotnet/roslyn/issues/13624 + private readonly static Func _nullResponseFeature = f => null; + private readonly static Func _nullResponseBodyFeature = f => null; + private readonly static Func _newResponseCookiesFeature = f => new ResponseCookiesFeature(f); + + private readonly DefaultHttpContext _context; + private FeatureReferences _features; + + public DefaultHttpResponse(DefaultHttpContext context) + { + _context = context; + _features.Initalize(context.Features); + } + + public void Initialize() + { + _features.Initalize(_context.Features); + } + + public void Initialize(int revision) + { + _features.Initalize(_context.Features, revision); + } + + public void Uninitialize() + { + _features = default; + } + + private IHttpResponseFeature HttpResponseFeature => + _features.Fetch(ref _features.Cache.Response, _nullResponseFeature); + + private IHttpResponseBodyFeature HttpResponseBodyFeature => + _features.Fetch(ref _features.Cache.ResponseBody, _nullResponseBodyFeature); + + private IResponseCookiesFeature ResponseCookiesFeature => + _features.Fetch(ref _features.Cache.Cookies, _newResponseCookiesFeature); + + public override HttpContext HttpContext { get { return _context; } } + + public override int StatusCode + { + get { return HttpResponseFeature.StatusCode; } + set { HttpResponseFeature.StatusCode = value; } + } + + public override IHeaderDictionary Headers + { + get { return HttpResponseFeature.Headers; } + } + + public override Stream Body + { + get { return HttpResponseBodyFeature.Stream; } + set + { + var otherFeature = _features.Collection.Get(); + if (otherFeature is StreamResponseBodyFeature streamFeature + && streamFeature.PriorFeature != null + && object.ReferenceEquals(value, streamFeature.PriorFeature.Stream)) + { + // They're reverting the stream back to the prior one. Revert the whole feature. + _features.Collection.Set(streamFeature.PriorFeature); + // CompleteAsync is registered with HttpResponse.OnCompleted and there's no way to unregister it. + // Prevent it from running by marking as disposed. + streamFeature.Dispose(); + return; + } + + var feature = new StreamResponseBodyFeature(value, otherFeature); + OnCompleted(feature.CompleteAsync); + _features.Collection.Set(feature); + } + } + + public override long? ContentLength + { + get { return Headers.ContentLength; } + set { Headers.ContentLength = value; } + } + + public override string ContentType + { + get + { + return Headers[HeaderNames.ContentType]; + } + set + { + if (string.IsNullOrEmpty(value)) + { + HttpResponseFeature.Headers.Remove(HeaderNames.ContentType); + } + else + { + HttpResponseFeature.Headers[HeaderNames.ContentType] = value; + } + } + } + + public override IResponseCookies Cookies + { + get { return ResponseCookiesFeature.Cookies; } + } + + public override bool HasStarted + { + get { return HttpResponseFeature.HasStarted; } + } + + public override PipeWriter BodyWriter + { + get { return HttpResponseBodyFeature.Writer; } + } + + public override void OnStarting(Func callback, object state) + { + if (callback == null) + { + throw new ArgumentNullException(nameof(callback)); + } + + HttpResponseFeature.OnStarting(callback, state); + } + + public override void OnCompleted(Func callback, object state) + { + if (callback == null) + { + throw new ArgumentNullException(nameof(callback)); + } + + HttpResponseFeature.OnCompleted(callback, state); + } + + public override void Redirect(string location, bool permanent) + { + if (permanent) + { + HttpResponseFeature.StatusCode = 301; + } + else + { + HttpResponseFeature.StatusCode = 302; + } + + Headers[HeaderNames.Location] = location; + } + + public override Task StartAsync(CancellationToken cancellationToken = default) + { + if (HasStarted) + { + return Task.CompletedTask; + } + + return HttpResponseBodyFeature.StartAsync(cancellationToken); + } + + public override Task CompleteAsync() => HttpResponseBodyFeature.CompleteAsync(); + + struct FeatureInterfaces + { + public IHttpResponseFeature Response; + public IHttpResponseBodyFeature ResponseBody; + public IResponseCookiesFeature Cookies; + } + } +} \ No newline at end of file diff --git a/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/HttpsExtensionConnectionAdapterTest.cs b/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/HttpsExtensionConnectionAdapterTest.cs deleted file mode 100644 index aea071282da..00000000000 --- a/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/HttpsExtensionConnectionAdapterTest.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -namespace Microsoft.Azure.Devices.Edge.Hub.Http.Test -{ - using System; - using Microsoft.AspNetCore.Server.Kestrel.Https; - using Microsoft.Azure.Devices.Edge.Hub.Http.Adapters; - using Microsoft.Azure.Devices.Edge.Util.Test.Common; - using Xunit; - using TestCertificateHelper = Microsoft.Azure.Devices.Edge.Util.Test.Common.CertificateHelper; - - [Unit] - public class HttpsExtensionConnectionAdapterTest - { - [Fact] - public void HttpsExtensionConnectionAdapterTestInvalidInput_Fails() - { - Assert.Throws(() => new HttpsExtensionConnectionAdapter(null)); - } - - [Fact] - public void HttpsExtensionConnectionAdapterTestInvalidOptions_Fails() - { - var options = new HttpsConnectionAdapterOptions() - { - ServerCertificate = null - }; - Assert.Throws(() => new HttpsExtensionConnectionAdapter(options)); - } - - [Fact] - public void HttpsExtensionConnectionAdapterTestValidCertWithNoEku_Succeeds() - { - var cert = TestCertificateHelper.GenerateSelfSignedCert("no eku"); - var options = new HttpsConnectionAdapterOptions() - { - ServerCertificate = cert - }; - - Assert.NotNull(new HttpsExtensionConnectionAdapter(options)); - } - - [Fact] - public void HttpsExtensionConnectionAdapterTestValidCertWithEkuServer_Succeeds() - { - var (cert, key) = TestCertificateHelper.GenerateServerCert("eku server auth", DateTime.Now.Subtract(TimeSpan.FromDays(2)), DateTime.Now.AddYears(1)); - var options = new HttpsConnectionAdapterOptions() - { - ServerCertificate = cert - }; - - Assert.NotNull(new HttpsExtensionConnectionAdapter(options)); - } - - [Fact] - public void HttpsExtensionConnectionAdapterTestValidCertWithEkuClient_Fails() - { - var (cert, key) = TestCertificateHelper.GenerateClientert("eku client auth", DateTime.Now.Subtract(TimeSpan.FromDays(2)), DateTime.Now.AddYears(1)); - var options = new HttpsConnectionAdapterOptions() - { - ServerCertificate = cert - }; - - Assert.Throws(() => new HttpsExtensionConnectionAdapter(options)); - } - - [Fact] - public void IsHttpsAlwaysTrue() - { - var server = TestCertificateHelper.GenerateSelfSignedCert("test server"); - var options = new HttpsConnectionAdapterOptions() - { - ServerCertificate = server - }; - var ext = new HttpsExtensionConnectionAdapter(options); - Assert.True(ext.IsHttps); - } - } -} diff --git a/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/TwinsControllerTest.cs b/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/TwinsControllerTest.cs index 62f2b2fb9fc..5304b4724a1 100644 --- a/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/TwinsControllerTest.cs +++ b/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/TwinsControllerTest.cs @@ -8,7 +8,6 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Http.Test using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; - using Microsoft.AspNetCore.Http.Internal; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Mvc.Filters; @@ -205,10 +204,10 @@ private static void SetupControllerContext(Controller controller) var httpContext = new DefaultHttpContext(); var httpResponse = new DefaultHttpResponse(httpContext); httpResponse.Body = new MemoryStream(); - var controllerContex = new ControllerContext(); - controllerContex.HttpContext = httpContext; + var controllerContext = new ControllerContext(); + controllerContext.HttpContext = httpContext; - controller.ControllerContext = controllerContex; + controller.ControllerContext = controllerContext; } private static Task CreateEdgeHubGetter(string id, DirectMethodResponse directMethodResponse) From 431390aabcf80baa384f485297341ceb2dd6bcc4 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 29 Apr 2020 15:33:30 -0700 Subject: [PATCH 008/111] temproarily disable diagnostics --- builds/misc/images.yaml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/builds/misc/images.yaml b/builds/misc/images.yaml index 581399c1504..6f1f03666d8 100644 --- a/builds/misc/images.yaml +++ b/builds/misc/images.yaml @@ -212,8 +212,8 @@ jobs: name: build displayName: Build ($(Build.Configuration)) - - powershell: edgelet/build/windows/build-diagnostics.ps1 -BuildConfiguration $(Build.Configuration) - displayName: Build iotedge-diagnostics + # - powershell: edgelet/build/windows/build-diagnostics.ps1 -BuildConfiguration $(Build.Configuration) + # displayName: Build iotedge-diagnostics - powershell: scripts/windows/build/Create-ArtifactInfo.ps1 -outputFolder '$(Build.BinariesDirectory)/publish' -buildNumber $(Build.BuildNumber) displayName: 'Create Artifact Info File' @@ -224,12 +224,12 @@ jobs: PathtoPublish: '$(Build.BinariesDirectory)/publish' ArtifactName: 'core-windows' - # azureiotedge-diagnostics - - template: templates/image-windows.yaml - parameters: - name: azureiotedge-diagnostics - imageName: azureiotedge-diagnostics - project: azureiotedge-diagnostics + # # azureiotedge-diagnostics + # - template: templates/image-windows.yaml + # parameters: + # name: azureiotedge-diagnostics + # imageName: azureiotedge-diagnostics + # project: azureiotedge-diagnostics # Edge Agent - template: templates/image-windows.yaml @@ -383,7 +383,7 @@ jobs: displayName: 'Publish Temperature Sensor Manifest' - script: scripts/linux/buildManifest.sh -r $(registry.address) -u $(registry.user) -p $(registry.password) -v $(Build.BuildNumber) -t $(System.DefaultWorkingDirectory)/edgelet/iotedged/docker/manifest.yaml.template -n microsoft --tags "$(tags)" displayName: 'Publish azureiotedge-iotedged Manifest' - - script: scripts/linux/buildManifest.sh -r $(registry.address) -u $(registry.user) -p $(registry.password) -v $(Build.BuildNumber) -t $(System.DefaultWorkingDirectory)/edgelet/iotedge-diagnostics/docker/manifest.yaml.template -n microsoft --tags "$(tags)" - displayName: 'Publish azureiotedge-diagnostics Manifest' + # - script: scripts/linux/buildManifest.sh -r $(registry.address) -u $(registry.user) -p $(registry.password) -v $(Build.BuildNumber) -t $(System.DefaultWorkingDirectory)/edgelet/iotedge-diagnostics/docker/manifest.yaml.template -n microsoft --tags "$(tags)" + # displayName: 'Publish azureiotedge-diagnostics Manifest' - script: scripts/linux/buildManifest.sh -r $(registry.address) -u $(registry.user) -p $(registry.password) -v $(Build.BuildNumber) -t $(System.DefaultWorkingDirectory)/edgelet/iotedge-proxy/docker/manifest.yaml.template -n microsoft --tags "$(tags)" displayName: 'Publish azureiotedge-proxy Manifest' From e0308cc4beea98f34cc0b977492030630548a880 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 29 Apr 2020 16:27:42 -0700 Subject: [PATCH 009/111] remove IStartup --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 2 +- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 1a2d4e16843..5ffb7b7b12f 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -67,7 +67,7 @@ public static Hosting Initialize( .UseStartup(); }).Build(); - IContainer container = host.Services.GetService(typeof(IStartup)) is Startup startup ? startup.Container : null; + IContainer container = host.Services.GetService(typeof(Startup)) is Startup startup ? startup.Container : null; return new Hosting(host, container); } } diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index f9be25e818b..26b22542cc8 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -15,7 +15,7 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; - public class Startup : IStartup + public class Startup { readonly IDependencyManager dependencyManager; readonly IConfigurationRoot configuration; @@ -87,7 +87,7 @@ IContainer BuildContainer(IServiceCollection services) var builder = new ContainerBuilder(); builder.Populate(services); this.dependencyManager.Register(builder); - builder.RegisterInstance(this); + builder.RegisterInstance(this); return builder.Build(); } From fb74925ce35213bdd5c964a2e4e16d50dcbbef58 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 29 Apr 2020 21:02:51 -0700 Subject: [PATCH 010/111] refactor hosting startup --- .../DependencyManager.cs | 2 +- .../Hosting.cs | 4 +- .../Startup2.cs | 84 +++++++++++++++++++ .../{Startup.cs => StartupDeprecated.cs} | 6 +- 4 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup2.cs rename edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/{Startup.cs => StartupDeprecated.cs} (96%) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/DependencyManager.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/DependencyManager.cs index 3f94c903741..75e35b83c7d 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/DependencyManager.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/DependencyManager.cs @@ -22,7 +22,7 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service using Microsoft.Extensions.Logging; using StorageLogLevel = Microsoft.Azure.Devices.Edge.Storage.StorageLogLevel; - class DependencyManager : IDependencyManager + public class DependencyManager : IDependencyManager { readonly IConfigurationRoot configuration; readonly X509Certificate2 serverCertificate; diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 5ffb7b7b12f..cc42103a392 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -64,10 +64,10 @@ public static Hosting Initialize( serviceCollection.AddSingleton(configuration); serviceCollection.AddSingleton(dependencyManager); }) - .UseStartup(); + .UseStartup(); }).Build(); - IContainer container = host.Services.GetService(typeof(Startup)) is Startup startup ? startup.Container : null; + IContainer container = host.Services.GetService(typeof(Startup2)) is Startup2 startup ? startup.Container : null; return new Hosting(host, container); } } diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup2.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup2.cs new file mode 100644 index 00000000000..d4a232a4151 --- /dev/null +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup2.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft. All rights reserved. +namespace Microsoft.Azure.Devices.Edge.Hub.Service +{ + using System; + using Autofac; + using Autofac.Extensions.DependencyInjection; + using Microsoft.AspNetCore.Builder; + using Microsoft.AspNetCore.Hosting; + using Microsoft.AspNetCore.Mvc; + using Microsoft.Azure.Devices.Client; + using Microsoft.Azure.Devices.Edge.Hub.Core; + using Microsoft.Azure.Devices.Edge.Hub.Http; + using Microsoft.Azure.Devices.Edge.Hub.Http.Middleware; + using Microsoft.Azure.Devices.Edge.Util; + using Microsoft.Extensions.Configuration; + using Microsoft.Extensions.DependencyInjection; + + public class Startup2 + { + readonly IConfigurationRoot configuration; + + // ReSharper disable once UnusedParameter.Local + public Startup2(IConfigurationRoot configuration) + { + this.configuration = Preconditions.CheckNotNull(configuration, nameof(configuration)); + } + + internal IContainer Container { get; private set; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddMemoryCache(); + services.AddControllers(options => options.Filters.Add(typeof(ExceptionFilter))); + services.Configure(options => { options.Filters.Add(new RequireHttpsAttribute()); }); + } + + public void ConfigureContainer(ContainerBuilder builder, DependencyManager dependencyManager) + { + dependencyManager.Register(builder); + builder.RegisterInstance(this); + } + + public void Configure(IApplicationBuilder app) + { + app.UseRouting(); + + app.UseWebSockets(); + + var webSocketListenerRegistry = app.ApplicationServices.GetService(typeof(IWebSocketListenerRegistry)) as IWebSocketListenerRegistry; + app.UseWebSocketHandlingMiddleware(webSocketListenerRegistry); + + string edgeHubConnectionString = this.configuration.GetValue(Constants.ConfigKey.IotHubConnectionString); + string iotHubHostname; + string edgeDeviceId; + if (!string.IsNullOrWhiteSpace(edgeHubConnectionString)) + { + IotHubConnectionStringBuilder iotHubConnectionStringBuilder = IotHubConnectionStringBuilder.Create(edgeHubConnectionString); + iotHubHostname = iotHubConnectionStringBuilder.HostName; + edgeDeviceId = iotHubConnectionStringBuilder.DeviceId; + } + else + { + iotHubHostname = this.configuration.GetValue(Constants.ConfigKey.IotHubHostname); + edgeDeviceId = this.configuration.GetValue(Constants.ConfigKey.DeviceId); + } + + app.UseAuthenticationMiddleware(iotHubHostname, edgeDeviceId); + + app.Use( + async (context, next) => + { + // Response header is added to prevent MIME type sniffing + context.Response.Headers.Add("X-Content-Type-Options", "nosniff"); + await next(); + }); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/StartupDeprecated.cs similarity index 96% rename from edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs rename to edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/StartupDeprecated.cs index 26b22542cc8..9d2d9523fc8 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/StartupDeprecated.cs @@ -15,13 +15,13 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; - public class Startup + public class StartupDeprecated { readonly IDependencyManager dependencyManager; readonly IConfigurationRoot configuration; // ReSharper disable once UnusedParameter.Local - public Startup( + public StartupDeprecated( IConfigurationRoot configuration, IDependencyManager dependencyManager) { @@ -87,7 +87,7 @@ IContainer BuildContainer(IServiceCollection services) var builder = new ContainerBuilder(); builder.Populate(services); this.dependencyManager.Register(builder); - builder.RegisterInstance(this); + builder.RegisterInstance(this); return builder.Build(); } From 6fd3a79c0d9296a1f1fa7c6b88d3916e1b52720b Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 29 Apr 2020 21:32:34 -0700 Subject: [PATCH 011/111] refactor base images to accomodate network controller --- .../modules/NetworkController/docker/linux/arm32v7/Dockerfile | 2 +- .../NetworkController/docker/linux/arm32v7/base/Dockerfile | 4 ---- test/modules/TestAnalyzer/docker/linux/arm32v7/Dockerfile | 2 +- .../modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile | 2 ++ test/modules/TestAnalyzer/docker/linux/arm64v8/Dockerfile | 2 +- .../TestResultCoordinator/docker/linux/arm32v7/Dockerfile | 2 +- .../TestResultCoordinator/docker/linux/arm64v8/Dockerfile | 2 +- 7 files changed, 7 insertions(+), 9 deletions(-) delete mode 100644 test/connectivity/modules/NetworkController/docker/linux/arm32v7/base/Dockerfile diff --git a/test/connectivity/modules/NetworkController/docker/linux/arm32v7/Dockerfile b/test/connectivity/modules/NetworkController/docker/linux/arm32v7/Dockerfile index 1e592f300ba..ab84239a93c 100644 --- a/test/connectivity/modules/NetworkController/docker/linux/arm32v7/Dockerfile +++ b/test/connectivity/modules/NetworkController/docker/linux/arm32v7/Dockerfile @@ -1,5 +1,5 @@ ARG base_tag=1.0.0-linux-arm32v7 -FROM azureiotedge/azureiotedge-networkcontroller-module-base:${base_tag} +FROM azureiotedge/azureiotedge-module-base-full:${base_tag} ARG EXE_DIR=. diff --git a/test/connectivity/modules/NetworkController/docker/linux/arm32v7/base/Dockerfile b/test/connectivity/modules/NetworkController/docker/linux/arm32v7/base/Dockerfile deleted file mode 100644 index 837a6b5a5e1..00000000000 --- a/test/connectivity/modules/NetworkController/docker/linux/arm32v7/base/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -ARG base_tag=3.1.2-bionic-arm32v7 -FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} - -RUN apt-get update && apt-get install -y --no-install-recommends iproute2 net-tools \ No newline at end of file diff --git a/test/modules/TestAnalyzer/docker/linux/arm32v7/Dockerfile b/test/modules/TestAnalyzer/docker/linux/arm32v7/Dockerfile index d51af17f2cc..fa5d1633060 100644 --- a/test/modules/TestAnalyzer/docker/linux/arm32v7/Dockerfile +++ b/test/modules/TestAnalyzer/docker/linux/arm32v7/Dockerfile @@ -1,5 +1,5 @@ ARG base_tag=1.0.5-linux-arm32v7 -FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-rocksdb-aspnet:${base_tag} +FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-full:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile b/test/modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile index b471299c69a..9e4e4918fb3 100644 --- a/test/modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile +++ b/test/modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile @@ -8,6 +8,8 @@ RUN apt-get update && apt-get install -y libcap2-bin libsnappy1v5 && \ COPY librocksdb.so /usr/lib/ +RUN apt-get update && apt-get install -y --no-install-recommends iproute2 net-tools + # Add an unprivileged user account for running the module RUN useradd -ms /bin/bash moduleuser USER moduleuser diff --git a/test/modules/TestAnalyzer/docker/linux/arm64v8/Dockerfile b/test/modules/TestAnalyzer/docker/linux/arm64v8/Dockerfile index 8ca3689632a..5c2f25fa189 100644 --- a/test/modules/TestAnalyzer/docker/linux/arm64v8/Dockerfile +++ b/test/modules/TestAnalyzer/docker/linux/arm64v8/Dockerfile @@ -1,5 +1,5 @@ ARG base_tag=1.0.5-linux-arm64v8 -FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-rocksdb-aspnet:${base_tag} +FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-full:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TestResultCoordinator/docker/linux/arm32v7/Dockerfile b/test/modules/TestResultCoordinator/docker/linux/arm32v7/Dockerfile index 35b37f3cdd5..6c736f91537 100644 --- a/test/modules/TestResultCoordinator/docker/linux/arm32v7/Dockerfile +++ b/test/modules/TestResultCoordinator/docker/linux/arm32v7/Dockerfile @@ -1,5 +1,5 @@ ARG base_tag=1.0.5-linux-arm32v7 -FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-rocksdb-aspnet:${base_tag} +FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-full:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TestResultCoordinator/docker/linux/arm64v8/Dockerfile b/test/modules/TestResultCoordinator/docker/linux/arm64v8/Dockerfile index 5612c036c43..9e7d7c80ff6 100644 --- a/test/modules/TestResultCoordinator/docker/linux/arm64v8/Dockerfile +++ b/test/modules/TestResultCoordinator/docker/linux/arm64v8/Dockerfile @@ -1,5 +1,5 @@ ARG base_tag=1.0.5-linux-arm64v8 -FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-rocksdb-aspnet:${base_tag} +FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-full:${base_tag} ARG EXE_DIR=. From af54b46c87b482011e51115c93c52de04999fd5a Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 29 Apr 2020 22:46:06 -0700 Subject: [PATCH 012/111] use fixed args for startup --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup2.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup2.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup2.cs index d4a232a4151..a4280dc5b12 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup2.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup2.cs @@ -17,10 +17,10 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service public class Startup2 { - readonly IConfigurationRoot configuration; + readonly IConfiguration configuration; // ReSharper disable once UnusedParameter.Local - public Startup2(IConfigurationRoot configuration) + public Startup2(IConfiguration configuration) { this.configuration = Preconditions.CheckNotNull(configuration, nameof(configuration)); } From 4f78be8e54a2f207de5c015d4e787be8b32f6334 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 30 Apr 2020 09:58:28 -0700 Subject: [PATCH 013/111] fix network controller base image --- .../modules/NetworkController/docker/linux/arm32v7/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/connectivity/modules/NetworkController/docker/linux/arm32v7/Dockerfile b/test/connectivity/modules/NetworkController/docker/linux/arm32v7/Dockerfile index ab84239a93c..f54d286dd35 100644 --- a/test/connectivity/modules/NetworkController/docker/linux/arm32v7/Dockerfile +++ b/test/connectivity/modules/NetworkController/docker/linux/arm32v7/Dockerfile @@ -1,5 +1,5 @@ ARG base_tag=1.0.0-linux-arm32v7 -FROM azureiotedge/azureiotedge-module-base-full:${base_tag} +FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-full:${base_tag} ARG EXE_DIR=. From 2cf918caafaf63215d0bcf3d37d51b3b50b56e15 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 30 Apr 2020 10:41:50 -0700 Subject: [PATCH 014/111] fix network controller base image tag --- .../modules/NetworkController/docker/linux/arm32v7/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/connectivity/modules/NetworkController/docker/linux/arm32v7/Dockerfile b/test/connectivity/modules/NetworkController/docker/linux/arm32v7/Dockerfile index f54d286dd35..cbdb87b9086 100644 --- a/test/connectivity/modules/NetworkController/docker/linux/arm32v7/Dockerfile +++ b/test/connectivity/modules/NetworkController/docker/linux/arm32v7/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=1.0.0-linux-arm32v7 +ARG base_tag=1.0.5-linux-arm32v7 FROM edgebuilds.azurecr.io/microsoft/azureiotedge-module-base-full:${base_tag} ARG EXE_DIR=. From dca3433b064b7eeeeb346f5b52da7ce6d10fe375 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 30 Apr 2020 11:48:00 -0700 Subject: [PATCH 015/111] attempt to fix generic host --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 6 ++++++ .../Microsoft.Azure.Devices.Edge.Hub.Service/Startup2.cs | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index cc42103a392..524042824a6 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -6,6 +6,7 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; using Autofac; + using Autofac.Extensions.DependencyInjection; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Server.Kestrel.Https; using Microsoft.Azure.Devices.Edge.Hub.Http.Extensions; @@ -36,6 +37,11 @@ public static Hosting Initialize( var certificateMode = clientCertAuthEnabled ? ClientCertificateMode.AllowCertificate : ClientCertificateMode.NoCertificate; IHost host = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder() + .UseServiceProviderFactory(new AutofacServiceProviderFactory()) + .ConfigureContainer(builder => + { + dependencyManager.Register(builder); + }) .ConfigureWebHostDefaults(webBuilder => { webBuilder diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup2.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup2.cs index a4280dc5b12..5ac11c7dcfd 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup2.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup2.cs @@ -35,9 +35,8 @@ public void ConfigureServices(IServiceCollection services) services.Configure(options => { options.Filters.Add(new RequireHttpsAttribute()); }); } - public void ConfigureContainer(ContainerBuilder builder, DependencyManager dependencyManager) + public void ConfigureContainer(ContainerBuilder builder) { - dependencyManager.Register(builder); builder.RegisterInstance(this); } From dc55d113b5cd7a98b16a75975a4ed0532cd1a236 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 30 Apr 2020 12:21:22 -0700 Subject: [PATCH 016/111] revert changes to webhost --- .../HttpProtocolHead.cs | 14 ++-- .../Hosting.cs | 73 +++++++--------- .../Program.cs | 2 +- .../{StartupDeprecated.cs => Startup.cs} | 6 +- .../Startup2.cs | 83 ------------------- .../ProtocolHeadFixture.cs | 2 +- 6 files changed, 42 insertions(+), 138 deletions(-) rename edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/{StartupDeprecated.cs => Startup.cs} (96%) delete mode 100644 edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup2.cs diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/HttpProtocolHead.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/HttpProtocolHead.cs index 5a5a671d8e1..a464d9c24e7 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/HttpProtocolHead.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/HttpProtocolHead.cs @@ -3,18 +3,18 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Http { using System.Threading; using System.Threading.Tasks; + using Microsoft.AspNetCore.Hosting; using Microsoft.Azure.Devices.Edge.Hub.Core; using Microsoft.Azure.Devices.Edge.Util; - using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; public class HttpProtocolHead : IProtocolHead { - readonly IHost host; + readonly IWebHost webHost; - public HttpProtocolHead(IHost host) + public HttpProtocolHead(IWebHost webHost) { - this.host = Preconditions.CheckNotNull(host, nameof(host)); + this.webHost = Preconditions.CheckNotNull(webHost, nameof(webHost)); } public string Name => "HTTP"; @@ -22,18 +22,18 @@ public HttpProtocolHead(IHost host) public async Task StartAsync() { Events.Starting(); - await this.host.StartAsync(); + await this.webHost.StartAsync(); Events.Started(); } public async Task CloseAsync(CancellationToken token) { Events.Closing(); - await this.host.StopAsync(token); + await this.webHost.StopAsync(token); Events.Closed(); } - public void Dispose() => this.host?.Dispose(); + public void Dispose() => this.webHost?.Dispose(); static class Events { diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 524042824a6..ce75a15f60c 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -6,25 +6,22 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; using Autofac; - using Autofac.Extensions.DependencyInjection; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Server.Kestrel.Https; - using Microsoft.Azure.Devices.Edge.Hub.Http.Extensions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; - using Microsoft.Extensions.Hosting; public class Hosting { - Hosting(IHost host, IContainer container) + Hosting(IWebHost webHost, IContainer container) { - this.Host = host; + this.WebHost = webHost; this.Container = container; } public IContainer Container { get; } - public IHost Host { get; } + public IWebHost WebHost { get; } public static Hosting Initialize( IConfigurationRoot configuration, @@ -35,46 +32,36 @@ public static Hosting Initialize( { int port = configuration.GetValue("httpSettings:port", 443); var certificateMode = clientCertAuthEnabled ? ClientCertificateMode.AllowCertificate : ClientCertificateMode.NoCertificate; - - IHost host = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder() - .UseServiceProviderFactory(new AutofacServiceProviderFactory()) - .ConfigureContainer(builder => - { - dependencyManager.Register(builder); - }) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder - .UseKestrel( - options => + IWebHostBuilder webHostBuilder = new WebHostBuilder() + .UseKestrel( + options => + { + options.Listen( + !Socket.OSSupportsIPv6 ? IPAddress.Any : IPAddress.IPv6Any, + port, + listenOptions => { - options.Listen( - !Socket.OSSupportsIPv6 ? IPAddress.Any : IPAddress.IPv6Any, - port, - listenOptions => + listenOptions.UseHttps( + new HttpsConnectionAdapterOptions() { - listenOptions.UseHttps( - new HttpsConnectionAdapterOptions() - { - ServerCertificate = serverCertificate, - ClientCertificateValidation = (clientCert, chain, policyErrors) => true, - ClientCertificateMode = certificateMode, - SslProtocols = sslProtocols - }); + ServerCertificate = serverCertificate, + ClientCertificateValidation = (clientCert, chain, policyErrors) => true, + ClientCertificateMode = certificateMode, + SslProtocols = sslProtocols }); - }) - .UseSockets() - .ConfigureServices( - serviceCollection => - { - serviceCollection.AddSingleton(configuration); - serviceCollection.AddSingleton(dependencyManager); - }) - .UseStartup(); - }).Build(); - - IContainer container = host.Services.GetService(typeof(Startup2)) is Startup2 startup ? startup.Container : null; - return new Hosting(host, container); + }); + }) + .UseSockets() + .ConfigureServices( + serviceCollection => + { + serviceCollection.AddSingleton(configuration); + serviceCollection.AddSingleton(dependencyManager); + }) + .UseStartup(); + IWebHost webHost = webHostBuilder.Build(); + IContainer container = webHost.Services.GetService(typeof(IStartup)) is Startup startup ? startup.Container : null; + return new Hosting(webHost, container); } } } diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Program.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Program.cs index 03f05120843..4f305c5fa56 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Program.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Program.cs @@ -150,7 +150,7 @@ static async Task GetEdgeHubProtocolHeadAsync(ILogger logge if (configuration.GetValue("httpSettings:enabled", true)) { - protocolHeads.Add(new HttpProtocolHead(hosting.Host)); + protocolHeads.Add(new HttpProtocolHead(hosting.WebHost)); } return new EdgeHubProtocolHead(protocolHeads, logger); diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/StartupDeprecated.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs similarity index 96% rename from edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/StartupDeprecated.cs rename to edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index 9d2d9523fc8..26b22542cc8 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/StartupDeprecated.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -15,13 +15,13 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; - public class StartupDeprecated + public class Startup { readonly IDependencyManager dependencyManager; readonly IConfigurationRoot configuration; // ReSharper disable once UnusedParameter.Local - public StartupDeprecated( + public Startup( IConfigurationRoot configuration, IDependencyManager dependencyManager) { @@ -87,7 +87,7 @@ IContainer BuildContainer(IServiceCollection services) var builder = new ContainerBuilder(); builder.Populate(services); this.dependencyManager.Register(builder); - builder.RegisterInstance(this); + builder.RegisterInstance(this); return builder.Build(); } diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup2.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup2.cs deleted file mode 100644 index 5ac11c7dcfd..00000000000 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup2.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -namespace Microsoft.Azure.Devices.Edge.Hub.Service -{ - using System; - using Autofac; - using Autofac.Extensions.DependencyInjection; - using Microsoft.AspNetCore.Builder; - using Microsoft.AspNetCore.Hosting; - using Microsoft.AspNetCore.Mvc; - using Microsoft.Azure.Devices.Client; - using Microsoft.Azure.Devices.Edge.Hub.Core; - using Microsoft.Azure.Devices.Edge.Hub.Http; - using Microsoft.Azure.Devices.Edge.Hub.Http.Middleware; - using Microsoft.Azure.Devices.Edge.Util; - using Microsoft.Extensions.Configuration; - using Microsoft.Extensions.DependencyInjection; - - public class Startup2 - { - readonly IConfiguration configuration; - - // ReSharper disable once UnusedParameter.Local - public Startup2(IConfiguration configuration) - { - this.configuration = Preconditions.CheckNotNull(configuration, nameof(configuration)); - } - - internal IContainer Container { get; private set; } - - // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) - { - services.AddMemoryCache(); - services.AddControllers(options => options.Filters.Add(typeof(ExceptionFilter))); - services.Configure(options => { options.Filters.Add(new RequireHttpsAttribute()); }); - } - - public void ConfigureContainer(ContainerBuilder builder) - { - builder.RegisterInstance(this); - } - - public void Configure(IApplicationBuilder app) - { - app.UseRouting(); - - app.UseWebSockets(); - - var webSocketListenerRegistry = app.ApplicationServices.GetService(typeof(IWebSocketListenerRegistry)) as IWebSocketListenerRegistry; - app.UseWebSocketHandlingMiddleware(webSocketListenerRegistry); - - string edgeHubConnectionString = this.configuration.GetValue(Constants.ConfigKey.IotHubConnectionString); - string iotHubHostname; - string edgeDeviceId; - if (!string.IsNullOrWhiteSpace(edgeHubConnectionString)) - { - IotHubConnectionStringBuilder iotHubConnectionStringBuilder = IotHubConnectionStringBuilder.Create(edgeHubConnectionString); - iotHubHostname = iotHubConnectionStringBuilder.HostName; - edgeDeviceId = iotHubConnectionStringBuilder.DeviceId; - } - else - { - iotHubHostname = this.configuration.GetValue(Constants.ConfigKey.IotHubHostname); - edgeDeviceId = this.configuration.GetValue(Constants.ConfigKey.DeviceId); - } - - app.UseAuthenticationMiddleware(iotHubHostname, edgeDeviceId); - - app.Use( - async (context, next) => - { - // Response header is added to prevent MIME type sniffing - context.Response.Headers.Add("X-Content-Type-Options", "nosniff"); - await next(); - }); - - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); - } - } -} diff --git a/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.E2E.Test/ProtocolHeadFixture.cs b/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.E2E.Test/ProtocolHeadFixture.cs index 15c5889c735..fcd2c03d851 100644 --- a/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.E2E.Test/ProtocolHeadFixture.cs +++ b/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.E2E.Test/ProtocolHeadFixture.cs @@ -98,7 +98,7 @@ async Task StartProtocolHead() ILogger logger = container.Resolve().CreateLogger("EdgeHub"); MqttProtocolHead mqttProtocolHead = await container.Resolve>(); AmqpProtocolHead amqpProtocolHead = await container.Resolve>(); - var httpProtocolHead = new HttpProtocolHead(hosting.Host); + var httpProtocolHead = new HttpProtocolHead(hosting.WebHost); this.protocolHead = new EdgeHubProtocolHead(new List { mqttProtocolHead, amqpProtocolHead, httpProtocolHead }, logger); await this.protocolHead.StartAsync(); } From 9b0c04330c594dd7457f60679472a67c867257d4 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 30 Apr 2020 13:16:26 -0700 Subject: [PATCH 017/111] revert changes to startup --- .../Startup.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index 26b22542cc8..50146db0507 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -15,7 +15,7 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; - public class Startup + public class Startup : IStartup { readonly IDependencyManager dependencyManager; readonly IConfigurationRoot configuration; @@ -35,7 +35,7 @@ public Startup( public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMemoryCache(); - services.AddControllers(options => options.Filters.Add(typeof(ExceptionFilter))); + services.AddMvc(options => options.Filters.Add(typeof(ExceptionFilter))); services.Configure(options => { options.Filters.Add(new RequireHttpsAttribute()); }); this.Container = this.BuildContainer(services); @@ -44,8 +44,6 @@ public IServiceProvider ConfigureServices(IServiceCollection services) public void Configure(IApplicationBuilder app) { - app.UseRouting(); - app.UseWebSockets(); var webSocketListenerRegistry = app.ApplicationServices.GetService(typeof(IWebSocketListenerRegistry)) as IWebSocketListenerRegistry; @@ -76,10 +74,7 @@ public void Configure(IApplicationBuilder app) await next(); }); - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); + app.UseMvc(); } IContainer BuildContainer(IServiceCollection services) @@ -87,7 +82,7 @@ IContainer BuildContainer(IServiceCollection services) var builder = new ContainerBuilder(); builder.Populate(services); this.dependencyManager.Register(builder); - builder.RegisterInstance(this); + builder.RegisterInstance(this); return builder.Build(); } From cede7ad7c1d1afef70bd4ca8c0d6ef7a464c9d27 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 30 Apr 2020 13:42:29 -0700 Subject: [PATCH 018/111] add logging --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index 50146db0507..82f79c91578 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -25,6 +25,7 @@ public Startup( IConfigurationRoot configuration, IDependencyManager dependencyManager) { + Console.WriteLine("---------IN CONSTRUCTOR--------------"); this.configuration = Preconditions.CheckNotNull(configuration, nameof(configuration)); this.dependencyManager = Preconditions.CheckNotNull(dependencyManager, nameof(dependencyManager)); } @@ -34,6 +35,7 @@ public Startup( // This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { + Console.WriteLine("---------IN CONFIGURE SERVICES ABOUT TO BUILD CONTAINER--------------"); services.AddMemoryCache(); services.AddMvc(options => options.Filters.Add(typeof(ExceptionFilter))); services.Configure(options => { options.Filters.Add(new RequireHttpsAttribute()); }); @@ -44,6 +46,7 @@ public IServiceProvider ConfigureServices(IServiceCollection services) public void Configure(IApplicationBuilder app) { + Console.WriteLine("---------IN CONFIGURE--------------"); app.UseWebSockets(); var webSocketListenerRegistry = app.ApplicationServices.GetService(typeof(IWebSocketListenerRegistry)) as IWebSocketListenerRegistry; @@ -79,6 +82,7 @@ public void Configure(IApplicationBuilder app) IContainer BuildContainer(IServiceCollection services) { + Console.WriteLine("---------IN BUILD CONTAINER--------------"); var builder = new ContainerBuilder(); builder.Populate(services); this.dependencyManager.Register(builder); From a50ca10c0ab20cf28390345f47de281aa70bb87b Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 30 Apr 2020 15:08:45 -0700 Subject: [PATCH 019/111] revert dependency manager scope change --- .../DependencyManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/DependencyManager.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/DependencyManager.cs index 75e35b83c7d..3f94c903741 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/DependencyManager.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/DependencyManager.cs @@ -22,7 +22,7 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service using Microsoft.Extensions.Logging; using StorageLogLevel = Microsoft.Azure.Devices.Edge.Storage.StorageLogLevel; - public class DependencyManager : IDependencyManager + class DependencyManager : IDependencyManager { readonly IConfigurationRoot configuration; readonly X509Certificate2 serverCertificate; From d84e5dcb6d1b2df0ed2b2b850234c814f822d6de Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 30 Apr 2020 16:14:59 -0700 Subject: [PATCH 020/111] disable endpoint routing --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index 82f79c91578..01835290d4a 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -38,7 +38,11 @@ public IServiceProvider ConfigureServices(IServiceCollection services) Console.WriteLine("---------IN CONFIGURE SERVICES ABOUT TO BUILD CONTAINER--------------"); services.AddMemoryCache(); services.AddMvc(options => options.Filters.Add(typeof(ExceptionFilter))); - services.Configure(options => { options.Filters.Add(new RequireHttpsAttribute()); }); + services.Configure(options => + { + options.Filters.Add(new RequireHttpsAttribute()); + options.EnableEndpointRouting = false; + }); this.Container = this.BuildContainer(services); return new AutofacServiceProvider(this.Container); From e633674ab6c76ea05f55123fa707c2d46fba4076 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Fri, 1 May 2020 09:08:06 -0700 Subject: [PATCH 021/111] remove debug logging --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index 01835290d4a..245d63c2e74 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -25,7 +25,6 @@ public Startup( IConfigurationRoot configuration, IDependencyManager dependencyManager) { - Console.WriteLine("---------IN CONSTRUCTOR--------------"); this.configuration = Preconditions.CheckNotNull(configuration, nameof(configuration)); this.dependencyManager = Preconditions.CheckNotNull(dependencyManager, nameof(dependencyManager)); } @@ -35,7 +34,6 @@ public Startup( // This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { - Console.WriteLine("---------IN CONFIGURE SERVICES ABOUT TO BUILD CONTAINER--------------"); services.AddMemoryCache(); services.AddMvc(options => options.Filters.Add(typeof(ExceptionFilter))); services.Configure(options => @@ -50,7 +48,6 @@ public IServiceProvider ConfigureServices(IServiceCollection services) public void Configure(IApplicationBuilder app) { - Console.WriteLine("---------IN CONFIGURE--------------"); app.UseWebSockets(); var webSocketListenerRegistry = app.ApplicationServices.GetService(typeof(IWebSocketListenerRegistry)) as IWebSocketListenerRegistry; @@ -86,7 +83,6 @@ public void Configure(IApplicationBuilder app) IContainer BuildContainer(IServiceCollection services) { - Console.WriteLine("---------IN BUILD CONTAINER--------------"); var builder = new ContainerBuilder(); builder.Populate(services); this.dependencyManager.Register(builder); From af0be0f2f8ccc7e18610e0554d9adaab524d91ab Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 4 May 2020 11:01:26 -0700 Subject: [PATCH 022/111] hacky attempt at workaround, clean up later --- .../Extensions/CertContext.cs | 11 +++++++ .../Hosting.cs | 30 ++++++++++++++++++- ...soft.Azure.Devices.Edge.Hub.Service.csproj | 1 + .../Startup.cs | 6 ++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertContext.cs diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertContext.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertContext.cs new file mode 100644 index 00000000000..ff9bf25bf19 --- /dev/null +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertContext.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft. All rights reserved. +namespace Microsoft.Azure.Devices.Edge.Hub.Http.Extensions +{ + using Microsoft.AspNetCore.Http.Features; + + public static class CertContext // TODO: Replace hacky POC + { + public static TlsConnectionFeatureExtended TlsConnectionFeatureExtended { get; set; } + public static TlsConnectionFeature TlsConnectionFeature { get; set; } + } +} diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index ce75a15f60c..380a030ee07 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -1,13 +1,17 @@ // Copyright (c) Microsoft. All rights reserved. namespace Microsoft.Azure.Devices.Edge.Hub.Service { + using System.Collections.Generic; using System.Net; + using System.Net.Security; using System.Net.Sockets; using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; using Autofac; using Microsoft.AspNetCore.Hosting; + using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Server.Kestrel.Https; + using Microsoft.Azure.Devices.Edge.Hub.Http.Extensions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -45,7 +49,26 @@ public static Hosting Initialize( new HttpsConnectionAdapterOptions() { ServerCertificate = serverCertificate, - ClientCertificateValidation = (clientCert, chain, policyErrors) => true, + ClientCertificateValidation = (clientCert, chain, policyErrors) => // TODO: Store cert and add to context in startup. Inject TlsFeatures into Startup class. Eliminate hacky POC. + { + CertContext.TlsConnectionFeature = new TlsConnectionFeature + { + ClientCertificate = clientCert + }; + + IList chainElements = new List(); + foreach (X509ChainElement element in chain.ChainElements) + { + chainElements.Add(element.Certificate); + } + + CertContext.TlsConnectionFeatureExtended = new TlsConnectionFeatureExtended + { + ChainElements = chainElements + }; + + return true; + }, ClientCertificateMode = certificateMode, SslProtocols = sslProtocols }); @@ -63,5 +86,10 @@ public static Hosting Initialize( IContainer container = webHost.Services.GetService(typeof(IStartup)) is Startup startup ? startup.Container : null; return new Hosting(webHost, container); } + + // static void ClientCertificateValidation(X509Certificate2 clientCert, X509Chain chain, SslPolicyErrors policyErrors) + // { + + // } } } diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Microsoft.Azure.Devices.Edge.Hub.Service.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Microsoft.Azure.Devices.Edge.Hub.Service.csproj index d3990a63752..ec887ac614e 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Microsoft.Azure.Devices.Edge.Hub.Service.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Microsoft.Azure.Devices.Edge.Hub.Service.csproj @@ -29,6 +29,7 @@ + diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index 245d63c2e74..4695cdb96da 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -2,14 +2,18 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service { using System; + using System.Threading.Tasks; using Autofac; using Autofac.Extensions.DependencyInjection; + using Microsoft.AspNetCore.Authentication.Certificate; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; + using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.Devices.Client; using Microsoft.Azure.Devices.Edge.Hub.Core; using Microsoft.Azure.Devices.Edge.Hub.Http; + using Microsoft.Azure.Devices.Edge.Hub.Http.Extensions; using Microsoft.Azure.Devices.Edge.Hub.Http.Middleware; using Microsoft.Azure.Devices.Edge.Util; using Microsoft.Extensions.Configuration; @@ -75,6 +79,8 @@ public void Configure(IApplicationBuilder app) { // Response header is added to prevent MIME type sniffing context.Response.Headers.Add("X-Content-Type-Options", "nosniff"); + context.Features.Set(CertContext.TlsConnectionFeature); + context.Features.Set(CertContext.TlsConnectionFeatureExtended); await next(); }); From fa866a0cdd29aeacd75162361ce4860a9a1067fd Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 4 May 2020 11:30:48 -0700 Subject: [PATCH 023/111] address self comments --- builds/misc/images.yaml | 20 ++++++++++---------- scripts/linux/runTests.sh | 4 ---- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/builds/misc/images.yaml b/builds/misc/images.yaml index 6f1f03666d8..581399c1504 100644 --- a/builds/misc/images.yaml +++ b/builds/misc/images.yaml @@ -212,8 +212,8 @@ jobs: name: build displayName: Build ($(Build.Configuration)) - # - powershell: edgelet/build/windows/build-diagnostics.ps1 -BuildConfiguration $(Build.Configuration) - # displayName: Build iotedge-diagnostics + - powershell: edgelet/build/windows/build-diagnostics.ps1 -BuildConfiguration $(Build.Configuration) + displayName: Build iotedge-diagnostics - powershell: scripts/windows/build/Create-ArtifactInfo.ps1 -outputFolder '$(Build.BinariesDirectory)/publish' -buildNumber $(Build.BuildNumber) displayName: 'Create Artifact Info File' @@ -224,12 +224,12 @@ jobs: PathtoPublish: '$(Build.BinariesDirectory)/publish' ArtifactName: 'core-windows' - # # azureiotedge-diagnostics - # - template: templates/image-windows.yaml - # parameters: - # name: azureiotedge-diagnostics - # imageName: azureiotedge-diagnostics - # project: azureiotedge-diagnostics + # azureiotedge-diagnostics + - template: templates/image-windows.yaml + parameters: + name: azureiotedge-diagnostics + imageName: azureiotedge-diagnostics + project: azureiotedge-diagnostics # Edge Agent - template: templates/image-windows.yaml @@ -383,7 +383,7 @@ jobs: displayName: 'Publish Temperature Sensor Manifest' - script: scripts/linux/buildManifest.sh -r $(registry.address) -u $(registry.user) -p $(registry.password) -v $(Build.BuildNumber) -t $(System.DefaultWorkingDirectory)/edgelet/iotedged/docker/manifest.yaml.template -n microsoft --tags "$(tags)" displayName: 'Publish azureiotedge-iotedged Manifest' - # - script: scripts/linux/buildManifest.sh -r $(registry.address) -u $(registry.user) -p $(registry.password) -v $(Build.BuildNumber) -t $(System.DefaultWorkingDirectory)/edgelet/iotedge-diagnostics/docker/manifest.yaml.template -n microsoft --tags "$(tags)" - # displayName: 'Publish azureiotedge-diagnostics Manifest' + - script: scripts/linux/buildManifest.sh -r $(registry.address) -u $(registry.user) -p $(registry.password) -v $(Build.BuildNumber) -t $(System.DefaultWorkingDirectory)/edgelet/iotedge-diagnostics/docker/manifest.yaml.template -n microsoft --tags "$(tags)" + displayName: 'Publish azureiotedge-diagnostics Manifest' - script: scripts/linux/buildManifest.sh -r $(registry.address) -u $(registry.user) -p $(registry.password) -v $(Build.BuildNumber) -t $(System.DefaultWorkingDirectory)/edgelet/iotedge-proxy/docker/manifest.yaml.template -n microsoft --tags "$(tags)" displayName: 'Publish azureiotedge-proxy Manifest' diff --git a/scripts/linux/runTests.sh b/scripts/linux/runTests.sh index a4798c12fa9..66f421eab29 100755 --- a/scripts/linux/runTests.sh +++ b/scripts/linux/runTests.sh @@ -20,10 +20,6 @@ BUILD_CONFIG="$2" SUFFIX='Microsoft.Azure*test.dll' OUTPUT_FOLDER=$BUILD_BINARIESDIRECTORY -echo 'dotnet version:' -dotnet --version -/opt/hostedtoolcache/dotnet/dotnet --version - if [ ! -f "$DOTNET_ROOT_PATH" ]; then dotnet_path=$(command -v dotnet) if [ $? -eq 0 ]; then From 1f9f72d72e7e1ee7dbf86a00c28811c42f65bd10 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 4 May 2020 13:51:38 -0700 Subject: [PATCH 024/111] hacky POC v2 --- .../Extensions/CertContext.cs | 6 +++--- .../Extensions/HttpContextExtensions.cs | 4 ++++ .../middleware/AuthenticationMiddleware.cs | 2 ++ .../Hosting.cs | 13 ++++++------- .../Startup.cs | 13 +++++++++++-- 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertContext.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertContext.cs index ff9bf25bf19..fc285b93f52 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertContext.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertContext.cs @@ -1,11 +1,11 @@ // Copyright (c) Microsoft. All rights reserved. namespace Microsoft.Azure.Devices.Edge.Hub.Http.Extensions { - using Microsoft.AspNetCore.Http.Features; + using System.Collections.Generic; + using System.Security.Cryptography.X509Certificates; public static class CertContext // TODO: Replace hacky POC { - public static TlsConnectionFeatureExtended TlsConnectionFeatureExtended { get; set; } - public static TlsConnectionFeature TlsConnectionFeature { get; set; } + public static Dictionary CertsToChain = new Dictionary(); } } diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs index 6dfd3a0dbde..54b394627ca 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. namespace Microsoft.Azure.Devices.Edge.Hub.Http.Extensions { + using System; using System.Collections.Generic; using System.Security.Cryptography.X509Certificates; using Microsoft.AspNetCore.Http; @@ -10,6 +11,9 @@ public static class HttpContextExtensions public static IList GetClientCertificateChain(this HttpContext context) { var feature = context.Features.Get(); + + Console.WriteLine($"-------------CLIENT CERT CHAIN NULL CHECK: {feature == null}---------------"); + return (feature == null) ? new List() : feature.ChainElements; } } diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/AuthenticationMiddleware.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/AuthenticationMiddleware.cs index 7f8765e8db6..658e2354885 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/AuthenticationMiddleware.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/AuthenticationMiddleware.cs @@ -83,11 +83,13 @@ public async Task Invoke(HttpContext context) if (clientCertificate != null) { + Console.WriteLine("------------------CLIENT CERT DEFINED-----------------------"); IList certChain = context.GetClientCertificateChain(); clientCredentials = this.identityFactory.GetWithX509Cert(deviceId, moduleId, string.Empty, clientCertificate, certChain); } else { + Console.WriteLine("------------------CLIENT CERT NULL-----------------------"); // Authorization header may be present in the QueryNameValuePairs as per Azure standards, // So check in the query parameters first. List authorizationQueryParameters = context.Request.Query diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 380a030ee07..cbce989d934 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. namespace Microsoft.Azure.Devices.Edge.Hub.Service { + using System; using System.Collections.Generic; using System.Net; using System.Net.Security; @@ -51,21 +52,19 @@ public static Hosting Initialize( ServerCertificate = serverCertificate, ClientCertificateValidation = (clientCert, chain, policyErrors) => // TODO: Store cert and add to context in startup. Inject TlsFeatures into Startup class. Eliminate hacky POC. { - CertContext.TlsConnectionFeature = new TlsConnectionFeature - { - ClientCertificate = clientCert - }; - + Console.WriteLine("---------------Setting map entry for tls feature----------------------"); IList chainElements = new List(); foreach (X509ChainElement element in chain.ChainElements) { chainElements.Add(element.Certificate); } - CertContext.TlsConnectionFeatureExtended = new TlsConnectionFeatureExtended + CertContext.CertsToChain.Add(clientCert, new TlsConnectionFeatureExtended { ChainElements = chainElements - }; + }); + + Console.WriteLine($"---------------Count of chain elements: {chainElements.Count}----------------------"); return true; }, diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index 4695cdb96da..7ddb8aa7b67 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -54,6 +54,17 @@ public void Configure(IApplicationBuilder app) { app.UseWebSockets(); + // TODO: eliminate hacky POC and consolidate with the below response headers + app.Use( + async (context, next) => + { + Console.WriteLine($"---------------Retrieving tls feature from map----------------------"); + TlsConnectionFeatureExtended tlsConnectionFeatureExtended = CertContext.CertsToChain[context.Connection.ClientCertificate]; // TODO: remove from dict + context.Features.Set(tlsConnectionFeatureExtended); + Console.WriteLine($"---------------Retrieve successful----------------------"); + await next(); + }); + var webSocketListenerRegistry = app.ApplicationServices.GetService(typeof(IWebSocketListenerRegistry)) as IWebSocketListenerRegistry; app.UseWebSocketHandlingMiddleware(webSocketListenerRegistry); @@ -79,8 +90,6 @@ public void Configure(IApplicationBuilder app) { // Response header is added to prevent MIME type sniffing context.Response.Headers.Add("X-Content-Type-Options", "nosniff"); - context.Features.Set(CertContext.TlsConnectionFeature); - context.Features.Set(CertContext.TlsConnectionFeatureExtended); await next(); }); From 8b34897fdb9096a41e418ed93d034ace9056f5c4 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 4 May 2020 14:20:54 -0700 Subject: [PATCH 025/111] add newtonsoft json for test modules --- test/modules/TestAnalyzer/Startup.cs | 2 +- test/modules/TestAnalyzer/TestAnalyzer.csproj | 1 + test/modules/TestResultCoordinator/Startup.cs | 2 +- test/modules/TestResultCoordinator/TestResultCoordinator.csproj | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/modules/TestAnalyzer/Startup.cs b/test/modules/TestAnalyzer/Startup.cs index 242eaebdde5..52784acd950 100644 --- a/test/modules/TestAnalyzer/Startup.cs +++ b/test/modules/TestAnalyzer/Startup.cs @@ -19,7 +19,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddControllers(); + services.AddControllers().AddNewtonsoftJson(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/test/modules/TestAnalyzer/TestAnalyzer.csproj b/test/modules/TestAnalyzer/TestAnalyzer.csproj index 990f65f9744..1508e0130d4 100644 --- a/test/modules/TestAnalyzer/TestAnalyzer.csproj +++ b/test/modules/TestAnalyzer/TestAnalyzer.csproj @@ -18,6 +18,7 @@ + diff --git a/test/modules/TestResultCoordinator/Startup.cs b/test/modules/TestResultCoordinator/Startup.cs index cdbb46b0d96..babfc299f8c 100644 --- a/test/modules/TestResultCoordinator/Startup.cs +++ b/test/modules/TestResultCoordinator/Startup.cs @@ -33,7 +33,7 @@ public void ConfigureServices(IServiceCollection services) { Logger.LogInformation("Calling Startup.ConfigureServices"); - services.AddControllers(); + services.AddControllers().AddNewtonsoftJson(); HashSet sources = Settings.Current.GetResultSourcesAsync(Logger).Result; Logger.LogInformation($"Result sources defined:{Environment.NewLine} {string.Join(Environment.NewLine + Enumerable.Repeat(" ", 5), sources)}"); diff --git a/test/modules/TestResultCoordinator/TestResultCoordinator.csproj b/test/modules/TestResultCoordinator/TestResultCoordinator.csproj index 953f70b2e31..c3e238f856d 100644 --- a/test/modules/TestResultCoordinator/TestResultCoordinator.csproj +++ b/test/modules/TestResultCoordinator/TestResultCoordinator.csproj @@ -19,6 +19,7 @@ + From 01467d33611062c9ce4e3fea64a999c82fba463d Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 4 May 2020 14:56:01 -0700 Subject: [PATCH 026/111] missed some base images --- .../modules/NetworkController/docker/linux/amd64/Dockerfile | 2 +- test/modules/ModuleRestarter/docker/linux/amd64/Dockerfile | 2 +- test/modules/ModuleRestarter/docker/windows/amd64/Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/connectivity/modules/NetworkController/docker/linux/amd64/Dockerfile b/test/connectivity/modules/NetworkController/docker/linux/amd64/Dockerfile index fc3370e6dbc..ded0ef7df71 100644 --- a/test/connectivity/modules/NetworkController/docker/linux/amd64/Dockerfile +++ b/test/connectivity/modules/NetworkController/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-alpine3.10 +ARG base_tag=3.1.2-alpine3.11 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/ModuleRestarter/docker/linux/amd64/Dockerfile b/test/modules/ModuleRestarter/docker/linux/amd64/Dockerfile index b5dca64c22b..d9927fb3339 100644 --- a/test/modules/ModuleRestarter/docker/linux/amd64/Dockerfile +++ b/test/modules/ModuleRestarter/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.17-alpine3.11 +ARG base_tag=3.1.2-alpine3.11 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/ModuleRestarter/docker/windows/amd64/Dockerfile b/test/modules/ModuleRestarter/docker/windows/amd64/Dockerfile index 6322b847f45..d9daec3fa8a 100644 --- a/test/modules/ModuleRestarter/docker/windows/amd64/Dockerfile +++ b/test/modules/ModuleRestarter/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=2.1.10-nanoserver-1809 +ARG base_tag=3.1.2-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. From 7a9f962a7c1715abaf83f4a6dbaae1534af7bd75 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 4 May 2020 18:17:37 -0700 Subject: [PATCH 027/111] add logs --- .../DeviceIdentityProvider.cs | 3 +++ .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs index 3d7c9bc1786..99a466fa111 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs @@ -12,6 +12,7 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Mqtt using Microsoft.Azure.Devices.Edge.Util; using Microsoft.Azure.Devices.ProtocolGateway.Identity; using Microsoft.Extensions.Logging; + using Newtonsoft.Json; using static System.FormattableString; public class DeviceIdentityProvider : IDeviceIdentityProvider @@ -78,6 +79,8 @@ public async Task GetAsync(string clientId, string username, st return UnauthenticatedDeviceIdentity.Instance; } + Console.WriteLine($"------------Device credential error: {JsonConvert.SerializeObject(deviceCredentials)} | Client id error: {!clientId.Equals(deviceCredentials.Identity.Id, StringComparison.Ordinal)}--------------"); + if (deviceCredentials == null || !clientId.Equals(deviceCredentials.Identity.Id, StringComparison.Ordinal) || !await this.authenticator.AuthenticateAsync(deviceCredentials)) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index cbce989d934..e0408f8de96 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -15,6 +15,7 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service using Microsoft.Azure.Devices.Edge.Hub.Http.Extensions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; + using Newtonsoft.Json; public class Hosting { @@ -59,6 +60,9 @@ public static Hosting Initialize( chainElements.Add(element.Certificate); } + Console.WriteLine($"---------------------{JsonConvert.SerializeObject(chainElements)}-----------------------"); + Console.WriteLine($"---------------------------{clientCert.Thumbprint}----------------------------------"); + CertContext.CertsToChain.Add(clientCert, new TlsConnectionFeatureExtended { ChainElements = chainElements From d2db33b2567ad003fcc14d97155a372c31f2d16e Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 4 May 2020 19:03:20 -0700 Subject: [PATCH 028/111] alter hacky POC --- .../Extensions/CertContext.cs | 2 +- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 2 +- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertContext.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertContext.cs index fc285b93f52..2e0afea959e 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertContext.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertContext.cs @@ -6,6 +6,6 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Http.Extensions public static class CertContext // TODO: Replace hacky POC { - public static Dictionary CertsToChain = new Dictionary(); + public static Dictionary CertsToChain = new Dictionary(); } } diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index e0408f8de96..b0d2e274ce4 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -63,7 +63,7 @@ public static Hosting Initialize( Console.WriteLine($"---------------------{JsonConvert.SerializeObject(chainElements)}-----------------------"); Console.WriteLine($"---------------------------{clientCert.Thumbprint}----------------------------------"); - CertContext.CertsToChain.Add(clientCert, new TlsConnectionFeatureExtended + CertContext.CertsToChain.Add(clientCert.Thumbprint, new TlsConnectionFeatureExtended { ChainElements = chainElements }); diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index 7ddb8aa7b67..a1a9abad0fe 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -59,7 +59,7 @@ public void Configure(IApplicationBuilder app) async (context, next) => { Console.WriteLine($"---------------Retrieving tls feature from map----------------------"); - TlsConnectionFeatureExtended tlsConnectionFeatureExtended = CertContext.CertsToChain[context.Connection.ClientCertificate]; // TODO: remove from dict + TlsConnectionFeatureExtended tlsConnectionFeatureExtended = CertContext.CertsToChain[context.Connection.ClientCertificate.Thumbprint]; // TODO: remove from dict context.Features.Set(tlsConnectionFeatureExtended); Console.WriteLine($"---------------Retrieve successful----------------------"); await next(); From 1ca31211dcb29d83d82e6df98270368af20bfdcf Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 4 May 2020 23:33:39 -0700 Subject: [PATCH 029/111] remove serialization and fix dup adds --- .../DeviceIdentityProvider.cs | 3 +-- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs index 99a466fa111..30f8f721a78 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs @@ -12,7 +12,6 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Mqtt using Microsoft.Azure.Devices.Edge.Util; using Microsoft.Azure.Devices.ProtocolGateway.Identity; using Microsoft.Extensions.Logging; - using Newtonsoft.Json; using static System.FormattableString; public class DeviceIdentityProvider : IDeviceIdentityProvider @@ -79,7 +78,7 @@ public async Task GetAsync(string clientId, string username, st return UnauthenticatedDeviceIdentity.Instance; } - Console.WriteLine($"------------Device credential error: {JsonConvert.SerializeObject(deviceCredentials)} | Client id error: {!clientId.Equals(deviceCredentials.Identity.Id, StringComparison.Ordinal)}--------------"); + Console.WriteLine($"------------Device credential error: {deviceCredentials.ToString()} | Client id error: {!clientId.Equals(deviceCredentials.Identity.Id, StringComparison.Ordinal)}--------------"); if (deviceCredentials == null || !clientId.Equals(deviceCredentials.Identity.Id, StringComparison.Ordinal) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index b0d2e274ce4..d7a8051f9a0 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -63,10 +63,10 @@ public static Hosting Initialize( Console.WriteLine($"---------------------{JsonConvert.SerializeObject(chainElements)}-----------------------"); Console.WriteLine($"---------------------------{clientCert.Thumbprint}----------------------------------"); - CertContext.CertsToChain.Add(clientCert.Thumbprint, new TlsConnectionFeatureExtended + CertContext.CertsToChain[clientCert.Thumbprint] = new TlsConnectionFeatureExtended { ChainElements = chainElements - }); + }; Console.WriteLine($"---------------Count of chain elements: {chainElements.Count}----------------------"); From 0fe78a0c7c04d53368d6b2589712ef0146c2b48a Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 5 May 2020 08:53:36 -0700 Subject: [PATCH 030/111] more logs --- .../Authenticator.cs | 4 ++-- .../DeviceIdentityProvider.cs | 12 ++++++++++++ .../CertificateHelper.cs | 7 +++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Authenticator.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Authenticator.cs index dc153b15434..da855aec5dd 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Authenticator.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Authenticator.cs @@ -78,10 +78,10 @@ public static void InvalidDeviceId(IModuleIdentity moduleIdentity, string edgeDe public static void AuthResult(IClientCredentials clientCredentials, bool reAuthenticating, bool result) { - string operation = reAuthenticating ? "re-authenticated" : "authenticated"; + string operation = reAuthenticating ? "re-authenticate" : "authenticate"; if (result) { - Log.LogDebug((int)EventIds.AuthResult, Invariant($"Client {clientCredentials.Identity.Id} {operation} successfully")); + Log.LogDebug((int)EventIds.AuthResult, Invariant($"Client {clientCredentials.Identity.Id} {operation}d successfully")); } else { diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs index 30f8f721a78..b409f0f9144 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs @@ -79,6 +79,18 @@ public async Task GetAsync(string clientId, string username, st } Console.WriteLine($"------------Device credential error: {deviceCredentials.ToString()} | Client id error: {!clientId.Equals(deviceCredentials.Identity.Id, StringComparison.Ordinal)}--------------"); + if (deviceCredentials is ICertificateCredentials) + { + ICertificateCredentials tmpCredentials = (ICertificateCredentials)deviceCredentials; + X509Certificate2 remoteCertificate = tmpCredentials.ClientCertificate; + IList remoteCertificateChain = tmpCredentials.ClientCertificateChain; + + Console.WriteLine($"------------------Remote cert: {remoteCertificate.RawData.ToString()}------------------"); + foreach (X509Certificate2 cert in remoteCertificateChain) + { + Console.WriteLine($"------------------Chain cert: {remoteCertificate.RawData.ToString()}------------------"); + } + } if (deviceCredentials == null || !clientId.Equals(deviceCredentials.Identity.Id, StringComparison.Ordinal) diff --git a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/CertificateHelper.cs b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/CertificateHelper.cs index 8d639c8e561..1a71c4115f3 100644 --- a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/CertificateHelper.cs +++ b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/CertificateHelper.cs @@ -89,6 +89,13 @@ public static (bool, Option) ValidateCert(X509Certificate2 remoteCertifi Preconditions.CheckNotNull(remoteCertificateChain); Preconditions.CheckNotNull(trustedCACerts); + // TODO: remove + Console.WriteLine($"------------------Remote cert: {remoteCertificate.RawData.ToString()}------------------"); + foreach (X509Certificate2 cert in remoteCertificateChain) + { + Console.WriteLine($"------------------Chain cert: {remoteCertificate.RawData.ToString()}------------------"); + } + (IList remoteCerts, Option errors) = BuildCertificateList(remoteCertificate, Option.Some(remoteCertificateChain)); if (errors.HasValue) { From 27f93b4978f1eb934a7fb74c4a3dc94b7c670c83 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 5 May 2020 08:56:40 -0700 Subject: [PATCH 031/111] alter logs --- .../Extensions/HttpContextExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs index 54b394627ca..3f420ffff9a 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs @@ -12,7 +12,7 @@ public static IList GetClientCertificateChain(this HttpContext { var feature = context.Features.Get(); - Console.WriteLine($"-------------CLIENT CERT CHAIN NULL CHECK: {feature == null}---------------"); + Console.WriteLine($"-------------CLIENT CERT CHAIN NULL CHECK: {feature == null} {feature.ChainElements.Count == 0}---------------"); return (feature == null) ? new List() : feature.ChainElements; } From 3827451261f117ef314c548da86c9cb9d70139cb Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 5 May 2020 09:20:11 -0700 Subject: [PATCH 032/111] add logging around ws middleware --- .../middleware/WebSocketHandlingMiddleware.cs | 7 +++++++ .../DeviceIdentityProvider.cs | 2 +- .../Microsoft.Azure.Devices.Edge.Util/CertificateHelper.cs | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/WebSocketHandlingMiddleware.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/WebSocketHandlingMiddleware.cs index a4d110bad13..0371cfd4081 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/WebSocketHandlingMiddleware.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/WebSocketHandlingMiddleware.cs @@ -72,9 +72,16 @@ async Task ProcessRequestAsync(HttpContext context, IWebSocketListener listener, var remoteEndPoint = new IPEndPoint(context.Connection.RemoteIpAddress, context.Connection.RemotePort); X509Certificate2 cert = await context.Connection.GetClientCertificateAsync(); + + // TODO: remove + Console.WriteLine($"------------------Remote cert: {cert.RawData.ToString()}------------------"); if (cert != null) { IList certChain = context.GetClientCertificateChain(); + foreach (X509Certificate2 chainedCert in certChain) + { + Console.WriteLine($"------------------Chain cert: {chainedCert.RawData.ToString()}------------------"); + } await listener.ProcessWebSocketRequestAsync(webSocket, localEndPoint, remoteEndPoint, correlationId, cert, certChain); } else diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs index b409f0f9144..45a000cfbea 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs @@ -88,7 +88,7 @@ public async Task GetAsync(string clientId, string username, st Console.WriteLine($"------------------Remote cert: {remoteCertificate.RawData.ToString()}------------------"); foreach (X509Certificate2 cert in remoteCertificateChain) { - Console.WriteLine($"------------------Chain cert: {remoteCertificate.RawData.ToString()}------------------"); + Console.WriteLine($"------------------Chain cert: {cert.RawData.ToString()}------------------"); } } diff --git a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/CertificateHelper.cs b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/CertificateHelper.cs index 1a71c4115f3..a8bdae64ed5 100644 --- a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/CertificateHelper.cs +++ b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/CertificateHelper.cs @@ -93,7 +93,7 @@ public static (bool, Option) ValidateCert(X509Certificate2 remoteCertifi Console.WriteLine($"------------------Remote cert: {remoteCertificate.RawData.ToString()}------------------"); foreach (X509Certificate2 cert in remoteCertificateChain) { - Console.WriteLine($"------------------Chain cert: {remoteCertificate.RawData.ToString()}------------------"); + Console.WriteLine($"------------------Chain cert: {cert.RawData.ToString()}------------------"); } (IList remoteCerts, Option errors) = BuildCertificateList(remoteCertificate, Option.Some(remoteCertificateChain)); From e02c519fcc4b1004359f404b15f9d17166b9e521 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 5 May 2020 09:40:54 -0700 Subject: [PATCH 033/111] logs around auth entrypoint --- .../middleware/WebSocketHandlingMiddleware.cs | 1 + .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/WebSocketHandlingMiddleware.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/WebSocketHandlingMiddleware.cs index 0371cfd4081..f9546be62da 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/WebSocketHandlingMiddleware.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/WebSocketHandlingMiddleware.cs @@ -82,6 +82,7 @@ async Task ProcessRequestAsync(HttpContext context, IWebSocketListener listener, { Console.WriteLine($"------------------Chain cert: {chainedCert.RawData.ToString()}------------------"); } + await listener.ProcessWebSocketRequestAsync(webSocket, localEndPoint, remoteEndPoint, correlationId, cert, certChain); } else diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index d7a8051f9a0..4556e8b05b7 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -54,10 +54,12 @@ public static Hosting Initialize( ClientCertificateValidation = (clientCert, chain, policyErrors) => // TODO: Store cert and add to context in startup. Inject TlsFeatures into Startup class. Eliminate hacky POC. { Console.WriteLine("---------------Setting map entry for tls feature----------------------"); + Console.WriteLine(clientCert.RawData.ToString()); IList chainElements = new List(); foreach (X509ChainElement element in chain.ChainElements) { chainElements.Add(element.Certificate); + Console.WriteLine(element.Certificate.RawData.ToString()); } Console.WriteLine($"---------------------{JsonConvert.SerializeObject(chainElements)}-----------------------"); From cd5776fc4c4b8317f35c55cbb87fb4cce56242bb Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 5 May 2020 11:03:33 -0700 Subject: [PATCH 034/111] more logs --- .../Extensions/HttpContextExtensions.cs | 4 ++++ .../DeviceIdentityProvider.cs | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs index 3f420ffff9a..ef63ccc9b1a 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs @@ -13,6 +13,10 @@ public static IList GetClientCertificateChain(this HttpContext var feature = context.Features.Get(); Console.WriteLine($"-------------CLIENT CERT CHAIN NULL CHECK: {feature == null} {feature.ChainElements.Count == 0}---------------"); + foreach (X509Certificate2 chainedCert in feature.ChainElements) + { + Console.WriteLine($"------------------Chain cert: {chainedCert.RawData.ToString()}------------------"); + } return (feature == null) ? new List() : feature.ChainElements; } diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs index 45a000cfbea..a3f362226fb 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs @@ -115,6 +115,12 @@ public void RegisterConnectionCertificate(X509Certificate2 certificate, IList Date: Tue, 5 May 2020 11:04:43 -0700 Subject: [PATCH 035/111] fix build --- .../DeviceIdentityProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs index a3f362226fb..0e205299326 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs @@ -117,7 +117,7 @@ public void RegisterConnectionCertificate(X509Certificate2 certificate, IList Date: Tue, 5 May 2020 12:01:02 -0700 Subject: [PATCH 036/111] more logs --- .../identity/ClientCredentialsFactory.cs | 7 +++++++ .../DeviceIdentityProvider.cs | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/identity/ClientCredentialsFactory.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/identity/ClientCredentialsFactory.cs index a5c147a5815..2741261e775 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/identity/ClientCredentialsFactory.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/identity/ClientCredentialsFactory.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. namespace Microsoft.Azure.Devices.Edge.Hub.Core.Identity { + using System; using System.Collections.Generic; using System.Security.Cryptography.X509Certificates; using Microsoft.Azure.Devices.Client; @@ -30,6 +31,12 @@ public ClientCredentialsFactory(IIdentityProvider identityProvider, string calle public IClientCredentials GetWithX509Cert(string deviceId, string moduleId, string deviceClientType, X509Certificate2 clientCertificate, IList clientChainCertificate) { + Console.WriteLine($"------------------Remote cert: {clientCertificate.RawData.ToString()}------------------"); + foreach (X509Certificate2 cert in clientChainCertificate) + { + Console.WriteLine($"------------------Chain cert: {cert.RawData.ToString()}------------------"); + } + string productInfo = string.Join(" ", deviceClientType, this.callerProductInfo).Trim(); IIdentity identity = this.identityProvider.Create(deviceId, moduleId); return new X509CertCredentials(identity, productInfo, clientCertificate, clientChainCertificate); diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs index 0e205299326..dfa0eeda3c4 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs @@ -79,8 +79,14 @@ public async Task GetAsync(string clientId, string username, st } Console.WriteLine($"------------Device credential error: {deviceCredentials.ToString()} | Client id error: {!clientId.Equals(deviceCredentials.Identity.Id, StringComparison.Ordinal)}--------------"); + if (deviceCredentials is ICertificateCredentials) { + foreach (X509Certificate2 cert in this.remoteCertificateChain) + { + Console.WriteLine($"------------------GetAsync() owned chain cert: {cert.RawData.ToString()}------------------"); + } + ICertificateCredentials tmpCredentials = (ICertificateCredentials)deviceCredentials; X509Certificate2 remoteCertificate = tmpCredentials.ClientCertificate; IList remoteCertificateChain = tmpCredentials.ClientCertificateChain; @@ -117,7 +123,7 @@ public void RegisterConnectionCertificate(X509Certificate2 certificate, IList Date: Tue, 5 May 2020 12:02:21 -0700 Subject: [PATCH 037/111] register connection certs specific logs --- .../DeviceIdentityProvider.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs index dfa0eeda3c4..6216fa2eda7 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs @@ -122,10 +122,10 @@ public void RegisterConnectionCertificate(X509Certificate2 certificate, IList Date: Tue, 5 May 2020 15:19:38 -0700 Subject: [PATCH 038/111] deep copy chain elements --- .../MqttProtocolHead.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/MqttProtocolHead.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/MqttProtocolHead.cs index 3b53299b63f..dfe1a314e98 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/MqttProtocolHead.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/MqttProtocolHead.cs @@ -203,11 +203,12 @@ bool RemoteCertificateValidationCallback(DeviceIdentityProvider identityProvider { if (this.clientCertAuthAllowed && certificate != null) { - IList certChain = chain?.ChainElements? - .Cast() - .Select(element => element.Certificate) - .ToList() - ?? new List(); + IList certChain = new List(); + foreach (X509ChainElement chainElement in chain.ChainElements) + { + certChain.Add(new X509Certificate2(chainElement.Certificate)); + } + identityProvider.RegisterConnectionCertificate(new X509Certificate2(certificate), certChain); } From 329eb45ae914f664eea85caa7c1a2b2b20d9f15c Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 5 May 2020 15:26:57 -0700 Subject: [PATCH 039/111] deep copy chain for ws --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 4556e8b05b7..e4b76bb69fc 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -58,7 +58,7 @@ public static Hosting Initialize( IList chainElements = new List(); foreach (X509ChainElement element in chain.ChainElements) { - chainElements.Add(element.Certificate); + chainElements.Add(new X509Certificate2(element.Certificate)); Console.WriteLine(element.Certificate.RawData.ToString()); } From 3020217dc97c186b95e083fd765c096771e1f086 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 5 May 2020 16:18:48 -0700 Subject: [PATCH 040/111] refactor websocket cert http context --- .../Extensions/CertChainMapper.cs | 29 +++++++++++++++++++ .../Extensions/CertContext.cs | 11 ------- .../Hosting.cs | 15 ++-------- .../Startup.cs | 8 ++++- 4 files changed, 39 insertions(+), 24 deletions(-) create mode 100644 edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertChainMapper.cs delete mode 100644 edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertContext.cs diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertChainMapper.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertChainMapper.cs new file mode 100644 index 00000000000..d00ed3b17d7 --- /dev/null +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertChainMapper.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft. All rights reserved. +namespace Microsoft.Azure.Devices.Edge.Hub.Http.Extensions +{ + using System.Collections.Generic; + using System.Security.Cryptography.X509Certificates; + + public static class CertChainMapper // TODO: Replace hacky POC + { + static Dictionary> certsToChain = new Dictionary>(); + + public static void ImportCertChain(string thumbprint, X509ChainElementCollection chainElements) + { + IList certChainCopy = new List(); + foreach (X509ChainElement chainElement in chainElements) + { + certChainCopy.Add(new X509Certificate2(chainElement.Certificate)); + } + + certsToChain[thumbprint] = certChainCopy; + } + + public static IList ExtractCertChain(string thumbprint) + { + IList certChain = certsToChain[thumbprint]; + certsToChain.Remove(thumbprint); + return certChain; + } + } +} diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertContext.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertContext.cs deleted file mode 100644 index 2e0afea959e..00000000000 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertContext.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -namespace Microsoft.Azure.Devices.Edge.Hub.Http.Extensions -{ - using System.Collections.Generic; - using System.Security.Cryptography.X509Certificates; - - public static class CertContext // TODO: Replace hacky POC - { - public static Dictionary CertsToChain = new Dictionary(); - } -} diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index e4b76bb69fc..6f286980bb1 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -55,22 +55,13 @@ public static Hosting Initialize( { Console.WriteLine("---------------Setting map entry for tls feature----------------------"); Console.WriteLine(clientCert.RawData.ToString()); - IList chainElements = new List(); - foreach (X509ChainElement element in chain.ChainElements) - { - chainElements.Add(new X509Certificate2(element.Certificate)); - Console.WriteLine(element.Certificate.RawData.ToString()); - } - Console.WriteLine($"---------------------{JsonConvert.SerializeObject(chainElements)}-----------------------"); + Console.WriteLine($"---------------------{JsonConvert.SerializeObject(chain.ChainElements)}-----------------------"); Console.WriteLine($"---------------------------{clientCert.Thumbprint}----------------------------------"); - CertContext.CertsToChain[clientCert.Thumbprint] = new TlsConnectionFeatureExtended - { - ChainElements = chainElements - }; + CertChainMapper.ImportCertChain(clientCert.Thumbprint, chain.ChainElements); - Console.WriteLine($"---------------Count of chain elements: {chainElements.Count}----------------------"); + Console.WriteLine($"---------------Count of chain elements: {chain.ChainElements.Count}----------------------"); return true; }, diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index a1a9abad0fe..77b6786e888 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -2,6 +2,8 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service { using System; + using System.Collections.Generic; + using System.Security.Cryptography.X509Certificates; using System.Threading.Tasks; using Autofac; using Autofac.Extensions.DependencyInjection; @@ -59,7 +61,11 @@ public void Configure(IApplicationBuilder app) async (context, next) => { Console.WriteLine($"---------------Retrieving tls feature from map----------------------"); - TlsConnectionFeatureExtended tlsConnectionFeatureExtended = CertContext.CertsToChain[context.Connection.ClientCertificate.Thumbprint]; // TODO: remove from dict + IList certChain = CertChainMapper.ExtractCertChain(context.Connection.ClientCertificate.Thumbprint); + TlsConnectionFeatureExtended tlsConnectionFeatureExtended = new TlsConnectionFeatureExtended + { + ChainElements = certChain + }; context.Features.Set(tlsConnectionFeatureExtended); Console.WriteLine($"---------------Retrieve successful----------------------"); await next(); From 272f450a55bd556f745e0e86268afed7633a156a Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 5 May 2020 17:12:26 -0700 Subject: [PATCH 041/111] clean up cert mapper logic --- .../Extensions/CertChainMapper.cs | 30 +++++++++++++++---- .../Hosting.cs | 7 +---- .../Startup.cs | 13 ++++---- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertChainMapper.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertChainMapper.cs index d00ed3b17d7..2d40ca6e266 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertChainMapper.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertChainMapper.cs @@ -1,12 +1,17 @@ // Copyright (c) Microsoft. All rights reserved. namespace Microsoft.Azure.Devices.Edge.Hub.Http.Extensions { + using System.Collections.Concurrent; using System.Collections.Generic; using System.Security.Cryptography.X509Certificates; + using AspNetCore.Http; + using Microsoft.Azure.Devices.Edge.Util; + using Microsoft.Extensions.Logging; public static class CertChainMapper // TODO: Replace hacky POC { - static Dictionary> certsToChain = new Dictionary>(); + // static readonly ILogger Log = Logger.Factory.CreateLogger(); + static ConcurrentDictionary> certsToChain = new ConcurrentDictionary>(); public static void ImportCertChain(string thumbprint, X509ChainElementCollection chainElements) { @@ -19,11 +24,26 @@ public static void ImportCertChain(string thumbprint, X509ChainElementCollection certsToChain[thumbprint] = certChainCopy; } - public static IList ExtractCertChain(string thumbprint) + // TODO: log in the case where remove fails (there must be concurrent overlapping connections which shouldn't happen) + public static Option> ExtractCertChain(ConnectionInfo connectionInfo) { - IList certChain = certsToChain[thumbprint]; - certsToChain.Remove(thumbprint); - return certChain; + if (connectionInfo.ClientCertificate != null) + { + X509Certificate2 clientCertificate = connectionInfo.ClientCertificate; + IList certChain; + certsToChain.TryRemove(clientCertificate.Thumbprint, out certChain); + + if (certChain == null) + { + return Option.None>(); + } + else + { + return Option.Some(certChain); + } + } + + return Option.None>(); } } } diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 6f286980bb1..4916e0340bc 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -51,7 +51,7 @@ public static Hosting Initialize( new HttpsConnectionAdapterOptions() { ServerCertificate = serverCertificate, - ClientCertificateValidation = (clientCert, chain, policyErrors) => // TODO: Store cert and add to context in startup. Inject TlsFeatures into Startup class. Eliminate hacky POC. + ClientCertificateValidation = (clientCert, chain, policyErrors) => // TODO: verify that this runs only if certificate provided { Console.WriteLine("---------------Setting map entry for tls feature----------------------"); Console.WriteLine(clientCert.RawData.ToString()); @@ -82,10 +82,5 @@ public static Hosting Initialize( IContainer container = webHost.Services.GetService(typeof(IStartup)) is Startup startup ? startup.Container : null; return new Hosting(webHost, container); } - - // static void ClientCertificateValidation(X509Certificate2 clientCert, X509Chain chain, SslPolicyErrors policyErrors) - // { - - // } } } diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index 77b6786e888..61e51224b1d 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -61,12 +61,15 @@ public void Configure(IApplicationBuilder app) async (context, next) => { Console.WriteLine($"---------------Retrieving tls feature from map----------------------"); - IList certChain = CertChainMapper.ExtractCertChain(context.Connection.ClientCertificate.Thumbprint); - TlsConnectionFeatureExtended tlsConnectionFeatureExtended = new TlsConnectionFeatureExtended + Option> certChainOption = CertChainMapper.ExtractCertChain(context.Connection); + certChainOption.ForEach(certChain => { - ChainElements = certChain - }; - context.Features.Set(tlsConnectionFeatureExtended); + TlsConnectionFeatureExtended tlsConnectionFeatureExtended = new TlsConnectionFeatureExtended + { + ChainElements = certChain + }; + context.Features.Set(tlsConnectionFeatureExtended); + }); Console.WriteLine($"---------------Retrieve successful----------------------"); await next(); }); From 41a44fd64a9dc91f4ebe06e2c5b77e90b113b2ac Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 5 May 2020 18:05:29 -0700 Subject: [PATCH 042/111] remove logging --- .../identity/ClientCredentialsFactory.cs | 6 ------ .../Extensions/HttpContextExtensions.cs | 7 ------- .../middleware/AuthenticationMiddleware.cs | 2 -- .../middleware/WebSocketHandlingMiddleware.cs | 7 ------- .../DeviceIdentityProvider.cs | 19 ------------------- .../Hosting.cs | 9 --------- .../Startup.cs | 2 -- 7 files changed, 52 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/identity/ClientCredentialsFactory.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/identity/ClientCredentialsFactory.cs index 2741261e775..76e77c433aa 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/identity/ClientCredentialsFactory.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/identity/ClientCredentialsFactory.cs @@ -31,12 +31,6 @@ public ClientCredentialsFactory(IIdentityProvider identityProvider, string calle public IClientCredentials GetWithX509Cert(string deviceId, string moduleId, string deviceClientType, X509Certificate2 clientCertificate, IList clientChainCertificate) { - Console.WriteLine($"------------------Remote cert: {clientCertificate.RawData.ToString()}------------------"); - foreach (X509Certificate2 cert in clientChainCertificate) - { - Console.WriteLine($"------------------Chain cert: {cert.RawData.ToString()}------------------"); - } - string productInfo = string.Join(" ", deviceClientType, this.callerProductInfo).Trim(); IIdentity identity = this.identityProvider.Create(deviceId, moduleId); return new X509CertCredentials(identity, productInfo, clientCertificate, clientChainCertificate); diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs index ef63ccc9b1a..6901eec86b9 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs @@ -11,13 +11,6 @@ public static class HttpContextExtensions public static IList GetClientCertificateChain(this HttpContext context) { var feature = context.Features.Get(); - - Console.WriteLine($"-------------CLIENT CERT CHAIN NULL CHECK: {feature == null} {feature.ChainElements.Count == 0}---------------"); - foreach (X509Certificate2 chainedCert in feature.ChainElements) - { - Console.WriteLine($"------------------Chain cert: {chainedCert.RawData.ToString()}------------------"); - } - return (feature == null) ? new List() : feature.ChainElements; } } diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/AuthenticationMiddleware.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/AuthenticationMiddleware.cs index 658e2354885..7f8765e8db6 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/AuthenticationMiddleware.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/AuthenticationMiddleware.cs @@ -83,13 +83,11 @@ public async Task Invoke(HttpContext context) if (clientCertificate != null) { - Console.WriteLine("------------------CLIENT CERT DEFINED-----------------------"); IList certChain = context.GetClientCertificateChain(); clientCredentials = this.identityFactory.GetWithX509Cert(deviceId, moduleId, string.Empty, clientCertificate, certChain); } else { - Console.WriteLine("------------------CLIENT CERT NULL-----------------------"); // Authorization header may be present in the QueryNameValuePairs as per Azure standards, // So check in the query parameters first. List authorizationQueryParameters = context.Request.Query diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/WebSocketHandlingMiddleware.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/WebSocketHandlingMiddleware.cs index f9546be62da..53704b8eed8 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/WebSocketHandlingMiddleware.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/WebSocketHandlingMiddleware.cs @@ -73,16 +73,9 @@ async Task ProcessRequestAsync(HttpContext context, IWebSocketListener listener, X509Certificate2 cert = await context.Connection.GetClientCertificateAsync(); - // TODO: remove - Console.WriteLine($"------------------Remote cert: {cert.RawData.ToString()}------------------"); if (cert != null) { IList certChain = context.GetClientCertificateChain(); - foreach (X509Certificate2 chainedCert in certChain) - { - Console.WriteLine($"------------------Chain cert: {chainedCert.RawData.ToString()}------------------"); - } - await listener.ProcessWebSocketRequestAsync(webSocket, localEndPoint, remoteEndPoint, correlationId, cert, certChain); } else diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs index 6216fa2eda7..11e07bd1926 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs @@ -78,24 +78,11 @@ public async Task GetAsync(string clientId, string username, st return UnauthenticatedDeviceIdentity.Instance; } - Console.WriteLine($"------------Device credential error: {deviceCredentials.ToString()} | Client id error: {!clientId.Equals(deviceCredentials.Identity.Id, StringComparison.Ordinal)}--------------"); - if (deviceCredentials is ICertificateCredentials) { - foreach (X509Certificate2 cert in this.remoteCertificateChain) - { - Console.WriteLine($"------------------GetAsync() owned chain cert: {cert.RawData.ToString()}------------------"); - } - ICertificateCredentials tmpCredentials = (ICertificateCredentials)deviceCredentials; X509Certificate2 remoteCertificate = tmpCredentials.ClientCertificate; IList remoteCertificateChain = tmpCredentials.ClientCertificateChain; - - Console.WriteLine($"------------------Remote cert: {remoteCertificate.RawData.ToString()}------------------"); - foreach (X509Certificate2 cert in remoteCertificateChain) - { - Console.WriteLine($"------------------Chain cert: {cert.RawData.ToString()}------------------"); - } } if (deviceCredentials == null @@ -121,12 +108,6 @@ public void RegisterConnectionCertificate(X509Certificate2 certificate, IList // TODO: verify that this runs only if certificate provided { - Console.WriteLine("---------------Setting map entry for tls feature----------------------"); - Console.WriteLine(clientCert.RawData.ToString()); - - Console.WriteLine($"---------------------{JsonConvert.SerializeObject(chain.ChainElements)}-----------------------"); - Console.WriteLine($"---------------------------{clientCert.Thumbprint}----------------------------------"); - CertChainMapper.ImportCertChain(clientCert.Thumbprint, chain.ChainElements); - - Console.WriteLine($"---------------Count of chain elements: {chain.ChainElements.Count}----------------------"); - return true; }, ClientCertificateMode = certificateMode, diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index 61e51224b1d..93c8a006c19 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -60,7 +60,6 @@ public void Configure(IApplicationBuilder app) app.Use( async (context, next) => { - Console.WriteLine($"---------------Retrieving tls feature from map----------------------"); Option> certChainOption = CertChainMapper.ExtractCertChain(context.Connection); certChainOption.ForEach(certChain => { @@ -70,7 +69,6 @@ public void Configure(IApplicationBuilder app) }; context.Features.Set(tlsConnectionFeatureExtended); }); - Console.WriteLine($"---------------Retrieve successful----------------------"); await next(); }); From a82de496155b0ceb06e3ed045509083ec75822f8 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 5 May 2020 18:11:46 -0700 Subject: [PATCH 043/111] remove more logging --- .../Microsoft.Azure.Devices.Edge.Util/CertificateHelper.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/CertificateHelper.cs b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/CertificateHelper.cs index a8bdae64ed5..8d639c8e561 100644 --- a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/CertificateHelper.cs +++ b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/CertificateHelper.cs @@ -89,13 +89,6 @@ public static (bool, Option) ValidateCert(X509Certificate2 remoteCertifi Preconditions.CheckNotNull(remoteCertificateChain); Preconditions.CheckNotNull(trustedCACerts); - // TODO: remove - Console.WriteLine($"------------------Remote cert: {remoteCertificate.RawData.ToString()}------------------"); - foreach (X509Certificate2 cert in remoteCertificateChain) - { - Console.WriteLine($"------------------Chain cert: {cert.RawData.ToString()}------------------"); - } - (IList remoteCerts, Option errors) = BuildCertificateList(remoteCertificate, Option.Some(remoteCertificateChain)); if (errors.HasValue) { From ca626988d9d0a46398e3094433e7d179e97261c9 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 5 May 2020 18:13:06 -0700 Subject: [PATCH 044/111] remove unused dotnet url in images yaml: --- builds/misc/images.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/builds/misc/images.yaml b/builds/misc/images.yaml index 91e44d40d16..316fad0fe3c 100644 --- a/builds/misc/images.yaml +++ b/builds/misc/images.yaml @@ -201,8 +201,6 @@ jobs: - win-rs5 workspace: clean: all - variables: - NetCorePackageUri: https://download.visualstudio.microsoft.com/download/pr/56131147-65ea-47d6-a945-b0296c86e510/44b43b7cb27d55081e650b9a4188a419/dotnet-sdk-3.1.201-win-x64.exe steps: - template: ../templates/install-dotnet3.yaml From c5f05df84f23f08c81ed0283e904db896c249c05 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 5 May 2020 18:14:36 -0700 Subject: [PATCH 045/111] test consistency logging command factory --- .../commands/LoggingCommandFactoryTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Core.Test/commands/LoggingCommandFactoryTest.cs b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Core.Test/commands/LoggingCommandFactoryTest.cs index 98861f4a408..0a3e010a3ab 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Core.Test/commands/LoggingCommandFactoryTest.cs +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Core.Test/commands/LoggingCommandFactoryTest.cs @@ -132,7 +132,7 @@ public async Task ExecuteFailureTests( await Assert.ThrowsAsync(() => create.ExecuteAsync(token)); factoryMock.Verify(commandMethodBeingTested); - logMock.Verify(l => l.Log(LogLevel.Information, It.IsAny(), It.IsAny(), It.IsAny(), (Func)It.IsAny()), Times.Once); + logMock.Verify(l => l.Log(LogLevel.Information, It.IsAny(), It.IsAny(), It.IsAny(), (Func)It.IsAny()), Times.Once); logMock.Verify(l => l.Log(LogLevel.Error, It.IsAny(), It.IsAny(), It.IsAny(), (Func)It.IsAny()), Times.Once); } From 9bc442854e9a606fe151162140594bd3f441e99b Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 6 May 2020 10:05:45 -0700 Subject: [PATCH 046/111] eliminate static public class and move to instance --- .../Extensions/CertChainMapper.cs | 20 +++++++++++-------- .../Hosting.cs | 9 +++------ .../Startup.cs | 8 +++++--- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertChainMapper.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertChainMapper.cs index 2d40ca6e266..afff7ae73b0 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertChainMapper.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertChainMapper.cs @@ -8,12 +8,16 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Http.Extensions using Microsoft.Azure.Devices.Edge.Util; using Microsoft.Extensions.Logging; - public static class CertChainMapper // TODO: Replace hacky POC + public class CertChainMapper { - // static readonly ILogger Log = Logger.Factory.CreateLogger(); - static ConcurrentDictionary> certsToChain = new ConcurrentDictionary>(); + static readonly ILogger Log = Logger.Factory.CreateLogger(); + readonly ConcurrentDictionary> certsToChain = new ConcurrentDictionary>(); - public static void ImportCertChain(string thumbprint, X509ChainElementCollection chainElements) + public CertChainMapper() + { + } + + public void ImportCertChain(string thumbprint, X509ChainElementCollection chainElements) { IList certChainCopy = new List(); foreach (X509ChainElement chainElement in chainElements) @@ -21,20 +25,20 @@ public static void ImportCertChain(string thumbprint, X509ChainElementCollection certChainCopy.Add(new X509Certificate2(chainElement.Certificate)); } - certsToChain[thumbprint] = certChainCopy; + this.certsToChain[thumbprint] = certChainCopy; } - // TODO: log in the case where remove fails (there must be concurrent overlapping connections which shouldn't happen) - public static Option> ExtractCertChain(ConnectionInfo connectionInfo) + public Option> ExtractCertChain(ConnectionInfo connectionInfo) { if (connectionInfo.ClientCertificate != null) { X509Certificate2 clientCertificate = connectionInfo.ClientCertificate; IList certChain; - certsToChain.TryRemove(clientCertificate.Thumbprint, out certChain); + this.certsToChain.TryRemove(clientCertificate.Thumbprint, out certChain); if (certChain == null) { + Log.LogError($"Did not find cert chain for connection {connectionInfo.Id}"); return Option.None>(); } else diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index efe9c03a15d..a34ea411b60 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -1,21 +1,16 @@ // Copyright (c) Microsoft. All rights reserved. namespace Microsoft.Azure.Devices.Edge.Hub.Service { - using System; - using System.Collections.Generic; using System.Net; - using System.Net.Security; using System.Net.Sockets; using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; using Autofac; using Microsoft.AspNetCore.Hosting; - using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Server.Kestrel.Https; using Microsoft.Azure.Devices.Edge.Hub.Http.Extensions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; - using Newtonsoft.Json; public class Hosting { @@ -38,6 +33,7 @@ public static Hosting Initialize( { int port = configuration.GetValue("httpSettings:port", 443); var certificateMode = clientCertAuthEnabled ? ClientCertificateMode.AllowCertificate : ClientCertificateMode.NoCertificate; + CertChainMapper certChainMapper = new CertChainMapper(); IWebHostBuilder webHostBuilder = new WebHostBuilder() .UseKestrel( options => @@ -53,7 +49,7 @@ public static Hosting Initialize( ServerCertificate = serverCertificate, ClientCertificateValidation = (clientCert, chain, policyErrors) => // TODO: verify that this runs only if certificate provided { - CertChainMapper.ImportCertChain(clientCert.Thumbprint, chain.ChainElements); + certChainMapper.ImportCertChain(clientCert.Thumbprint, chain.ChainElements); return true; }, ClientCertificateMode = certificateMode, @@ -67,6 +63,7 @@ public static Hosting Initialize( { serviceCollection.AddSingleton(configuration); serviceCollection.AddSingleton(dependencyManager); + serviceCollection.AddSingleton(certChainMapper); }) .UseStartup(); IWebHost webHost = webHostBuilder.Build(); diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index 93c8a006c19..ab868a969e0 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -25,14 +25,17 @@ public class Startup : IStartup { readonly IDependencyManager dependencyManager; readonly IConfigurationRoot configuration; + readonly CertChainMapper certChainMapper; // ReSharper disable once UnusedParameter.Local public Startup( IConfigurationRoot configuration, - IDependencyManager dependencyManager) + IDependencyManager dependencyManager, + CertChainMapper certChainMapper) { this.configuration = Preconditions.CheckNotNull(configuration, nameof(configuration)); this.dependencyManager = Preconditions.CheckNotNull(dependencyManager, nameof(dependencyManager)); + this.certChainMapper = Preconditions.CheckNotNull(certChainMapper, nameof(certChainMapper)); } internal IContainer Container { get; private set; } @@ -56,11 +59,10 @@ public void Configure(IApplicationBuilder app) { app.UseWebSockets(); - // TODO: eliminate hacky POC and consolidate with the below response headers app.Use( async (context, next) => { - Option> certChainOption = CertChainMapper.ExtractCertChain(context.Connection); + Option> certChainOption = this.certChainMapper.ExtractCertChain(context.Connection); certChainOption.ForEach(certChain => { TlsConnectionFeatureExtended tlsConnectionFeatureExtended = new TlsConnectionFeatureExtended From 15f6c293af540b79563af652b0782ab0528b1968 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 6 May 2020 11:10:10 -0700 Subject: [PATCH 047/111] address self comments --- .../EdgeTlsTransport.cs | 2 +- .../middleware/WebSocketHandlingMiddleware.cs | 1 - .../DeviceIdentityProvider.cs | 7 ------- .../MqttProtocolHead.cs | 10 +++++----- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/EdgeTlsTransport.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/EdgeTlsTransport.cs index 9d1a36ed3d0..7e2e16ec960 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/EdgeTlsTransport.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/EdgeTlsTransport.cs @@ -44,7 +44,7 @@ protected override X509Principal CreateX509Principal(X509Certificate2 certificat protected override bool ValidateRemoteCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { // copy of the chain elements since they are destroyed after this method completes - this.remoteCertificateChain = chain == null ? new List() : chain.ChainElements.Cast().Select(element => element.Certificate).ToList(); + this.remoteCertificateChain = chain == null ? new List() : chain.ChainElements.Cast().Select(element => new X509Certificate2(element.Certificate)).ToList(); return base.ValidateRemoteCertificate(sender, certificate, chain, sslPolicyErrors); } } diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/WebSocketHandlingMiddleware.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/WebSocketHandlingMiddleware.cs index 53704b8eed8..a4d110bad13 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/WebSocketHandlingMiddleware.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/WebSocketHandlingMiddleware.cs @@ -72,7 +72,6 @@ async Task ProcessRequestAsync(HttpContext context, IWebSocketListener listener, var remoteEndPoint = new IPEndPoint(context.Connection.RemoteIpAddress, context.Connection.RemotePort); X509Certificate2 cert = await context.Connection.GetClientCertificateAsync(); - if (cert != null) { IList certChain = context.GetClientCertificateChain(); diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs index 11e07bd1926..3d7c9bc1786 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceIdentityProvider.cs @@ -78,13 +78,6 @@ public async Task GetAsync(string clientId, string username, st return UnauthenticatedDeviceIdentity.Instance; } - if (deviceCredentials is ICertificateCredentials) - { - ICertificateCredentials tmpCredentials = (ICertificateCredentials)deviceCredentials; - X509Certificate2 remoteCertificate = tmpCredentials.ClientCertificate; - IList remoteCertificateChain = tmpCredentials.ClientCertificateChain; - } - if (deviceCredentials == null || !clientId.Equals(deviceCredentials.Identity.Id, StringComparison.Ordinal) || !await this.authenticator.AuthenticateAsync(deviceCredentials)) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/MqttProtocolHead.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/MqttProtocolHead.cs index dfe1a314e98..7c11b458fd0 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/MqttProtocolHead.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/MqttProtocolHead.cs @@ -203,11 +203,11 @@ bool RemoteCertificateValidationCallback(DeviceIdentityProvider identityProvider { if (this.clientCertAuthAllowed && certificate != null) { - IList certChain = new List(); - foreach (X509ChainElement chainElement in chain.ChainElements) - { - certChain.Add(new X509Certificate2(chainElement.Certificate)); - } + IList certChain = chain?.ChainElements? + .Cast() + .Select(element => new X509Certificate2(element.Certificate)) + .ToList() + ?? new List(); identityProvider.RegisterConnectionCertificate(new X509Certificate2(certificate), certChain); } From 1c442014363c3d8b13438808fda8d05696e3e20f Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 6 May 2020 11:21:14 -0700 Subject: [PATCH 048/111] clean up using --- .../ModuleManagementHttpClient.cs | 1 - .../version_2018_06_28/ModuleManagementHttpClient.cs | 1 - .../version_2019_01_30/ModuleManagementHttpClient.cs | 1 - .../version_2019_10_22/ModuleManagementHttpClient.cs | 1 - .../version_2019_11_05/ModuleManagementHttpClient.cs | 1 - .../identity/ClientCredentialsFactory.cs | 1 - .../Extensions/HttpContextExtensions.cs | 1 - .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs | 3 --- 8 files changed, 10 deletions(-) diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/ModuleManagementHttpClient.cs b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/ModuleManagementHttpClient.cs index b84f9623cbd..ca7de4b9ae2 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/ModuleManagementHttpClient.cs +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/ModuleManagementHttpClient.cs @@ -8,7 +8,6 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Edgelet using System.Threading.Tasks; using Microsoft.Azure.Devices.Edge.Agent.Core; using Microsoft.Azure.Devices.Edge.Agent.Core.DeviceManager; - using Microsoft.Azure.Devices.Edge.Agent.Core.Metrics; using Microsoft.Azure.Devices.Edge.Agent.Edgelet.Models; using Microsoft.Azure.Devices.Edge.Agent.Edgelet.Versioning; using Microsoft.Azure.Devices.Edge.Util; diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2018_06_28/ModuleManagementHttpClient.cs b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2018_06_28/ModuleManagementHttpClient.cs index 0d1d8dcc039..53c2a54fe6a 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2018_06_28/ModuleManagementHttpClient.cs +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2018_06_28/ModuleManagementHttpClient.cs @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Edgelet.Version_2018_06_28 using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Devices.Edge.Agent.Core; - using Microsoft.Azure.Devices.Edge.Agent.Core.Metrics; using Microsoft.Azure.Devices.Edge.Agent.Edgelet.Version_2018_06_28.GeneratedCode; using Microsoft.Azure.Devices.Edge.Agent.Edgelet.Versioning; using Microsoft.Azure.Devices.Edge.Util; diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_01_30/ModuleManagementHttpClient.cs b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_01_30/ModuleManagementHttpClient.cs index 31332f5b7c2..2672d9ec439 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_01_30/ModuleManagementHttpClient.cs +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_01_30/ModuleManagementHttpClient.cs @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Edgelet.Version_2019_01_30 using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Devices.Edge.Agent.Core; - using Microsoft.Azure.Devices.Edge.Agent.Core.Metrics; using Microsoft.Azure.Devices.Edge.Agent.Edgelet.Version_2019_01_30.GeneratedCode; using Microsoft.Azure.Devices.Edge.Agent.Edgelet.Versioning; using Microsoft.Azure.Devices.Edge.Util; diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_10_22/ModuleManagementHttpClient.cs b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_10_22/ModuleManagementHttpClient.cs index 120a8ccce95..8a56ef26e89 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_10_22/ModuleManagementHttpClient.cs +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_10_22/ModuleManagementHttpClient.cs @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Edgelet.Version_2019_10_22 using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Devices.Edge.Agent.Core; - using Microsoft.Azure.Devices.Edge.Agent.Core.Metrics; using Microsoft.Azure.Devices.Edge.Agent.Edgelet.Version_2019_10_22.GeneratedCode; using Microsoft.Azure.Devices.Edge.Agent.Edgelet.Versioning; using Microsoft.Azure.Devices.Edge.Util; diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_11_05/ModuleManagementHttpClient.cs b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_11_05/ModuleManagementHttpClient.cs index 27a7749fbe8..2f96510c25a 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_11_05/ModuleManagementHttpClient.cs +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/version_2019_11_05/ModuleManagementHttpClient.cs @@ -15,7 +15,6 @@ namespace Microsoft.Azure.Devices.Edge.Agent.Edgelet.Version_2019_11_05 using Microsoft.Azure.Devices.Edge.Util; using Microsoft.Azure.Devices.Edge.Util.Edged; using Microsoft.Azure.Devices.Edge.Util.TransientFaultHandling; - using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Disk = Microsoft.Azure.Devices.Edge.Agent.Edgelet.Models.Disk; using Identity = Microsoft.Azure.Devices.Edge.Agent.Edgelet.Models.Identity; diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/identity/ClientCredentialsFactory.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/identity/ClientCredentialsFactory.cs index 76e77c433aa..a5c147a5815 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/identity/ClientCredentialsFactory.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/identity/ClientCredentialsFactory.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. namespace Microsoft.Azure.Devices.Edge.Hub.Core.Identity { - using System; using System.Collections.Generic; using System.Security.Cryptography.X509Certificates; using Microsoft.Azure.Devices.Client; diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs index 6901eec86b9..6dfd3a0dbde 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/HttpContextExtensions.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. namespace Microsoft.Azure.Devices.Edge.Hub.Http.Extensions { - using System; using System.Collections.Generic; using System.Security.Cryptography.X509Certificates; using Microsoft.AspNetCore.Http; diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index ab868a969e0..5dd27ddfdfb 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -4,13 +4,10 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service using System; using System.Collections.Generic; using System.Security.Cryptography.X509Certificates; - using System.Threading.Tasks; using Autofac; using Autofac.Extensions.DependencyInjection; - using Microsoft.AspNetCore.Authentication.Certificate; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; - using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.Devices.Client; using Microsoft.Azure.Devices.Edge.Hub.Core; From 3e74ce5ed93e7aa5c27dbfd2e94e5bfb2bc99e03 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 6 May 2020 12:21:54 -0700 Subject: [PATCH 049/111] remove prereqs to see if truly needed --- builds/checkin/dotnet.yaml | 8 -------- builds/ci/dotnet.yaml | 5 ----- 2 files changed, 13 deletions(-) diff --git a/builds/checkin/dotnet.yaml b/builds/checkin/dotnet.yaml index e3e0d6466c7..44a57bd45a9 100644 --- a/builds/checkin/dotnet.yaml +++ b/builds/checkin/dotnet.yaml @@ -33,10 +33,6 @@ jobs: vmImage: "ubuntu-16.04" steps: - template: ../templates/install-dotnet3.yaml - - task: Bash@3 - displayName: Install Prerequisites - inputs: - filePath: scripts/linux/installPrereqs.sh - task: Bash@3 displayName: Build inputs: @@ -64,10 +60,6 @@ jobs: vmImage: "vs2017-win2016" steps: - template: ../templates/install-dotnet3.yaml - - task: PowerShell@2 - displayName: Install Prerequisites - inputs: - filePath: scripts/windows/setup/Install-Prerequisites.ps1 - task: PowerShell@2 displayName: Build inputs: diff --git a/builds/ci/dotnet.yaml b/builds/ci/dotnet.yaml index 0998467059a..a03c06d4055 100644 --- a/builds/ci/dotnet.yaml +++ b/builds/ci/dotnet.yaml @@ -32,11 +32,6 @@ jobs: IotHubConnStr2, IotHubMqttHeadCert - template: ../templates/install-dotnet3.yaml - - task: Bash@3 - displayName: Install Prerequisites needed for RocksDB integration tests - inputs: - filePath: scripts/linux/installPrereqs.sh - arguments: -u $(NetCorePackageUriLinux) - pwsh: | $store = [System.Security.Cryptography.X509Certificates.X509Store]::new('Root', 'CurrentUser') $store.Open('ReadWrite') From c49112c6c15a4a91f36cf8e0789e2b7fe179b62f Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 6 May 2020 13:15:53 -0700 Subject: [PATCH 050/111] prereqs needed for ci and checkin on linux only --- builds/checkin/dotnet.yaml | 4 ++++ builds/ci/dotnet.yaml | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/builds/checkin/dotnet.yaml b/builds/checkin/dotnet.yaml index 44a57bd45a9..4c23a5e3e8b 100644 --- a/builds/checkin/dotnet.yaml +++ b/builds/checkin/dotnet.yaml @@ -33,6 +33,10 @@ jobs: vmImage: "ubuntu-16.04" steps: - template: ../templates/install-dotnet3.yaml + - task: Bash@3 + displayName: Install Prerequisites + inputs: + filePath: scripts/linux/installPrereqs.sh - task: Bash@3 displayName: Build inputs: diff --git a/builds/ci/dotnet.yaml b/builds/ci/dotnet.yaml index a03c06d4055..0998467059a 100644 --- a/builds/ci/dotnet.yaml +++ b/builds/ci/dotnet.yaml @@ -32,6 +32,11 @@ jobs: IotHubConnStr2, IotHubMqttHeadCert - template: ../templates/install-dotnet3.yaml + - task: Bash@3 + displayName: Install Prerequisites needed for RocksDB integration tests + inputs: + filePath: scripts/linux/installPrereqs.sh + arguments: -u $(NetCorePackageUriLinux) - pwsh: | $store = [System.Security.Cryptography.X509Certificates.X509Store]::new('Root', 'CurrentUser') $store.Open('ReadWrite') From 28df313e7648bc4df6869e0b1a328351c901d2cc Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 6 May 2020 16:12:29 -0700 Subject: [PATCH 051/111] use newtonsoft json in edgehub service --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index 5dd27ddfdfb..bed6835496a 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -41,7 +41,7 @@ public Startup( public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMemoryCache(); - services.AddMvc(options => options.Filters.Add(typeof(ExceptionFilter))); + services.AddMvc(options => options.Filters.Add(typeof(ExceptionFilter))).AddNewtonsoftJson(); services.Configure(options => { options.Filters.Add(new RequireHttpsAttribute()); From 691f626177d50adf5d8499056100f9d1e7be7e07 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 6 May 2020 16:25:26 -0700 Subject: [PATCH 052/111] remove windows install prereq script: unused --- .../windows/setup/Install-Prerequisites.ps1 | 79 ------------------- 1 file changed, 79 deletions(-) delete mode 100644 scripts/windows/setup/Install-Prerequisites.ps1 diff --git a/scripts/windows/setup/Install-Prerequisites.ps1 b/scripts/windows/setup/Install-Prerequisites.ps1 deleted file mode 100644 index 84852b42d45..00000000000 --- a/scripts/windows/setup/Install-Prerequisites.ps1 +++ /dev/null @@ -1,79 +0,0 @@ -<# - # Installs .NET Core, Nuget, and Python. - #> - -param ( - [ValidateNotNullOrEmpty()] - [ValidateScript( {Invoke-WebRequest $_ -DisableKeepAlive -UseBasicParsing -Method "Head"})] - [String]$NugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe", - - [ValidateNotNullOrEmpty()] - [ValidateScript( {Invoke-WebRequest $_ -DisableKeepAlive -UseBasicParsing -Method "Head"})] - [String]$PythonUrl = "https://www.python.org/ftp/python/2.7.14/python-2.7.14.msi", - - [ValidateNotNullOrEmpty()] - [ValidateScript( {Test-Path $_ -PathType Container})] - [String]$AgentWorkFolder = $Env:AGENT_WORKFOLDER, - - [ValidateNotNullOrEmpty()] - [ValidateScript( {Test-Path $_ -PathType Container})] - [String]$BuildRepositoryLocalPath = $Env:BUILD_REPOSITORY_LOCALPATH, - - [Switch]$Python, - [Switch]$Nuget -) - -Set-StrictMode -Version "Latest" -$ErrorActionPreference = "Stop" - -<# - # Prepare environment - #> - -Import-Module ([IO.Path]::Combine($PSScriptRoot, "..", "Defaults.psm1")) -Force - -if (-not $AgentWorkFolder) { - $AgentWorkFolder = DefaultAgentWorkFolder -} - -if (-not $BuildRepositoryLocalPath) { - $BuildRepositoryLocalPath = DefaultBuildRepositoryLocalPath -} - -$All = -not $Python -and -not $Nuget - -[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - -<# - # Install Nuget - #> - -$NugetInstallPath = Join-Path $AgentWorkFolder "nuget" -$NugetExe = Join-Path $NugetInstallPath "nuget.exe" -if ($Nuget -or $All) { - if (Test-Path $NugetInstallPath) { - Remove-Item $NugetInstalLPath -Force -Recurse - } - New-Item $NugetInstallPath -ItemType "Directory" -Force - - Write-Host "Downloading Nuget." - (New-Object System.Net.WebClient).DownloadFile($NugetUrl, $NugetExe) -} - -<# - # Install Python - #> -if ($Python -or $All) { - $PythonInstallPath = Join-Path $AgentWorkFolder "python" - if (Test-Path $PythonInstallPath) { - Remove-Item $PythonInstallPath -Force -Recurse - } - New-Item $PythonInstallPath -ItemType "Directory" -Force - - Write-Host "Downloading Python." - $PythonMsi = Join-Path $PythonInstallPath "python.msi" - (New-Object System.Net.WebClient).DownloadFile($PythonUrl, $PythonMsi) - cmd /c start /wait msiexec /passive /package $PythonMsi -} - -Write-Host "Done!" From ab2304ded1e20142b6767c1ac40c58f5d73fae13 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 6 May 2020 19:07:01 -0700 Subject: [PATCH 053/111] use new routing in edgeHub --- .../Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index bed6835496a..a25a14003dd 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -41,7 +41,7 @@ public Startup( public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMemoryCache(); - services.AddMvc(options => options.Filters.Add(typeof(ExceptionFilter))).AddNewtonsoftJson(); + services.AddRazorPages(); services.Configure(options => { options.Filters.Add(new RequireHttpsAttribute()); @@ -100,6 +100,12 @@ public void Configure(IApplicationBuilder app) }); app.UseMvc(); + app.UseRouting(); + + app.UseEndpoints(endpoints => + { + endpoints.MapRazorPages(); + }); } IContainer BuildContainer(IServiceCollection services) From 44d6e3f323cae5b7435f48e788e83d03bb1d8597 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 7 May 2020 09:31:49 -0700 Subject: [PATCH 054/111] prior attempted aspnet fix --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index a25a14003dd..1ef2ba8ff4e 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -41,11 +41,10 @@ public Startup( public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMemoryCache(); - services.AddRazorPages(); + services.AddControllers().AddNewtonsoftJson(); services.Configure(options => { options.Filters.Add(new RequireHttpsAttribute()); - options.EnableEndpointRouting = false; }); this.Container = this.BuildContainer(services); @@ -104,7 +103,7 @@ public void Configure(IApplicationBuilder app) app.UseEndpoints(endpoints => { - endpoints.MapRazorPages(); + endpoints.MapControllers(); }); } From 13cd7f35d3f911e8e4dc7c65fb30ac8179c2d15d Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 7 May 2020 09:42:19 -0700 Subject: [PATCH 055/111] no more useMvc() --- edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index 1ef2ba8ff4e..1d3fa69b0ba 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -98,7 +98,6 @@ public void Configure(IApplicationBuilder app) await next(); }); - app.UseMvc(); app.UseRouting(); app.UseEndpoints(endpoints => From a744aa1a1f274a42138d1279ad4da4a3eff0c82a Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 7 May 2020 09:55:34 -0700 Subject: [PATCH 056/111] new e2e tests use dotnet 3.1 --- builds/e2e/templates/e2e-setup.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builds/e2e/templates/e2e-setup.yaml b/builds/e2e/templates/e2e-setup.yaml index 55dc3483617..43c75ff88e4 100644 --- a/builds/e2e/templates/e2e-setup.yaml +++ b/builds/e2e/templates/e2e-setup.yaml @@ -76,7 +76,7 @@ steps: $testDir = '$(Build.SourcesDirectory)/test/Microsoft.Azure.Devices.Edge.Test' dotnet build $testDir - $binDir = Convert-Path "$testDir/bin/Debug/netcoreapp2.1" + $binDir = Convert-Path "$testDir/bin/Debug/netcoreapp3.1" Write-Output "##vso[task.setvariable variable=binDir]$binDir" displayName: Build tests From a9a906b31a87f0d4fed02f9cabbe14907f030fe5 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 7 May 2020 09:56:26 -0700 Subject: [PATCH 057/111] service deployment use dotnet 3.1 --- builds/service/service-deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builds/service/service-deployment.yaml b/builds/service/service-deployment.yaml index 5f72acf10a7..4a433cc3ff6 100644 --- a/builds/service/service-deployment.yaml +++ b/builds/service/service-deployment.yaml @@ -30,7 +30,7 @@ steps: $testDir = '$(Build.SourcesDirectory)/test/Microsoft.Azure.Devices.Edge.Test' dotnet build $testDir - $binDir = Convert-Path "$testDir/bin/Debug/netcoreapp2.1" + $binDir = Convert-Path "$testDir/bin/Debug/netcoreapp3.1" Write-Output "##vso[task.setvariable variable=binDir]$binDir" displayName: Build tests From 7f8f5c825ea35d8b366b5bb589cb021341bc35d1 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 7 May 2020 15:51:25 -0700 Subject: [PATCH 058/111] attempt workaround for certmapper --- .../{Extensions => }/CertChainMapper.cs | 0 .../middleware/CertChainSavingMiddleware.cs | 49 ++++++++++++++++++ .../Hosting.cs | 6 ++- .../Startup.cs | 50 +++++++++++++++---- 4 files changed, 94 insertions(+), 11 deletions(-) rename edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/{Extensions => }/CertChainMapper.cs (100%) create mode 100644 edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/CertChainSavingMiddleware.cs diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertChainMapper.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/CertChainMapper.cs similarity index 100% rename from edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Extensions/CertChainMapper.cs rename to edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/CertChainMapper.cs diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/CertChainSavingMiddleware.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/CertChainSavingMiddleware.cs new file mode 100644 index 00000000000..ca390c240e2 --- /dev/null +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/CertChainSavingMiddleware.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft. All rights reserved. +namespace Microsoft.Azure.Devices.Edge.Hub.Http.Middleware +{ + using System.Collections.Generic; + using System.Net.Security; + using System.Security.Cryptography.X509Certificates; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Connections; + using Microsoft.Azure.Devices.Edge.Hub.Http.Extensions; + + public class CertChainSavingMiddleware + { + readonly ConnectionDelegate next; + + public CertChainSavingMiddleware(ConnectionDelegate next) + { + this.next = next; + } + + public async Task OnConnectionAsync(ConnectionContext context) + { + await Task.Yield(); + + SslStream sslStream = context.Features.Get(); + IList certChainCopy = new List(); + + // TODO: should we leave inner stream open? + new SslStream(sslStream, true, (_, clientCert, chain, policyErrors) => + { + foreach (X509ChainElement chainElement in chain.ChainElements) + { + certChainCopy.Add(new X509Certificate2(chainElement.Certificate)); + } + + return true; + }); + + TlsConnectionFeatureExtended tlsConnectionFeatureExtended = new TlsConnectionFeatureExtended + { + ChainElements = certChainCopy + }; + context.Features.Set(tlsConnectionFeatureExtended); + } + + static class Events + { + } + } +} diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index a34ea411b60..ffecc371483 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -9,6 +9,7 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Server.Kestrel.Https; using Microsoft.Azure.Devices.Edge.Hub.Http.Extensions; + using Microsoft.Azure.Devices.Edge.Hub.Http.Middleware; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -49,12 +50,13 @@ public static Hosting Initialize( ServerCertificate = serverCertificate, ClientCertificateValidation = (clientCert, chain, policyErrors) => // TODO: verify that this runs only if certificate provided { - certChainMapper.ImportCertChain(clientCert.Thumbprint, chain.ChainElements); + // certChainMapper.ImportCertChain(clientCert.Thumbprint, chain.ChainElements); return true; }, ClientCertificateMode = certificateMode, SslProtocols = sslProtocols - }); + }) + .Use(next => new CertChainSavingMiddleware(next).OnConnectionAsync); }); }) .UseSockets() diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index 1d3fa69b0ba..73a828c9d3a 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -6,6 +6,7 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service using System.Security.Cryptography.X509Certificates; using Autofac; using Autofac.Extensions.DependencyInjection; + using Microsoft.AspNetCore.Authentication.Certificate; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; @@ -40,6 +41,37 @@ public Startup( // This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { + // services.AddAuthentication( + // CertificateAuthenticationDefaults.AuthenticationScheme) + // .AddCertificate(options => + // { + // options.Events = new CertificateAuthenticationEvents + // { + // OnCertificateValidated = context => + // { + // CertificateValidatedContext context1; + // + // var claims = new[] + // { + // new Claim( + // ClaimTypes.NameIdentifier, + // context.ClientCertificate.Subject, + // ClaimValueTypes.String, + // context.Options.ClaimsIssuer), + // new Claim(ClaimTypes.Name, + // context.ClientCertificate.Subject, + // ClaimValueTypes.String, + // context.Options.ClaimsIssuer) + // }; + // + // context.Principal = new ClaimsPrincipal( + // new ClaimsIdentity(claims, context.Scheme.Name)); + // context.Success(); + // + // return Task.CompletedTask; + // } + // }; + // }); services.AddMemoryCache(); services.AddControllers().AddNewtonsoftJson(); services.Configure(options => @@ -58,15 +90,15 @@ public void Configure(IApplicationBuilder app) app.Use( async (context, next) => { - Option> certChainOption = this.certChainMapper.ExtractCertChain(context.Connection); - certChainOption.ForEach(certChain => - { - TlsConnectionFeatureExtended tlsConnectionFeatureExtended = new TlsConnectionFeatureExtended - { - ChainElements = certChain - }; - context.Features.Set(tlsConnectionFeatureExtended); - }); + // Option> certChainOption = this.certChainMapper.ExtractCertChain(context.Connection); + // certChainOption.ForEach(certChain => + // { + // TlsConnectionFeatureExtended tlsConnectionFeatureExtended = new TlsConnectionFeatureExtended + // { + // ChainElements = certChain + // }; + // context.Features.Set(tlsConnectionFeatureExtended); + // }); await next(); }); From cd3d064bbe8a37e798a72ff23aa205be0e35070b Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 7 May 2020 18:12:18 -0700 Subject: [PATCH 059/111] hacky workaround to make aspnet middleware set sslstream --- .../middleware/CertChainSavingMiddleware.cs | 2 +- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/CertChainSavingMiddleware.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/CertChainSavingMiddleware.cs index ca390c240e2..a7c1723d063 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/CertChainSavingMiddleware.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/CertChainSavingMiddleware.cs @@ -25,7 +25,7 @@ public async Task OnConnectionAsync(ConnectionContext context) IList certChainCopy = new List(); // TODO: should we leave inner stream open? - new SslStream(sslStream, true, (_, clientCert, chain, policyErrors) => + new SslStream(sslStream, false, (_, clientCert, chain, policyErrors) => { foreach (X509ChainElement chainElement in chain.ChainElements) { diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index ffecc371483..6b7cf8bd675 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -47,7 +47,10 @@ public static Hosting Initialize( listenOptions.UseHttps( new HttpsConnectionAdapterOptions() { - ServerCertificate = serverCertificate, + ServerCertificateSelector = (connectionContext, _) => + { + return serverCertificate; + }, ClientCertificateValidation = (clientCert, chain, policyErrors) => // TODO: verify that this runs only if certificate provided { // certChainMapper.ImportCertChain(clientCert.Thumbprint, chain.ChainElements); From 56b88f7efa9db47f5693fdc4ef987ba2fc9351cd Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 7 May 2020 18:32:14 -0700 Subject: [PATCH 060/111] clean up custom middleware --- .../middleware/CertChainSavingMiddleware.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/CertChainSavingMiddleware.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/CertChainSavingMiddleware.cs index a7c1723d063..0092ea33e9f 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/CertChainSavingMiddleware.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/CertChainSavingMiddleware.cs @@ -19,13 +19,10 @@ public CertChainSavingMiddleware(ConnectionDelegate next) public async Task OnConnectionAsync(ConnectionContext context) { - await Task.Yield(); - SslStream sslStream = context.Features.Get(); - IList certChainCopy = new List(); - // TODO: should we leave inner stream open? - new SslStream(sslStream, false, (_, clientCert, chain, policyErrors) => + IList certChainCopy = new List(); + SslStream newSslStream = new SslStream(sslStream, true, (_, clientCert, chain, policyErrors) => // TODO: should we leave inner stream open? { foreach (X509ChainElement chainElement in chain.ChainElements) { @@ -34,12 +31,15 @@ public async Task OnConnectionAsync(ConnectionContext context) return true; }); + newSslStream.Close(); TlsConnectionFeatureExtended tlsConnectionFeatureExtended = new TlsConnectionFeatureExtended { ChainElements = certChainCopy }; context.Features.Set(tlsConnectionFeatureExtended); + + await this.next(context); } static class Events From c21e976da6a4010170fae9cf1a9c8e052e112424 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 7 May 2020 23:52:36 -0700 Subject: [PATCH 061/111] eliminate cert mapper --- .../CertChainMapper.cs | 53 ----------------- .../middleware/CertChainSavingMiddleware.cs | 49 ---------------- .../Hosting.cs | 36 ++++++++---- .../Startup.cs | 57 +------------------ 4 files changed, 27 insertions(+), 168 deletions(-) delete mode 100644 edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/CertChainMapper.cs delete mode 100644 edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/CertChainSavingMiddleware.cs diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/CertChainMapper.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/CertChainMapper.cs deleted file mode 100644 index afff7ae73b0..00000000000 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/CertChainMapper.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -namespace Microsoft.Azure.Devices.Edge.Hub.Http.Extensions -{ - using System.Collections.Concurrent; - using System.Collections.Generic; - using System.Security.Cryptography.X509Certificates; - using AspNetCore.Http; - using Microsoft.Azure.Devices.Edge.Util; - using Microsoft.Extensions.Logging; - - public class CertChainMapper - { - static readonly ILogger Log = Logger.Factory.CreateLogger(); - readonly ConcurrentDictionary> certsToChain = new ConcurrentDictionary>(); - - public CertChainMapper() - { - } - - public void ImportCertChain(string thumbprint, X509ChainElementCollection chainElements) - { - IList certChainCopy = new List(); - foreach (X509ChainElement chainElement in chainElements) - { - certChainCopy.Add(new X509Certificate2(chainElement.Certificate)); - } - - this.certsToChain[thumbprint] = certChainCopy; - } - - public Option> ExtractCertChain(ConnectionInfo connectionInfo) - { - if (connectionInfo.ClientCertificate != null) - { - X509Certificate2 clientCertificate = connectionInfo.ClientCertificate; - IList certChain; - this.certsToChain.TryRemove(clientCertificate.Thumbprint, out certChain); - - if (certChain == null) - { - Log.LogError($"Did not find cert chain for connection {connectionInfo.Id}"); - return Option.None>(); - } - else - { - return Option.Some(certChain); - } - } - - return Option.None>(); - } - } -} diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/CertChainSavingMiddleware.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/CertChainSavingMiddleware.cs deleted file mode 100644 index 0092ea33e9f..00000000000 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/middleware/CertChainSavingMiddleware.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -namespace Microsoft.Azure.Devices.Edge.Hub.Http.Middleware -{ - using System.Collections.Generic; - using System.Net.Security; - using System.Security.Cryptography.X509Certificates; - using System.Threading.Tasks; - using Microsoft.AspNetCore.Connections; - using Microsoft.Azure.Devices.Edge.Hub.Http.Extensions; - - public class CertChainSavingMiddleware - { - readonly ConnectionDelegate next; - - public CertChainSavingMiddleware(ConnectionDelegate next) - { - this.next = next; - } - - public async Task OnConnectionAsync(ConnectionContext context) - { - SslStream sslStream = context.Features.Get(); - - IList certChainCopy = new List(); - SslStream newSslStream = new SslStream(sslStream, true, (_, clientCert, chain, policyErrors) => // TODO: should we leave inner stream open? - { - foreach (X509ChainElement chainElement in chain.ChainElements) - { - certChainCopy.Add(new X509Certificate2(chainElement.Certificate)); - } - - return true; - }); - newSslStream.Close(); - - TlsConnectionFeatureExtended tlsConnectionFeatureExtended = new TlsConnectionFeatureExtended - { - ChainElements = certChainCopy - }; - context.Features.Set(tlsConnectionFeatureExtended); - - await this.next(context); - } - - static class Events - { - } - } -} diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 6b7cf8bd675..bf5551cbe92 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -1,11 +1,13 @@ // Copyright (c) Microsoft. All rights reserved. namespace Microsoft.Azure.Devices.Edge.Hub.Service { + using System.Collections.Generic; using System.Net; using System.Net.Sockets; using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; using Autofac; + using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Server.Kestrel.Https; using Microsoft.Azure.Devices.Edge.Hub.Http.Extensions; @@ -34,7 +36,6 @@ public static Hosting Initialize( { int port = configuration.GetValue("httpSettings:port", 443); var certificateMode = clientCertAuthEnabled ? ClientCertificateMode.AllowCertificate : ClientCertificateMode.NoCertificate; - CertChainMapper certChainMapper = new CertChainMapper(); IWebHostBuilder webHostBuilder = new WebHostBuilder() .UseKestrel( options => @@ -47,19 +48,19 @@ public static Hosting Initialize( listenOptions.UseHttps( new HttpsConnectionAdapterOptions() { - ServerCertificateSelector = (connectionContext, _) => + ServerCertificate = serverCertificate, + OnAuthenticate = (context, options) => { - return serverCertificate; - }, - ClientCertificateValidation = (clientCert, chain, policyErrors) => // TODO: verify that this runs only if certificate provided - { - // certChainMapper.ImportCertChain(clientCert.Thumbprint, chain.ChainElements); - return true; + options.RemoteCertificateValidationCallback = (_, clientCert, chain, policyErrors) => + { + TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chain, context); + context.Features.Set(tlsConnectionFeatureExtended); + return true; + }; }, ClientCertificateMode = certificateMode, SslProtocols = sslProtocols - }) - .Use(next => new CertChainSavingMiddleware(next).OnConnectionAsync); + }); }); }) .UseSockets() @@ -68,12 +69,25 @@ public static Hosting Initialize( { serviceCollection.AddSingleton(configuration); serviceCollection.AddSingleton(dependencyManager); - serviceCollection.AddSingleton(certChainMapper); }) .UseStartup(); IWebHost webHost = webHostBuilder.Build(); IContainer container = webHost.Services.GetService(typeof(IStartup)) is Startup startup ? startup.Container : null; return new Hosting(webHost, container); } + + public static TlsConnectionFeatureExtended GetConnectionFeatureExtended(X509Chain chain, ConnectionContext context) + { + IList clientCertChain = new List(); + foreach (X509ChainElement chainElement in chain.ChainElements) + { + clientCertChain.Add(new X509Certificate2(chainElement.Certificate)); + } + + return new TlsConnectionFeatureExtended + { + ChainElements = clientCertChain + }; + } } } diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index 73a828c9d3a..32efb4a2499 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -2,18 +2,13 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service { using System; - using System.Collections.Generic; - using System.Security.Cryptography.X509Certificates; using Autofac; using Autofac.Extensions.DependencyInjection; - using Microsoft.AspNetCore.Authentication.Certificate; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.Devices.Client; using Microsoft.Azure.Devices.Edge.Hub.Core; - using Microsoft.Azure.Devices.Edge.Hub.Http; - using Microsoft.Azure.Devices.Edge.Hub.Http.Extensions; using Microsoft.Azure.Devices.Edge.Hub.Http.Middleware; using Microsoft.Azure.Devices.Edge.Util; using Microsoft.Extensions.Configuration; @@ -23,17 +18,14 @@ public class Startup : IStartup { readonly IDependencyManager dependencyManager; readonly IConfigurationRoot configuration; - readonly CertChainMapper certChainMapper; // ReSharper disable once UnusedParameter.Local public Startup( IConfigurationRoot configuration, - IDependencyManager dependencyManager, - CertChainMapper certChainMapper) + IDependencyManager dependencyManager) { this.configuration = Preconditions.CheckNotNull(configuration, nameof(configuration)); this.dependencyManager = Preconditions.CheckNotNull(dependencyManager, nameof(dependencyManager)); - this.certChainMapper = Preconditions.CheckNotNull(certChainMapper, nameof(certChainMapper)); } internal IContainer Container { get; private set; } @@ -41,43 +33,13 @@ public Startup( // This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { - // services.AddAuthentication( - // CertificateAuthenticationDefaults.AuthenticationScheme) - // .AddCertificate(options => - // { - // options.Events = new CertificateAuthenticationEvents - // { - // OnCertificateValidated = context => - // { - // CertificateValidatedContext context1; - // - // var claims = new[] - // { - // new Claim( - // ClaimTypes.NameIdentifier, - // context.ClientCertificate.Subject, - // ClaimValueTypes.String, - // context.Options.ClaimsIssuer), - // new Claim(ClaimTypes.Name, - // context.ClientCertificate.Subject, - // ClaimValueTypes.String, - // context.Options.ClaimsIssuer) - // }; - // - // context.Principal = new ClaimsPrincipal( - // new ClaimsIdentity(claims, context.Scheme.Name)); - // context.Success(); - // - // return Task.CompletedTask; - // } - // }; - // }); services.AddMemoryCache(); services.AddControllers().AddNewtonsoftJson(); services.Configure(options => { options.Filters.Add(new RequireHttpsAttribute()); }); + this.Container = this.BuildContainer(services); return new AutofacServiceProvider(this.Container); @@ -87,21 +49,6 @@ public void Configure(IApplicationBuilder app) { app.UseWebSockets(); - app.Use( - async (context, next) => - { - // Option> certChainOption = this.certChainMapper.ExtractCertChain(context.Connection); - // certChainOption.ForEach(certChain => - // { - // TlsConnectionFeatureExtended tlsConnectionFeatureExtended = new TlsConnectionFeatureExtended - // { - // ChainElements = certChain - // }; - // context.Features.Set(tlsConnectionFeatureExtended); - // }); - await next(); - }); - var webSocketListenerRegistry = app.ApplicationServices.GetService(typeof(IWebSocketListenerRegistry)) as IWebSocketListenerRegistry; app.UseWebSocketHandlingMiddleware(webSocketListenerRegistry); From d4174977b54b1401ed930cd5c3831f98621a8276 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 7 May 2020 23:55:00 -0700 Subject: [PATCH 062/111] unneeded using --- edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index bf5551cbe92..a3f8030abb9 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -11,7 +11,6 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Server.Kestrel.Https; using Microsoft.Azure.Devices.Edge.Hub.Http.Extensions; - using Microsoft.Azure.Devices.Edge.Hub.Http.Middleware; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; From b36165f2d9090f3ebfc7745c2f9680d7cfe20212 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Fri, 8 May 2020 09:15:12 -0700 Subject: [PATCH 063/111] remove unused parameter --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index a3f8030abb9..1b737b695d2 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -52,7 +52,7 @@ public static Hosting Initialize( { options.RemoteCertificateValidationCallback = (_, clientCert, chain, policyErrors) => { - TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chain, context); + TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chain); context.Features.Set(tlsConnectionFeatureExtended); return true; }; @@ -75,7 +75,7 @@ public static Hosting Initialize( return new Hosting(webHost, container); } - public static TlsConnectionFeatureExtended GetConnectionFeatureExtended(X509Chain chain, ConnectionContext context) + public static TlsConnectionFeatureExtended GetConnectionFeatureExtended(X509Chain chain) { IList clientCertChain = new List(); foreach (X509ChainElement chainElement in chain.ChainElements) From 5412abb5b838405a50210f54e5f45e8520920957 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Fri, 8 May 2020 10:46:47 -0700 Subject: [PATCH 064/111] use no certificate to enable chained callbacks --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 1b737b695d2..3bab9147175 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -34,7 +34,8 @@ public static Hosting Initialize( SslProtocols sslProtocols) { int port = configuration.GetValue("httpSettings:port", 443); - var certificateMode = clientCertAuthEnabled ? ClientCertificateMode.AllowCertificate : ClientCertificateMode.NoCertificate; + // var certificateMode = clientCertAuthEnabled ? ClientCertificateMode.AllowCertificate : ClientCertificateMode.NoCertificate; + var certificateMode = ClientCertificateMode.NoCertificate; IWebHostBuilder webHostBuilder = new WebHostBuilder() .UseKestrel( options => @@ -52,7 +53,7 @@ public static Hosting Initialize( { options.RemoteCertificateValidationCallback = (_, clientCert, chain, policyErrors) => { - TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chain); + TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chain); // TODO: handle case where no cert is used context.Features.Set(tlsConnectionFeatureExtended); return true; }; From 4d55617232a53ac74d8a4e879be28dceab75db57 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Fri, 8 May 2020 23:40:23 -0700 Subject: [PATCH 065/111] set require certificate true to enable cert validation callback --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 3bab9147175..3cfb5e4bf1b 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -34,8 +34,8 @@ public static Hosting Initialize( SslProtocols sslProtocols) { int port = configuration.GetValue("httpSettings:port", 443); - // var certificateMode = clientCertAuthEnabled ? ClientCertificateMode.AllowCertificate : ClientCertificateMode.NoCertificate; - var certificateMode = ClientCertificateMode.NoCertificate; + var certificateMode = clientCertAuthEnabled ? ClientCertificateMode.AllowCertificate : ClientCertificateMode.NoCertificate; + var certificateRequired = clientCertAuthEnabled ? true : false; IWebHostBuilder webHostBuilder = new WebHostBuilder() .UseKestrel( options => @@ -51,6 +51,7 @@ public static Hosting Initialize( ServerCertificate = serverCertificate, OnAuthenticate = (context, options) => { + options.ClientCertificateRequired = true; options.RemoteCertificateValidationCallback = (_, clientCert, chain, policyErrors) => { TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chain); // TODO: handle case where no cert is used From 81925734b67ca390330868044d0cf1285a39b504 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 11 May 2020 08:51:06 -0700 Subject: [PATCH 066/111] remove unused var --- edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 3cfb5e4bf1b..06140945a92 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -35,7 +35,6 @@ public static Hosting Initialize( { int port = configuration.GetValue("httpSettings:port", 443); var certificateMode = clientCertAuthEnabled ? ClientCertificateMode.AllowCertificate : ClientCertificateMode.NoCertificate; - var certificateRequired = clientCertAuthEnabled ? true : false; IWebHostBuilder webHostBuilder = new WebHostBuilder() .UseKestrel( options => From 294fd7d4d23381d34015ec5df6c037ae7442ee07 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 11 May 2020 09:41:12 -0700 Subject: [PATCH 067/111] set no certificate mode --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 06140945a92..49254d116dc 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -34,7 +34,7 @@ public static Hosting Initialize( SslProtocols sslProtocols) { int port = configuration.GetValue("httpSettings:port", 443); - var certificateMode = clientCertAuthEnabled ? ClientCertificateMode.AllowCertificate : ClientCertificateMode.NoCertificate; + // var certificateMode = clientCertAuthEnabled ? ClientCertificateMode.AllowCertificate : ClientCertificateMode.NoCertificate; IWebHostBuilder webHostBuilder = new WebHostBuilder() .UseKestrel( options => @@ -58,7 +58,7 @@ public static Hosting Initialize( return true; }; }, - ClientCertificateMode = certificateMode, + ClientCertificateMode = ClientCertificateMode.NoCertificate, SslProtocols = sslProtocols }); }); From 66d830e4d2903081b108a02fa200df2c3964be34 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 11 May 2020 13:14:38 -0700 Subject: [PATCH 068/111] make certificate handling work for all cases --- .../Hosting.cs | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 49254d116dc..6ed690bd7bb 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -7,10 +7,10 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; using Autofac; - using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Server.Kestrel.Https; using Microsoft.Azure.Devices.Edge.Hub.Http.Extensions; + using Microsoft.Azure.Devices.Edge.Util; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -34,7 +34,6 @@ public static Hosting Initialize( SslProtocols sslProtocols) { int port = configuration.GetValue("httpSettings:port", 443); - // var certificateMode = clientCertAuthEnabled ? ClientCertificateMode.AllowCertificate : ClientCertificateMode.NoCertificate; IWebHostBuilder webHostBuilder = new WebHostBuilder() .UseKestrel( options => @@ -50,15 +49,18 @@ public static Hosting Initialize( ServerCertificate = serverCertificate, OnAuthenticate = (context, options) => { - options.ClientCertificateRequired = true; - options.RemoteCertificateValidationCallback = (_, clientCert, chain, policyErrors) => + if (clientCertAuthEnabled) { - TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chain); // TODO: handle case where no cert is used - context.Features.Set(tlsConnectionFeatureExtended); - return true; - }; + options.ClientCertificateRequired = true; + options.RemoteCertificateValidationCallback = (_, clientCert, chain, policyErrors) => + { + TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chain); + context.Features.Set(tlsConnectionFeatureExtended); + return true; + }; + } }, - ClientCertificateMode = ClientCertificateMode.NoCertificate, + ClientCertificateMode = ClientCertificateMode.NoCertificate, // we can override this in OnAuthenticate if using certs SslProtocols = sslProtocols }); }); @@ -78,6 +80,8 @@ public static Hosting Initialize( public static TlsConnectionFeatureExtended GetConnectionFeatureExtended(X509Chain chain) { + Preconditions.CheckNotNull(chain); + IList clientCertChain = new List(); foreach (X509ChainElement chainElement in chain.ChainElements) { From b00afc909f5977e40052dbc8bc3c60f100fe0b03 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 11 May 2020 15:03:48 -0700 Subject: [PATCH 069/111] set blank tls connection feature for direct method case --- .../Hosting.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 6ed690bd7bb..04b56e22b1f 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -54,7 +54,7 @@ public static Hosting Initialize( options.ClientCertificateRequired = true; options.RemoteCertificateValidationCallback = (_, clientCert, chain, policyErrors) => { - TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chain); + TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(Option.Some(chain)); context.Features.Set(tlsConnectionFeatureExtended); return true; }; @@ -78,15 +78,16 @@ public static Hosting Initialize( return new Hosting(webHost, container); } - public static TlsConnectionFeatureExtended GetConnectionFeatureExtended(X509Chain chain) + public static TlsConnectionFeatureExtended GetConnectionFeatureExtended(Option chain) { - Preconditions.CheckNotNull(chain); - IList clientCertChain = new List(); - foreach (X509ChainElement chainElement in chain.ChainElements) + chain.ForEach(chain => { - clientCertChain.Add(new X509Certificate2(chainElement.Certificate)); - } + foreach (X509ChainElement chainElement in chain.ChainElements) + { + clientCertChain.Add(new X509Certificate2(chainElement.Certificate)); + } + }); return new TlsConnectionFeatureExtended { From 9a99611d3060fa6d79b3b17616b0c8219b34ecd3 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 11 May 2020 15:48:25 -0700 Subject: [PATCH 070/111] fix chain option logic --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 04b56e22b1f..b61952cae6f 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -54,7 +54,8 @@ public static Hosting Initialize( options.ClientCertificateRequired = true; options.RemoteCertificateValidationCallback = (_, clientCert, chain, policyErrors) => { - TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(Option.Some(chain)); + Option chainOption = chain == null ? Option.None() : Option.Some(chain); + TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chainOption); context.Features.Set(tlsConnectionFeatureExtended); return true; }; From f0db4bd53b12fe5777e35f628e719d70e2ad025c Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 11 May 2020 21:22:33 -0700 Subject: [PATCH 071/111] attempt assembly name fix for edgeHub routing --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index b61952cae6f..b8d60e99d3b 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -73,7 +73,8 @@ public static Hosting Initialize( serviceCollection.AddSingleton(configuration); serviceCollection.AddSingleton(dependencyManager); }) - .UseStartup(); + .UseStartup() + .UseSetting(WebHostDefaults.ApplicationKey, typeof(Startup).Assembly.GetName().Name); IWebHost webHost = webHostBuilder.Build(); IContainer container = webHost.Services.GetService(typeof(IStartup)) is Startup startup ? startup.Container : null; return new Hosting(webHost, container); From d09b955605eefe1b59a9011f0b62518c933ec4df Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 11 May 2020 21:23:59 -0700 Subject: [PATCH 072/111] turn off https middleware to debug routing --- .../Hosting.cs | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index b8d60e99d3b..a9c428a6eab 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -43,27 +43,27 @@ public static Hosting Initialize( port, listenOptions => { - listenOptions.UseHttps( - new HttpsConnectionAdapterOptions() - { - ServerCertificate = serverCertificate, - OnAuthenticate = (context, options) => - { - if (clientCertAuthEnabled) - { - options.ClientCertificateRequired = true; - options.RemoteCertificateValidationCallback = (_, clientCert, chain, policyErrors) => - { - Option chainOption = chain == null ? Option.None() : Option.Some(chain); - TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chainOption); - context.Features.Set(tlsConnectionFeatureExtended); - return true; - }; - } - }, - ClientCertificateMode = ClientCertificateMode.NoCertificate, // we can override this in OnAuthenticate if using certs - SslProtocols = sslProtocols - }); + // listenOptions.UseHttps( + // new HttpsConnectionAdapterOptions() + // { + // ServerCertificate = serverCertificate, + // OnAuthenticate = (context, options) => + // { + // if (clientCertAuthEnabled) + // { + // options.ClientCertificateRequired = true; + // options.RemoteCertificateValidationCallback = (_, clientCert, chain, policyErrors) => + // { + // Option chainOption = chain == null ? Option.None() : Option.Some(chain); + // TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chainOption); + // context.Features.Set(tlsConnectionFeatureExtended); + // return true; + // }; + // } + // }, + // ClientCertificateMode = ClientCertificateMode.NoCertificate, // we can override this in OnAuthenticate if using certs + // SslProtocols = sslProtocols + // }); }); }) .UseSockets() From 29fcecfdf60e8b01890cbc6a61631115d2cb8e80 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 12 May 2020 12:05:00 -0700 Subject: [PATCH 073/111] fix direct methods --- .../Hosting.cs | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index a9c428a6eab..cd61522a167 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -9,6 +9,7 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service using Autofac; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Server.Kestrel.Https; + using Microsoft.Azure.Devices.Edge.Hub.Http.Controllers; using Microsoft.Azure.Devices.Edge.Hub.Http.Extensions; using Microsoft.Azure.Devices.Edge.Util; using Microsoft.Extensions.Configuration; @@ -43,27 +44,27 @@ public static Hosting Initialize( port, listenOptions => { - // listenOptions.UseHttps( - // new HttpsConnectionAdapterOptions() - // { - // ServerCertificate = serverCertificate, - // OnAuthenticate = (context, options) => - // { - // if (clientCertAuthEnabled) - // { - // options.ClientCertificateRequired = true; - // options.RemoteCertificateValidationCallback = (_, clientCert, chain, policyErrors) => - // { - // Option chainOption = chain == null ? Option.None() : Option.Some(chain); - // TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chainOption); - // context.Features.Set(tlsConnectionFeatureExtended); - // return true; - // }; - // } - // }, - // ClientCertificateMode = ClientCertificateMode.NoCertificate, // we can override this in OnAuthenticate if using certs - // SslProtocols = sslProtocols - // }); + listenOptions.UseHttps( + new HttpsConnectionAdapterOptions() + { + ServerCertificate = serverCertificate, + OnAuthenticate = (context, options) => + { + if (clientCertAuthEnabled) + { + options.ClientCertificateRequired = true; + options.RemoteCertificateValidationCallback = (_, clientCert, chain, policyErrors) => + { + Option chainOption = chain == null ? Option.None() : Option.Some(chain); + TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chainOption); + context.Features.Set(tlsConnectionFeatureExtended); + return true; + }; + } + }, + ClientCertificateMode = ClientCertificateMode.NoCertificate, // we can override this in OnAuthenticate if using certs + SslProtocols = sslProtocols + }); }); }) .UseSockets() @@ -74,7 +75,7 @@ public static Hosting Initialize( serviceCollection.AddSingleton(dependencyManager); }) .UseStartup() - .UseSetting(WebHostDefaults.ApplicationKey, typeof(Startup).Assembly.GetName().Name); + .UseSetting(WebHostDefaults.ApplicationKey, typeof(TwinsController).Assembly.GetName().Name); IWebHost webHost = webHostBuilder.Build(); IContainer container = webHost.Services.GetService(typeof(IStartup)) is Startup startup ? startup.Container : null; return new Hosting(webHost, container); From bfae8e575e742a51fd1cfd64db299df6a0b3d211 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 13 May 2020 12:29:42 -0700 Subject: [PATCH 074/111] new dotnet version 5-12 --- builds/misc/images-release.yaml | 4 ++-- builds/templates/install-dotnet3.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/builds/misc/images-release.yaml b/builds/misc/images-release.yaml index 50956099c92..f7ebdc31a06 100644 --- a/builds/misc/images-release.yaml +++ b/builds/misc/images-release.yaml @@ -278,7 +278,7 @@ jobs: - task: DotNetCoreInstaller@0 displayName: "Install .NET Core - 3.1.3" inputs: - version: "3.1.201" + version: "3.1.202" - task: DotNetCoreCLI@2 displayName: "Functions Binding nuget package" inputs: @@ -367,7 +367,7 @@ jobs: - task: DotNetCoreInstaller@0 displayName: "Install .NET Core - 3.1.3" inputs: - version: "3.1.201" + version: "3.1.202" - powershell: "scripts/windows/build/Publish-Branch.ps1 -Configuration:\"$(Build.Configuration)\" -PublishTests:$False -UpdateVersion" displayName: "Build ($(Build.Configuration))" name: build diff --git a/builds/templates/install-dotnet3.yaml b/builds/templates/install-dotnet3.yaml index 05b5e5883f5..011424886f0 100644 --- a/builds/templates/install-dotnet3.yaml +++ b/builds/templates/install-dotnet3.yaml @@ -3,4 +3,4 @@ steps: displayName: Install .NET Core sdk inputs: packageType: sdk - version: 3.1.201 + version: 3.1.202 From 04dad906481cec448d9848e558df049265defa5b Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 13 May 2020 12:31:41 -0700 Subject: [PATCH 075/111] update dockerfiles for new dotnet version --- edge-agent/docker/linux/amd64/Dockerfile | 2 +- edge-agent/docker/linux/arm32v7/base/Dockerfile | 2 +- edge-agent/docker/linux/arm64v8/base/Dockerfile | 2 +- edge-agent/docker/windows/amd64/Dockerfile | 2 +- edge-agent/docker/windows/arm32v7/base/Dockerfile | 2 +- edge-hub/docker/linux/amd64/Dockerfile | 2 +- edge-hub/docker/linux/arm32v7/base/Dockerfile | 2 +- edge-hub/docker/linux/arm64v8/base/Dockerfile | 2 +- edge-hub/docker/windows/amd64/Dockerfile | 2 +- edge-hub/docker/windows/arm32v7/base/Dockerfile | 2 +- edge-modules/MetricsCollector/docker/linux/amd64/Dockerfile | 2 +- edge-modules/MetricsCollector/docker/windows/amd64/Dockerfile | 2 +- .../SimulatedTemperatureSensor/docker/linux/amd64/Dockerfile | 2 +- .../docker/linux/arm32v7/base/Dockerfile | 2 +- .../docker/linux/arm64v8/base/Dockerfile | 2 +- .../SimulatedTemperatureSensor/docker/windows/amd64/Dockerfile | 2 +- .../docker/windows/arm32v7/base/Dockerfile | 2 +- .../modules/NetworkController/docker/linux/amd64/Dockerfile | 2 +- .../modules/NetworkController/docker/windows/amd64/Dockerfile | 2 +- .../CloudToDeviceMessageTester/docker/linux/amd64/Dockerfile | 2 +- .../CloudToDeviceMessageTester/docker/windows/amd64/Dockerfile | 2 +- test/modules/DeploymentTester/docker/linux/amd64/Dockerfile | 2 +- test/modules/DeploymentTester/docker/windows/amd64/Dockerfile | 2 +- test/modules/DirectMethodReceiver/docker/linux/amd64/Dockerfile | 2 +- .../DirectMethodReceiver/docker/windows/amd64/Dockerfile | 2 +- test/modules/DirectMethodSender/docker/linux/amd64/Dockerfile | 2 +- test/modules/DirectMethodSender/docker/windows/amd64/Dockerfile | 2 +- test/modules/MetricsValidator/docker/linux/amd64/Dockerfile | 2 +- test/modules/MetricsValidator/docker/windows/amd64/Dockerfile | 2 +- test/modules/ModuleRestarter/docker/linux/amd64/Dockerfile | 2 +- test/modules/ModuleRestarter/docker/windows/amd64/Dockerfile | 2 +- test/modules/Relayer/docker/linux/amd64/Dockerfile | 2 +- test/modules/Relayer/docker/windows/amd64/Dockerfile | 2 +- test/modules/TemperatureFilter/docker/linux/amd64/Dockerfile | 2 +- test/modules/TemperatureFilter/docker/windows/amd64/Dockerfile | 2 +- test/modules/TestAnalyzer/docker/linux/amd64/Dockerfile | 2 +- test/modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile | 2 +- test/modules/TestAnalyzer/docker/linux/arm64v8/base/Dockerfile | 2 +- test/modules/TestAnalyzer/docker/windows/amd64/Dockerfile | 2 +- .../modules/TestResultCoordinator/docker/linux/amd64/Dockerfile | 2 +- .../TestResultCoordinator/docker/windows/amd64/Dockerfile | 2 +- test/modules/TwinTester/docker/linux/amd64/Dockerfile | 2 +- test/modules/TwinTester/docker/windows/amd64/Dockerfile | 2 +- test/modules/load-gen/docker/linux/amd64/Dockerfile | 2 +- test/modules/load-gen/docker/windows/amd64/Dockerfile | 2 +- 45 files changed, 45 insertions(+), 45 deletions(-) diff --git a/edge-agent/docker/linux/amd64/Dockerfile b/edge-agent/docker/linux/amd64/Dockerfile index 4941076f5a0..2545e6d624e 100644 --- a/edge-agent/docker/linux/amd64/Dockerfile +++ b/edge-agent/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-alpine3.11 +ARG base_tag=3.1.4-alpine3.11 FROM azureiotedge/azureiotedge-runtime-base:1.2-linux-amd64 as builder FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} diff --git a/edge-agent/docker/linux/arm32v7/base/Dockerfile b/edge-agent/docker/linux/arm32v7/base/Dockerfile index cd9db42dd4e..58bc1e89928 100644 --- a/edge-agent/docker/linux/arm32v7/base/Dockerfile +++ b/edge-agent/docker/linux/arm32v7/base/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-bionic-arm32v7 +ARG base_tag=3.1.4-bionic-arm32v7 FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} RUN apt-get update && \ diff --git a/edge-agent/docker/linux/arm64v8/base/Dockerfile b/edge-agent/docker/linux/arm64v8/base/Dockerfile index 31e6dc6074c..5e7115b43ea 100644 --- a/edge-agent/docker/linux/arm64v8/base/Dockerfile +++ b/edge-agent/docker/linux/arm64v8/base/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-bionic-arm64v8 +ARG base_tag=3.1.4-bionic-arm64v8 ARG num_procs=4 FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} diff --git a/edge-agent/docker/windows/amd64/Dockerfile b/edge-agent/docker/windows/amd64/Dockerfile index 752a5b1c362..fdfd03287e5 100644 --- a/edge-agent/docker/windows/amd64/Dockerfile +++ b/edge-agent/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-nanoserver-1809 +ARG base_tag=3.1.4-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} USER ContainerAdministrator diff --git a/edge-agent/docker/windows/arm32v7/base/Dockerfile b/edge-agent/docker/windows/arm32v7/base/Dockerfile index 6e6c15f4378..dad298de61b 100644 --- a/edge-agent/docker/windows/arm32v7/base/Dockerfile +++ b/edge-agent/docker/windows/arm32v7/base/Dockerfile @@ -1,7 +1,7 @@ # Base image for arm32v7 dotnet-runtime container FROM mcr.microsoft.com/windows/nanoserver:1809-arm32v7 -ENV DOTNET_VERSION 3.1.2 +ENV DOTNET_VERSION 3.1.4 ENV DOTNET_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-runtime-${DOTNET_VERSION}-win-arm.zip RUN curl -SL %DOTNET_DOWNLOAD_URL% --output dotnet.zip \ diff --git a/edge-hub/docker/linux/amd64/Dockerfile b/edge-hub/docker/linux/amd64/Dockerfile index be1ee2b3f94..e238b0988d0 100644 --- a/edge-hub/docker/linux/amd64/Dockerfile +++ b/edge-hub/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-alpine3.11 +ARG base_tag=3.1.4-alpine3.11 FROM azureiotedge/azureiotedge-runtime-base:1.2-linux-amd64 as builder FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} diff --git a/edge-hub/docker/linux/arm32v7/base/Dockerfile b/edge-hub/docker/linux/arm32v7/base/Dockerfile index c957b76f4db..b2538dc323e 100644 --- a/edge-hub/docker/linux/arm32v7/base/Dockerfile +++ b/edge-hub/docker/linux/arm32v7/base/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-bionic-arm32v7 +ARG base_tag=3.1.4-bionic-arm32v7 FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} # Add an unprivileged user account for running Edge Hub diff --git a/edge-hub/docker/linux/arm64v8/base/Dockerfile b/edge-hub/docker/linux/arm64v8/base/Dockerfile index f7f72ba8acd..4091b7f9e1b 100644 --- a/edge-hub/docker/linux/arm64v8/base/Dockerfile +++ b/edge-hub/docker/linux/arm64v8/base/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-bionic-arm64v8 +ARG base_tag=3.1.4-bionic-arm64v8 FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} # Add an unprivileged user account for running Edge Hub diff --git a/edge-hub/docker/windows/amd64/Dockerfile b/edge-hub/docker/windows/amd64/Dockerfile index f2a80f0c8cd..364b7944e44 100644 --- a/edge-hub/docker/windows/amd64/Dockerfile +++ b/edge-hub/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-nanoserver-1809 +ARG base_tag=3.1.4-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} ARG EXE_DIR=. diff --git a/edge-hub/docker/windows/arm32v7/base/Dockerfile b/edge-hub/docker/windows/arm32v7/base/Dockerfile index 371e9a1911f..0e3e22a6721 100644 --- a/edge-hub/docker/windows/arm32v7/base/Dockerfile +++ b/edge-hub/docker/windows/arm32v7/base/Dockerfile @@ -1,7 +1,7 @@ # Base image for arm32v7 dotnet-runtime container FROM mcr.microsoft.com/windows/nanoserver:1809-arm32v7 -ENV DOTNET_VERSION 3.1.2 +ENV DOTNET_VERSION 3.1.4 ENV DOTNET_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-runtime-${DOTNET_VERSION}-win-arm.zip RUN curl -SL %DOTNET_DOWNLOAD_URL% --output dotnet.zip \ diff --git a/edge-modules/MetricsCollector/docker/linux/amd64/Dockerfile b/edge-modules/MetricsCollector/docker/linux/amd64/Dockerfile index 515e802a806..0c630058ca6 100644 --- a/edge-modules/MetricsCollector/docker/linux/amd64/Dockerfile +++ b/edge-modules/MetricsCollector/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-alpine3.11 +ARG base_tag=3.1.4-alpine3.11 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/edge-modules/MetricsCollector/docker/windows/amd64/Dockerfile b/edge-modules/MetricsCollector/docker/windows/amd64/Dockerfile index b65dff48e12..7b35eea1fbf 100644 --- a/edge-modules/MetricsCollector/docker/windows/amd64/Dockerfile +++ b/edge-modules/MetricsCollector/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-nanoserver-1809 +ARG base_tag=3.1.4-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/edge-modules/SimulatedTemperatureSensor/docker/linux/amd64/Dockerfile b/edge-modules/SimulatedTemperatureSensor/docker/linux/amd64/Dockerfile index dc7dff29934..ea3b3632b3e 100644 --- a/edge-modules/SimulatedTemperatureSensor/docker/linux/amd64/Dockerfile +++ b/edge-modules/SimulatedTemperatureSensor/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-alpine3.11 +ARG base_tag=3.1.4-alpine3.11 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/edge-modules/SimulatedTemperatureSensor/docker/linux/arm32v7/base/Dockerfile b/edge-modules/SimulatedTemperatureSensor/docker/linux/arm32v7/base/Dockerfile index f15ddeb4a7b..8c669e25082 100644 --- a/edge-modules/SimulatedTemperatureSensor/docker/linux/arm32v7/base/Dockerfile +++ b/edge-modules/SimulatedTemperatureSensor/docker/linux/arm32v7/base/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-bionic-arm32v7 +ARG base_tag=3.1.4-bionic-arm32v7 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} # Add an unprivileged user account for running the module diff --git a/edge-modules/SimulatedTemperatureSensor/docker/linux/arm64v8/base/Dockerfile b/edge-modules/SimulatedTemperatureSensor/docker/linux/arm64v8/base/Dockerfile index 136adac7255..c014864531b 100644 --- a/edge-modules/SimulatedTemperatureSensor/docker/linux/arm64v8/base/Dockerfile +++ b/edge-modules/SimulatedTemperatureSensor/docker/linux/arm64v8/base/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-bionic-arm64v8 +ARG base_tag=3.1.4-bionic-arm64v8 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} # Add an unprivileged user account for running the module diff --git a/edge-modules/SimulatedTemperatureSensor/docker/windows/amd64/Dockerfile b/edge-modules/SimulatedTemperatureSensor/docker/windows/amd64/Dockerfile index 01789cf53fa..4f236f94f05 100644 --- a/edge-modules/SimulatedTemperatureSensor/docker/windows/amd64/Dockerfile +++ b/edge-modules/SimulatedTemperatureSensor/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-nanoserver-1809 +ARG base_tag=3.1.4-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/edge-modules/SimulatedTemperatureSensor/docker/windows/arm32v7/base/Dockerfile b/edge-modules/SimulatedTemperatureSensor/docker/windows/arm32v7/base/Dockerfile index ca9d0ca93d1..1b8d018c98f 100644 --- a/edge-modules/SimulatedTemperatureSensor/docker/windows/arm32v7/base/Dockerfile +++ b/edge-modules/SimulatedTemperatureSensor/docker/windows/arm32v7/base/Dockerfile @@ -1,7 +1,7 @@ # Base image for arm32v7 dotnet-runtime container FROM mcr.microsoft.com/windows/nanoserver:1809-arm32v7 -ENV DOTNET_VERSION 3.1.2 +ENV DOTNET_VERSION 3.1.4 ENV DOTNET_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-runtime-${DOTNET_VERSION}-win-arm.zip RUN curl -SL %DOTNET_DOWNLOAD_URL% --output dotnet.zip \ diff --git a/test/connectivity/modules/NetworkController/docker/linux/amd64/Dockerfile b/test/connectivity/modules/NetworkController/docker/linux/amd64/Dockerfile index ded0ef7df71..e3150eef6ce 100644 --- a/test/connectivity/modules/NetworkController/docker/linux/amd64/Dockerfile +++ b/test/connectivity/modules/NetworkController/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-alpine3.11 +ARG base_tag=3.1.4-alpine3.11 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/connectivity/modules/NetworkController/docker/windows/amd64/Dockerfile b/test/connectivity/modules/NetworkController/docker/windows/amd64/Dockerfile index aaa2d6c2872..596bcc595be 100644 --- a/test/connectivity/modules/NetworkController/docker/windows/amd64/Dockerfile +++ b/test/connectivity/modules/NetworkController/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-nanoserver-1809 +ARG base_tag=3.1.4-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/CloudToDeviceMessageTester/docker/linux/amd64/Dockerfile b/test/modules/CloudToDeviceMessageTester/docker/linux/amd64/Dockerfile index aa153ac31e9..1c288e0bba5 100644 --- a/test/modules/CloudToDeviceMessageTester/docker/linux/amd64/Dockerfile +++ b/test/modules/CloudToDeviceMessageTester/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-alpine3.10 +ARG base_tag=3.1.4-alpine3.10 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/CloudToDeviceMessageTester/docker/windows/amd64/Dockerfile b/test/modules/CloudToDeviceMessageTester/docker/windows/amd64/Dockerfile index 3889db34348..0efbee9fde3 100644 --- a/test/modules/CloudToDeviceMessageTester/docker/windows/amd64/Dockerfile +++ b/test/modules/CloudToDeviceMessageTester/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-nanoserver-1809 +ARG base_tag=3.1.4-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ENV MODULE_NAME "CloudToDeviceMessageTester.dll" diff --git a/test/modules/DeploymentTester/docker/linux/amd64/Dockerfile b/test/modules/DeploymentTester/docker/linux/amd64/Dockerfile index 650c2c9e4d1..584c9fc9929 100644 --- a/test/modules/DeploymentTester/docker/linux/amd64/Dockerfile +++ b/test/modules/DeploymentTester/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-alpine3.11 +ARG base_tag=3.1.4-alpine3.11 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/DeploymentTester/docker/windows/amd64/Dockerfile b/test/modules/DeploymentTester/docker/windows/amd64/Dockerfile index 8e8ea427ead..1253f368cbb 100644 --- a/test/modules/DeploymentTester/docker/windows/amd64/Dockerfile +++ b/test/modules/DeploymentTester/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-nanoserver-1809 +ARG base_tag=3.1.4-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ENV MODULE_NAME "DeploymentTester.dll" diff --git a/test/modules/DirectMethodReceiver/docker/linux/amd64/Dockerfile b/test/modules/DirectMethodReceiver/docker/linux/amd64/Dockerfile index 0e7d02f47a9..e62b0c71201 100644 --- a/test/modules/DirectMethodReceiver/docker/linux/amd64/Dockerfile +++ b/test/modules/DirectMethodReceiver/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-alpine3.11 +ARG base_tag=3.1.4-alpine3.11 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/DirectMethodReceiver/docker/windows/amd64/Dockerfile b/test/modules/DirectMethodReceiver/docker/windows/amd64/Dockerfile index 19b96127307..997cf9039b8 100644 --- a/test/modules/DirectMethodReceiver/docker/windows/amd64/Dockerfile +++ b/test/modules/DirectMethodReceiver/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-nanoserver-1809 +ARG base_tag=3.1.4-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/DirectMethodSender/docker/linux/amd64/Dockerfile b/test/modules/DirectMethodSender/docker/linux/amd64/Dockerfile index 9b9a46fae48..6287e02a56c 100644 --- a/test/modules/DirectMethodSender/docker/linux/amd64/Dockerfile +++ b/test/modules/DirectMethodSender/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-alpine3.11 +ARG base_tag=3.1.4-alpine3.11 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/DirectMethodSender/docker/windows/amd64/Dockerfile b/test/modules/DirectMethodSender/docker/windows/amd64/Dockerfile index 5ede88893b9..4c3e41e2fa8 100644 --- a/test/modules/DirectMethodSender/docker/windows/amd64/Dockerfile +++ b/test/modules/DirectMethodSender/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-nanoserver-1809 +ARG base_tag=3.1.4-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/MetricsValidator/docker/linux/amd64/Dockerfile b/test/modules/MetricsValidator/docker/linux/amd64/Dockerfile index 77d0b4dd86e..dc4229f5c8b 100644 --- a/test/modules/MetricsValidator/docker/linux/amd64/Dockerfile +++ b/test/modules/MetricsValidator/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-alpine3.11 +ARG base_tag=3.1.4-alpine3.11 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/MetricsValidator/docker/windows/amd64/Dockerfile b/test/modules/MetricsValidator/docker/windows/amd64/Dockerfile index 64c7139cde2..6e9d1357936 100644 --- a/test/modules/MetricsValidator/docker/windows/amd64/Dockerfile +++ b/test/modules/MetricsValidator/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-nanoserver-1809 +ARG base_tag=3.1.4-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/ModuleRestarter/docker/linux/amd64/Dockerfile b/test/modules/ModuleRestarter/docker/linux/amd64/Dockerfile index d9927fb3339..4d065d84276 100644 --- a/test/modules/ModuleRestarter/docker/linux/amd64/Dockerfile +++ b/test/modules/ModuleRestarter/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-alpine3.11 +ARG base_tag=3.1.4-alpine3.11 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/ModuleRestarter/docker/windows/amd64/Dockerfile b/test/modules/ModuleRestarter/docker/windows/amd64/Dockerfile index d9daec3fa8a..ecff2ed1a5d 100644 --- a/test/modules/ModuleRestarter/docker/windows/amd64/Dockerfile +++ b/test/modules/ModuleRestarter/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-nanoserver-1809 +ARG base_tag=3.1.4-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/Relayer/docker/linux/amd64/Dockerfile b/test/modules/Relayer/docker/linux/amd64/Dockerfile index 9a3121be799..c7943bd2473 100644 --- a/test/modules/Relayer/docker/linux/amd64/Dockerfile +++ b/test/modules/Relayer/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-alpine3.11 +ARG base_tag=3.1.4-alpine3.11 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/Relayer/docker/windows/amd64/Dockerfile b/test/modules/Relayer/docker/windows/amd64/Dockerfile index 3ab066b6430..6caabb84f6d 100644 --- a/test/modules/Relayer/docker/windows/amd64/Dockerfile +++ b/test/modules/Relayer/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-nanoserver-1809 +ARG base_tag=3.1.4-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ENV MODULE_NAME "Relayer.dll" diff --git a/test/modules/TemperatureFilter/docker/linux/amd64/Dockerfile b/test/modules/TemperatureFilter/docker/linux/amd64/Dockerfile index 13475e0822e..c9bec30dc37 100644 --- a/test/modules/TemperatureFilter/docker/linux/amd64/Dockerfile +++ b/test/modules/TemperatureFilter/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-alpine3.11 +ARG base_tag=3.1.4-alpine3.11 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TemperatureFilter/docker/windows/amd64/Dockerfile b/test/modules/TemperatureFilter/docker/windows/amd64/Dockerfile index 81ecc173267..696618d8bd9 100644 --- a/test/modules/TemperatureFilter/docker/windows/amd64/Dockerfile +++ b/test/modules/TemperatureFilter/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-nanoserver-1809 +ARG base_tag=3.1.4-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TestAnalyzer/docker/linux/amd64/Dockerfile b/test/modules/TestAnalyzer/docker/linux/amd64/Dockerfile index efc02bb1673..96978a4fa71 100644 --- a/test/modules/TestAnalyzer/docker/linux/amd64/Dockerfile +++ b/test/modules/TestAnalyzer/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-alpine3.11 +ARG base_tag=3.1.4-alpine3.11 FROM azureiotedge/azureiotedge-runtime-base:1.1-linux-amd64 as builder FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} diff --git a/test/modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile b/test/modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile index 9e4e4918fb3..ee7e9903abf 100644 --- a/test/modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile +++ b/test/modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-bionic-arm32v7 +ARG base_tag=3.1.4-bionic-arm32v7 FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} RUN apt-get update && apt-get install -y libcap2-bin libsnappy1v5 && \ diff --git a/test/modules/TestAnalyzer/docker/linux/arm64v8/base/Dockerfile b/test/modules/TestAnalyzer/docker/linux/arm64v8/base/Dockerfile index 5219eff65d5..cac64864a77 100644 --- a/test/modules/TestAnalyzer/docker/linux/arm64v8/base/Dockerfile +++ b/test/modules/TestAnalyzer/docker/linux/arm64v8/base/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-bionic-arm64v8 +ARG base_tag=3.1.4-bionic-arm64v8 FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} RUN apt-get update && \ diff --git a/test/modules/TestAnalyzer/docker/windows/amd64/Dockerfile b/test/modules/TestAnalyzer/docker/windows/amd64/Dockerfile index 95e591ed52c..7625ccef0a4 100644 --- a/test/modules/TestAnalyzer/docker/windows/amd64/Dockerfile +++ b/test/modules/TestAnalyzer/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-nanoserver-1809 +ARG base_tag=3.1.4-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TestResultCoordinator/docker/linux/amd64/Dockerfile b/test/modules/TestResultCoordinator/docker/linux/amd64/Dockerfile index 311170b74b3..2ade3b933ac 100644 --- a/test/modules/TestResultCoordinator/docker/linux/amd64/Dockerfile +++ b/test/modules/TestResultCoordinator/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-alpine3.11 +ARG base_tag=3.1.4-alpine3.11 FROM azureiotedge/azureiotedge-runtime-base:1.1-linux-amd64 as builder FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} diff --git a/test/modules/TestResultCoordinator/docker/windows/amd64/Dockerfile b/test/modules/TestResultCoordinator/docker/windows/amd64/Dockerfile index 4e14440abd8..d8be96716e0 100644 --- a/test/modules/TestResultCoordinator/docker/windows/amd64/Dockerfile +++ b/test/modules/TestResultCoordinator/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-nanoserver-1809 +ARG base_tag=3.1.4-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/aspnet:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/TwinTester/docker/linux/amd64/Dockerfile b/test/modules/TwinTester/docker/linux/amd64/Dockerfile index 95bf59ef0b2..52f35667e49 100644 --- a/test/modules/TwinTester/docker/linux/amd64/Dockerfile +++ b/test/modules/TwinTester/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-alpine3.11 +ARG base_tag=3.1.4-alpine3.11 FROM azureiotedge/azureiotedge-runtime-base:1.1-linux-amd64 as builder FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} diff --git a/test/modules/TwinTester/docker/windows/amd64/Dockerfile b/test/modules/TwinTester/docker/windows/amd64/Dockerfile index 6b54ce299da..69300333e1c 100644 --- a/test/modules/TwinTester/docker/windows/amd64/Dockerfile +++ b/test/modules/TwinTester/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-nanoserver-1809 +ARG base_tag=3.1.4-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/load-gen/docker/linux/amd64/Dockerfile b/test/modules/load-gen/docker/linux/amd64/Dockerfile index 1433464fb0d..bd4e9887f49 100644 --- a/test/modules/load-gen/docker/linux/amd64/Dockerfile +++ b/test/modules/load-gen/docker/linux/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-alpine3.11 +ARG base_tag=3.1.4-alpine3.11 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. diff --git a/test/modules/load-gen/docker/windows/amd64/Dockerfile b/test/modules/load-gen/docker/windows/amd64/Dockerfile index 8c220300dfb..6326fc98cbb 100644 --- a/test/modules/load-gen/docker/windows/amd64/Dockerfile +++ b/test/modules/load-gen/docker/windows/amd64/Dockerfile @@ -1,4 +1,4 @@ -ARG base_tag=3.1.2-nanoserver-1809 +ARG base_tag=3.1.4-nanoserver-1809 FROM mcr.microsoft.com/dotnet/core/runtime:${base_tag} ARG EXE_DIR=. From 87423c3b97df8bc20f7c54646970dd41d92c1d36 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 13 May 2020 12:34:11 -0700 Subject: [PATCH 076/111] separate PR for images release yaml: --- builds/misc/images-release.yaml | 636 -------------------------------- 1 file changed, 636 deletions(-) delete mode 100644 builds/misc/images-release.yaml diff --git a/builds/misc/images-release.yaml b/builds/misc/images-release.yaml deleted file mode 100644 index f7ebdc31a06..00000000000 --- a/builds/misc/images-release.yaml +++ /dev/null @@ -1,636 +0,0 @@ -#Your build pipeline references a secret variable named ‘build.registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 -#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 -#Your build pipeline references the ‘configuration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 -#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 -#Your build pipeline references the ‘version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 -#Your build pipeline references the ‘configuration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 -#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 -#Your build pipeline references the ‘version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 -#Your build pipeline references the ‘configuration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 -#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 -#Your build pipeline references the ‘version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 -#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 -#Your build pipeline references the ‘version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 -#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 -#Your build pipeline references the ‘version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 -#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 -#Your build pipeline references the ‘version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 -#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 -#Your build pipeline references the ‘version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 -#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 -#Your build pipeline references the ‘version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 -#Your build pipeline references a secret variable named ‘registry.password’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it secret. See https://go.microsoft.com/fwlink/?linkid=865972 -#Your build pipeline references the ‘version’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971 -jobs: - - job: linux_dotnet_projects - displayName: LinuxDotnet - pool: - name: "Hosted Ubuntu 1604" - steps: - - bash: | - docker login '$(build.registry.address)' --username '$(build.registry.user)' --password '$(build.registry.password)' - docker login '$(registry.address)' --username '$(registry.user)' --password '$(registry.password)' - displayName: 'Docker Login' - - task: Bash@3 - displayName: "Install Rust" - inputs: - arguments: "--package-arm" - filePath: ./edgelet/build/linux/install.sh - targetType: filePath - - bash: "echo \"##vso[task.setvariable variable=PATH;]$HOME/.cargo/bin:$PATH\"" - displayName: "Modify path" - - template: ../templates/install-dotnet3.yaml - - task: ShellScript@2 - displayName: "Install build prerequisites" - inputs: - scriptPath: scripts/linux/installPrereqs.sh - - bash: "cargo install --git https://github.com/arsing/cross.git --branch set-path" - displayName: "Install cross (fork with docker fix)" - - task: ShellScript@2 - displayName: "Build Azure-IoT-Edge-Core" - inputs: - args: "-c Release" - scriptPath: scripts/linux/buildBranch.sh - - task: DotNetCoreInstaller@0 - displayName: "Install .NET Core 2.1" - inputs: - version: "2.1.700" - - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - displayName: "Edge Agent Code Sign" - inputs: - ConnectedServiceName: "Azure IoT Edge Code Sign 2" - FolderPath: $(Build.BinariesDirectory)/publish/Microsoft.Azure.Devices.Edge.Agent.Service - Pattern: Microsoft.Azure.Devices.Edge.*.dll - SessionTimeout: 20 - inlineOperation: | - [ - { - "keyCode": "CP-230012", - "operationSetCode": "SigntoolSign", - "parameters": [ - { - "parameterName": "OpusName", - "parameterValue": "Microsoft" - }, - { - "parameterName": "OpusInfo", - "parameterValue": "http://www.microsoft.com" - }, - { - "parameterName": "Append", - "parameterValue": "/as" - }, - { - "parameterName": "FileDigest", - "parameterValue": "/fd \"SHA256\"" - }, - { - "parameterName": "PageHash", - "parameterValue": "/NPH" - }, - { - "parameterName": "TimeStamp", - "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" - } - ], - "toolName": "sign", - "toolVersion": "1.0" - }, - { - "keyCode": "CP-230012", - "operationSetCode": "SigntoolVerify", - "parameters": [ - { - "parameterName": "VerifyAll", - "parameterValue": "/all" - } - ], - "toolName": "sign", - "toolVersion": "1.0" - } - ] - signConfigType: inlineSignParams - - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - displayName: "Edge Hub Code Sign" - inputs: - ConnectedServiceName: "Azure IoT Edge Code Sign 2" - FolderPath: $(Build.BinariesDirectory)/publish/Microsoft.Azure.Devices.Edge.Hub.Service - Pattern: "Microsoft.Azure.Devices.Edge.*.dll,Microsoft.Azure.Devices.Routing.*.dll" - SessionTimeout: 20 - inlineOperation: | - [ - { - "keyCode": "CP-230012", - "operationSetCode": "SigntoolSign", - "parameters": [ - { - "parameterName": "OpusName", - "parameterValue": "Microsoft" - }, - { - "parameterName": "OpusInfo", - "parameterValue": "http://www.microsoft.com" - }, - { - "parameterName": "Append", - "parameterValue": "/as" - }, - { - "parameterName": "FileDigest", - "parameterValue": "/fd \"SHA256\"" - }, - { - "parameterName": "PageHash", - "parameterValue": "/NPH" - }, - { - "parameterName": "TimeStamp", - "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" - } - ], - "toolName": "sign", - "toolVersion": "1.0" - }, - { - "keyCode": "CP-230012", - "operationSetCode": "SigntoolVerify", - "parameters": [ - { - "parameterName": "VerifyAll", - "parameterValue": "/all" - } - ], - "toolName": "sign", - "toolVersion": "1.0" - } - ] - signConfigType: inlineSignParams - - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - displayName: "Temp Sensor Code Sign" - inputs: - ConnectedServiceName: "Azure IoT Edge Code Sign 2" - FolderPath: $(Build.BinariesDirectory)/publish/SimulatedTemperatureSensor - Pattern: "Microsoft.Azure.Devices.Edge.*.dll,SimulatedTemperatureSensor.dll" - SessionTimeout: 20 - inlineOperation: | - [ - { - "keyCode": "CP-230012", - "operationSetCode": "SigntoolSign", - "parameters": [ - { - "parameterName": "OpusName", - "parameterValue": "Microsoft" - }, - { - "parameterName": "OpusInfo", - "parameterValue": "http://www.microsoft.com" - }, - { - "parameterName": "Append", - "parameterValue": "/as" - }, - { - "parameterName": "FileDigest", - "parameterValue": "/fd \"SHA256\"" - }, - { - "parameterName": "PageHash", - "parameterValue": "/NPH" - }, - { - "parameterName": "TimeStamp", - "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" - } - ], - "toolName": "sign", - "toolVersion": "1.0" - }, - { - "keyCode": "CP-230012", - "operationSetCode": "SigntoolVerify", - "parameters": [ - { - "parameterName": "VerifyAll", - "parameterValue": "/all" - } - ], - "toolName": "sign", - "toolVersion": "1.0" - } - ] - signConfigType: inlineSignParams - - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - displayName: "Functions Binding Code Sign" - inputs: - ConnectedServiceName: "Azure IoT Edge Code Sign 2" - FolderPath: $(Build.BinariesDirectory)/publish/Microsoft.Azure.WebJobs.Extensions.EdgeHub - Pattern: Microsoft.Azure.WebJobs.Extensions*.dll - SessionTimeout: 20 - inlineOperation: | - [ - { - "keyCode": "CP-230012", - "operationSetCode": "SigntoolSign", - "parameters": [ - { - "parameterName": "OpusName", - "parameterValue": "Microsoft" - }, - { - "parameterName": "OpusInfo", - "parameterValue": "http://www.microsoft.com" - }, - { - "parameterName": "Append", - "parameterValue": "/as" - }, - { - "parameterName": "FileDigest", - "parameterValue": "/fd \"SHA256\"" - }, - { - "parameterName": "PageHash", - "parameterValue": "/NPH" - }, - { - "parameterName": "TimeStamp", - "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" - } - ], - "toolName": "sign", - "toolVersion": "1.0" - }, - { - "keyCode": "CP-230012", - "operationSetCode": "SigntoolVerify", - "parameters": [ - { - "parameterName": "VerifyAll", - "parameterValue": "/all" - } - ], - "toolName": "sign", - "toolVersion": "1.0" - } - ] - signConfigType: inlineSignParams - - task: DotNetCoreInstaller@0 - displayName: "Install .NET Core - 3.1.3" - inputs: - version: "3.1.202" - - task: DotNetCoreCLI@2 - displayName: "Functions Binding nuget package" - inputs: - buildProperties: OutDir=$(Build.BinariesDirectory)/publish/Microsoft.Azure.WebJobs.Extensions.EdgeHub - command: pack - nobuild: true - packDirectory: $(Build.BinariesDirectory)/publish/ - packagesToPack: "**/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj" - versionEnvVar: version - versioningScheme: byEnvVar - - task: DotNetCoreInstaller@0 - displayName: "Install .NET Core 2.1" - inputs: - version: "2.1.700" - - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - displayName: "Functions Binding nuget package Sign" - inputs: - ConnectedServiceName: "Azure IoT Edge Code Sign 2" - FolderPath: $(Build.BinariesDirectory)/publish - Pattern: Microsoft.Azure.WebJobs.Extensions*.nupkg - inlineOperation: | - [ - { - "keyCode": "CP-401405", - "operationSetCode": "NuGetSign", - "parameters": [], - "toolName": "sign", - "toolVersion": "1.0" - }, - { - "keyCode": "CP-401405", - "operationSetCode": "NuGetVerify", - "parameters": [], - "toolName": "sign", - "toolVersion": "1.0" - } - ] - signConfigType: inlineSignParams - - task: Bash@3 - displayName: "Build iotedge-diagnostics" - inputs: - arguments: "-i azureiotedge-diagnostics -n microsoft -P iotedge-diagnostics -c $(Build.Configuration)" - filePath: ./scripts/linux/buildEdgelet.sh - targetType: filePath - - bash: | - scripts/linux/buildEdgelet.sh -i azureiotedge-diagnostics -n microsoft -P iotedge-diagnostics -c $(configuration) && - scripts/linux/buildImage.sh -r $(registry.address) -u $(registry.user) -p $(registry.password) -v $(version) -i azureiotedge-diagnostics -n $(namespace) -P azureiotedge-diagnostics - displayName: 'Build Image - azureiotedge-diagnostics - amd64' - - bash: | - scripts/linux/buildEdgelet.sh -i azureiotedge-diagnostics -n microsoft -P iotedge-diagnostics -c $(configuration) --target-arch armv7l && - scripts/linux/buildImage.sh -r $(registry.address) -u $(registry.user) -p $(registry.password) -v $(version) -i azureiotedge-diagnostics -n $(namespace) -P azureiotedge-diagnostics --target-arch armv7l - displayName: 'Build Image - azureiotedge-diagnostics - ARM32' - - bash: | - scripts/linux/buildEdgelet.sh -i azureiotedge-diagnostics -n microsoft -P iotedge-diagnostics -c $(configuration) --target-arch aarch64 && - scripts/linux/buildImage.sh -r $(registry.address) -u $(registry.user) -p $(registry.password) -v $(version) -i azureiotedge-diagnostics -n $(namespace) -P azureiotedge-diagnostics --target-arch aarch64 - displayName: 'Build Image - azureiotedge-diagnostics - ARM64' - - template: templates/image-linux.yaml - parameters: - imageName: azureiotedge-agent - name: "Edge Agent" - project: Microsoft.Azure.Devices.Edge.Agent.Service - - template: templates/image-linux.yaml - parameters: - imageName: azureiotedge-hub - name: "Edge Hub" - project: Microsoft.Azure.Devices.Edge.Hub.Service - - template: templates/image-linux.yaml - parameters: - imageName: azureiotedge-simulated-temperature-sensor - name: "Temperature Sensor" - project: SimulatedTemperatureSensor - variables: - build.registry.address: edgebuilds.azurecr.io - build.registry.user: EdgeBuilds - registry.address: edgerelease.azurecr.io - registry.user: EdgeRelease - - job: windows - displayName: Windows - pool: - name: Azure-IoT-Edge-Core - demands: - - "Build-Image -equals true" - - win-rs5 - - DotNetFramework - steps: - - task: DotNetCoreInstaller@0 - displayName: "Install .NET Core - 3.1.3" - inputs: - version: "3.1.202" - - powershell: "scripts/windows/build/Publish-Branch.ps1 -Configuration:\"$(Build.Configuration)\" -PublishTests:$False -UpdateVersion" - displayName: "Build ($(Build.Configuration))" - name: build - - script: | - docker login $(build.registry.address) -u $(build.registry.user) -p $(build.registry.password) - docker login $(registry.address) -u $(registry.user) -p $(registry.password) - displayName: 'docker login' - - task: PowerShell@2 - displayName: "Build iotedge-diagnostics" - inputs: - filePath: ./edgelet/build/windows/build-diagnostics.ps1 - targetType: filePath - - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - displayName: "azureiotedge-diagnostics Code Sign" - inputs: - ConnectedServiceName: "Azure IoT Edge Code Sign 2" - FolderPath: $(Build.BinariesDirectory)\publish\azureiotedge-diagnostics - Pattern: iotedge-diagnostics.exe - SessionTimeout: 20 - inlineOperation: | - [ - { - "keyCode": "CP-230012", - "operationSetCode": "SigntoolSign", - "parameters": [ - { - "parameterName": "OpusName", - "parameterValue": "Microsoft" - }, - { - "parameterName": "OpusInfo", - "parameterValue": "http://www.microsoft.com" - }, - { - "parameterName": "Append", - "parameterValue": "/as" - }, - { - "parameterName": "FileDigest", - "parameterValue": "/fd \"SHA256\"" - }, - { - "parameterName": "PageHash", - "parameterValue": "/NPH" - }, - { - "parameterName": "TimeStamp", - "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" - } - ], - "toolName": "sign", - "toolVersion": "1.0" - }, - { - "keyCode": "CP-230012", - "operationSetCode": "SigntoolVerify", - "parameters": [ - { - "parameterName": "VerifyAll", - "parameterValue": "/all" - } - ], - "toolName": "sign", - "toolVersion": "1.0" - } - ] - signConfigType: inlineSignParams - - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - displayName: "Edge Agent Code Sign" - inputs: - ConnectedServiceName: "Azure IoT Edge Code Sign 2" - FolderPath: $(Build.BinariesDirectory)\publish\Microsoft.Azure.Devices.Edge.Agent.Service - Pattern: Microsoft.Azure.Devices.Edge.*.dll - SessionTimeout: 20 - inlineOperation: | - [ - { - "keyCode": "CP-230012", - "operationSetCode": "SigntoolSign", - "parameters": [ - { - "parameterName": "OpusName", - "parameterValue": "Microsoft" - }, - { - "parameterName": "OpusInfo", - "parameterValue": "http://www.microsoft.com" - }, - { - "parameterName": "Append", - "parameterValue": "/as" - }, - { - "parameterName": "FileDigest", - "parameterValue": "/fd \"SHA256\"" - }, - { - "parameterName": "PageHash", - "parameterValue": "/NPH" - }, - { - "parameterName": "TimeStamp", - "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" - } - ], - "toolName": "sign", - "toolVersion": "1.0" - }, - { - "keyCode": "CP-230012", - "operationSetCode": "SigntoolVerify", - "parameters": [ - { - "parameterName": "VerifyAll", - "parameterValue": "/all" - } - ], - "toolName": "sign", - "toolVersion": "1.0" - } - ] - signConfigType: inlineSignParams - - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - displayName: "Edge Hub Code Sign" - inputs: - ConnectedServiceName: "Azure IoT Edge Code Sign 2" - FolderPath: $(Build.BinariesDirectory)\publish\Microsoft.Azure.Devices.Edge.Hub.Service - Pattern: "Microsoft.Azure.Devices.Edge.*.dll,Microsoft.Azure.Devices.Routing.*.dll" - SessionTimeout: 20 - inlineOperation: | - [ - { - "keyCode": "CP-230012", - "operationSetCode": "SigntoolSign", - "parameters": [ - { - "parameterName": "OpusName", - "parameterValue": "Microsoft" - }, - { - "parameterName": "OpusInfo", - "parameterValue": "http://www.microsoft.com" - }, - { - "parameterName": "Append", - "parameterValue": "/as" - }, - { - "parameterName": "FileDigest", - "parameterValue": "/fd \"SHA256\"" - }, - { - "parameterName": "PageHash", - "parameterValue": "/NPH" - }, - { - "parameterName": "TimeStamp", - "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" - } - ], - "toolName": "sign", - "toolVersion": "1.0" - }, - { - "keyCode": "CP-230012", - "operationSetCode": "SigntoolVerify", - "parameters": [ - { - "parameterName": "VerifyAll", - "parameterValue": "/all" - } - ], - "toolName": "sign", - "toolVersion": "1.0" - } - ] - signConfigType: inlineSignParams - - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - displayName: "Temp Sensor Code Sign" - inputs: - ConnectedServiceName: "Azure IoT Edge Code Sign 2" - FolderPath: $(Build.BinariesDirectory)\publish\SimulatedTemperatureSensor - Pattern: "Microsoft.Azure.Devices.Edge.*.dll,SimulatedTemperatureSensor.dll" - SessionTimeout: 20 - inlineOperation: | - [ - { - "keyCode": "CP-230012", - "operationSetCode": "SigntoolSign", - "parameters": [ - { - "parameterName": "OpusName", - "parameterValue": "Microsoft" - }, - { - "parameterName": "OpusInfo", - "parameterValue": "http://www.microsoft.com" - }, - { - "parameterName": "Append", - "parameterValue": "/as" - }, - { - "parameterName": "FileDigest", - "parameterValue": "/fd \"SHA256\"" - }, - { - "parameterName": "PageHash", - "parameterValue": "/NPH" - }, - { - "parameterName": "TimeStamp", - "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" - } - ], - "toolName": "sign", - "toolVersion": "1.0" - }, - { - "keyCode": "CP-230012", - "operationSetCode": "SigntoolVerify", - "parameters": [ - { - "parameterName": "VerifyAll", - "parameterValue": "/all" - } - ], - "toolName": "sign", - "toolVersion": "1.0" - } - ] - signConfigType: inlineSignParams - - task: PowerShell@2 - displayName: "Build Image - Edge Agent - amd64" - inputs: - arguments: "-Name 'azureiotedge-agent' -Project 'Microsoft.Azure.Devices.Edge.Agent.Service' -Version '$(version)' -Registry '$(registry.address)' -Namespace '$(namespace)' -Push" - filePath: ./scripts/windows/build/Publish-DockerImage.ps1 - targetType: filePath - - task: PowerShell@2 - displayName: "Build Image - Edge Hub - amd64" - inputs: - arguments: "-Name 'azureiotedge-hub' -Project 'Microsoft.Azure.Devices.Edge.Hub.Service' -Version '$(version)' -Registry '$(registry.address)' -Namespace '$(namespace)' -Push" - filePath: ./scripts/windows/build/Publish-DockerImage.ps1 - targetType: filePath - - task: PowerShell@2 - displayName: "Build Image - Temp Sensor - amd64" - inputs: - arguments: "-Name 'azureiotedge-simulated-temperature-sensor' -Project 'SimulatedTemperatureSensor' -Version '$(version)' -Registry '$(registry.address)' -Namespace '$(namespace)' -Push" - filePath: ./scripts/windows/build/Publish-DockerImage.ps1 - targetType: filePath - - task: PowerShell@2 - displayName: "Build Image - azureiotedge-diagnostics - amd64" - inputs: - arguments: "-Name 'azureiotedge-diagnostics' -Project 'azureiotedge-diagnostics' -Version '$(version)' -Registry '$(registry.address)' -Namespace '$(namespace)' -Push" - filePath: ./scripts/windows/build/Publish-DockerImage.ps1 - targetType: filePath - - task: PublishBuildArtifacts@1 - displayName: "Publish Artifacts to VSTS" - inputs: - ArtifactName: publish-win - PathtoPublish: $(Build.BinariesDirectory)\publish - variables: - build.registry.address: edgebuilds.azurecr.io - build.registry.user: EdgeBuilds - registry.address: edgerelease.azurecr.io - registry.user: EdgeRelease From 3f5bf575c3b5f1f15861b758c9c206862514ea44 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 13 May 2020 15:32:44 -0700 Subject: [PATCH 077/111] raise permissions for azureiotedge-module-base-full to get network controller working --- .../modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile | 4 ---- .../modules/TestAnalyzer/docker/linux/arm64v8/base/Dockerfile | 4 ---- 2 files changed, 8 deletions(-) diff --git a/test/modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile b/test/modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile index ee7e9903abf..82682290897 100644 --- a/test/modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile +++ b/test/modules/TestAnalyzer/docker/linux/arm32v7/base/Dockerfile @@ -9,7 +9,3 @@ RUN apt-get update && apt-get install -y libcap2-bin libsnappy1v5 && \ COPY librocksdb.so /usr/lib/ RUN apt-get update && apt-get install -y --no-install-recommends iproute2 net-tools - -# Add an unprivileged user account for running the module -RUN useradd -ms /bin/bash moduleuser -USER moduleuser diff --git a/test/modules/TestAnalyzer/docker/linux/arm64v8/base/Dockerfile b/test/modules/TestAnalyzer/docker/linux/arm64v8/base/Dockerfile index cac64864a77..2d305a5c070 100644 --- a/test/modules/TestAnalyzer/docker/linux/arm64v8/base/Dockerfile +++ b/test/modules/TestAnalyzer/docker/linux/arm64v8/base/Dockerfile @@ -11,7 +11,3 @@ RUN apt-get update && \ ln -s /lib/aarch64-linux-gnu/libc.so.6 /usr/lib/aarch64-linux-gnu/libc.so.6 COPY librocksdb.so /usr/lib - -# Add an unprivileged user account for running the module -RUN useradd -ms /bin/bash moduleuser -USER moduleuser From 34e560723671d5316b01f9f413a73878c20d3c08 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 13 May 2020 16:31:48 -0700 Subject: [PATCH 078/111] restart docker --- scripts/linux/runE2ETest.sh | 3 +++ test/connectivity/scripts/testHelper.sh | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/linux/runE2ETest.sh b/scripts/linux/runE2ETest.sh index 554c2d4530a..2b71f386221 100755 --- a/scripts/linux/runE2ETest.sh +++ b/scripts/linux/runE2ETest.sh @@ -25,6 +25,9 @@ function clean_up() { if [ "$CLEAN_ALL" = '1' ]; then echo 'Prune docker system' docker system prune -af --volumes || true + + echo 'Restart docker' + systemctl restart docker fi } diff --git a/test/connectivity/scripts/testHelper.sh b/test/connectivity/scripts/testHelper.sh index cc745975137..cd97607f0f5 100644 --- a/test/connectivity/scripts/testHelper.sh +++ b/test/connectivity/scripts/testHelper.sh @@ -12,8 +12,11 @@ function clean_up() { rm -rf /etc/iotedge/config.yaml if [ "$CLEAN_ALL" = '1' ]; then - echo 'Prune docker system' + echo 'Prune docker system ' docker system prune -af --volumes || true + + echo 'Restart docker' + systemctl restart docker else echo 'Remove docker containers' docker rm -f $(docker ps -aq) || true From cb649a46e80d2e415549583630aa2d6b94dd4bc9 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 13 May 2020 16:39:36 -0700 Subject: [PATCH 079/111] fix spacing --- test/connectivity/scripts/testHelper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/connectivity/scripts/testHelper.sh b/test/connectivity/scripts/testHelper.sh index cd97607f0f5..eea42d08f0a 100644 --- a/test/connectivity/scripts/testHelper.sh +++ b/test/connectivity/scripts/testHelper.sh @@ -12,7 +12,7 @@ function clean_up() { rm -rf /etc/iotedge/config.yaml if [ "$CLEAN_ALL" = '1' ]; then - echo 'Prune docker system ' + echo 'Prune docker system' docker system prune -af --volumes || true echo 'Restart docker' From 6eb63ca61e3679f82d2e9a769bad079c0f99d395 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 14 May 2020 08:24:36 -0700 Subject: [PATCH 080/111] fix misleading error message --- builds/ci/dotnet.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builds/ci/dotnet.yaml b/builds/ci/dotnet.yaml index 0998467059a..542586221a6 100644 --- a/builds/ci/dotnet.yaml +++ b/builds/ci/dotnet.yaml @@ -33,7 +33,7 @@ jobs: IotHubMqttHeadCert - template: ../templates/install-dotnet3.yaml - task: Bash@3 - displayName: Install Prerequisites needed for RocksDB integration tests + displayName: Install Prerequisites inputs: filePath: scripts/linux/installPrereqs.sh arguments: -u $(NetCorePackageUriLinux) From b72cc9e8df5d59526de82f21ec9a927a64284389 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 14 May 2020 08:24:55 -0700 Subject: [PATCH 081/111] add usage to winarm32 build manifest --- scripts/linux/buildManifest.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/scripts/linux/buildManifest.sh b/scripts/linux/buildManifest.sh index 56aed09bd7c..d29b9dc1816 100755 --- a/scripts/linux/buildManifest.sh +++ b/scripts/linux/buildManifest.sh @@ -35,15 +35,16 @@ usage() echo "Note: Depending on the options you might have to run this as root or sudo." echo "" echo "options" - echo " -r, --registry Docker registry required to build, tag and run the module" - echo " -u, --username Docker Registry Username" - echo " -p, --password Docker Username's password" - echo " -n, --namespace Docker namespace (default: $DEFAULT_DOCKER_NAMESPACE)" - echo " -i, --image-name Docker image name (Optional if specified in template yaml)" - echo " -v, --image-version Docker Image Version." - echo " -t, --template Yaml file template for manifest definition." - echo " --tags Additional tags to add to the docker image. Specify as a list of strings. e.g. --tags \"['1.0']\"" - echo " --ignore-missing Ignore missing images in manifest" + echo " -r, --registry Docker registry required to build, tag and run the module" + echo " -u, --username Docker Registry Username" + echo " -p, --password Docker Username's password" + echo " -n, --namespace Docker namespace (default: $DEFAULT_DOCKER_NAMESPACE)" + echo " -i, --image-name Docker image name (Optional if specified in template yaml)" + echo " -v, --image-version Docker Image Version." + echo " -t, --template Yaml file template for manifest definition." + echo " -w, --win-arm32-enabled Enable the windows arm32 build manifest" + echo " --tags Additional tags to add to the docker image. Specify as a list of strings. e.g. --tags \"['1.0']\"" + echo " --ignore-missing Ignore missing images in manifest" exit 1; } From ad7e4297d8593d288ebde90014f90bcb60cc3a77 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Fri, 15 May 2020 09:27:49 -0700 Subject: [PATCH 082/111] remove arguments to prereqs script --- builds/ci/dotnet.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/builds/ci/dotnet.yaml b/builds/ci/dotnet.yaml index 542586221a6..d9497d93f1c 100644 --- a/builds/ci/dotnet.yaml +++ b/builds/ci/dotnet.yaml @@ -36,7 +36,6 @@ jobs: displayName: Install Prerequisites inputs: filePath: scripts/linux/installPrereqs.sh - arguments: -u $(NetCorePackageUriLinux) - pwsh: | $store = [System.Security.Cryptography.X509Certificates.X509Store]::new('Root', 'CurrentUser') $store.Open('ReadWrite') From 5a98eb0f80567dd5625769ba3867d2adfacdd38a Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Fri, 15 May 2020 09:37:38 -0700 Subject: [PATCH 083/111] move comment for image build functions sample to describe linux --- builds/misc/images.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builds/misc/images.yaml b/builds/misc/images.yaml index 316fad0fe3c..e406c257438 100644 --- a/builds/misc/images.yaml +++ b/builds/misc/images.yaml @@ -74,7 +74,7 @@ jobs: imageName: azureiotedge-analyzer project: TestAnalyzer - # Functions Sample + # Functions Sample - Not supported on linux arm64 - template: templates/image-linux.yaml parameters: name: Functions Sample @@ -272,7 +272,7 @@ jobs: imageName: azureiotedge-analyzer project: TestAnalyzer - # Functions Sample - Not supported on arm64 + # Functions Sample - template: templates/image-windows.yaml parameters: name: Functions Sample From 72e1d09e0a3650be114dbdac6e3e6a75293c2110 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Fri, 15 May 2020 12:40:15 -0700 Subject: [PATCH 084/111] fix indentation --- ...Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Agent.Edgelet.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Agent.IoTHub.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Hub.CloudProxy.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Hub.Core.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Hub.Http.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj | 2 +- .../Microsoft.Azure.Devices.Routing.Core.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Storage.RocksDb.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Storage.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Util.Test.Common.csproj | 2 +- tools/IoTEdgeDevOps/DemoApp/DemoApp.csproj | 6 +----- tools/IoTEdgeDevOps/DevOpsLib/DevOpsLib.csproj | 4 +--- .../IoTEdgeDevOps/IoTEdgeDashboard/IoTEdgeDashboard.csproj | 5 +---- 15 files changed, 15 insertions(+), 24 deletions(-) diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.csproj index a3f9e02ce8b..72e735b6f20 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.csproj @@ -1,6 +1,6 @@ - + True diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/Microsoft.Azure.Devices.Edge.Agent.Edgelet.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/Microsoft.Azure.Devices.Edge.Agent.Edgelet.csproj index 8c1f7e7142f..d69affa7ab7 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/Microsoft.Azure.Devices.Edge.Agent.Edgelet.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/Microsoft.Azure.Devices.Edge.Agent.Edgelet.csproj @@ -1,6 +1,6 @@ - + True diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/Microsoft.Azure.Devices.Edge.Agent.IoTHub.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/Microsoft.Azure.Devices.Edge.Agent.IoTHub.csproj index f9a3f66d996..aa1661d4358 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/Microsoft.Azure.Devices.Edge.Agent.IoTHub.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/Microsoft.Azure.Devices.Edge.Agent.IoTHub.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj index 28bdaafbf49..baaa12dbb56 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj @@ -1,5 +1,5 @@  - + True diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.CloudProxy/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.CloudProxy/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.csproj index ff5a23d5588..1759976d8c1 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.CloudProxy/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.CloudProxy/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Microsoft.Azure.Devices.Edge.Hub.Core.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Microsoft.Azure.Devices.Edge.Hub.Core.csproj index 00878518694..f026e14497f 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Microsoft.Azure.Devices.Edge.Hub.Core.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Microsoft.Azure.Devices.Edge.Hub.Core.csproj @@ -1,6 +1,6 @@  - + latest diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj index ab29d1f3dd4..32073bcbb4a 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj index 9b2ec0d4613..7a129bf5995 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-hub/src/Microsoft.Azure.Devices.Routing.Core/Microsoft.Azure.Devices.Routing.Core.csproj b/edge-hub/src/Microsoft.Azure.Devices.Routing.Core/Microsoft.Azure.Devices.Routing.Core.csproj index 701436d024c..99b18051542 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Routing.Core/Microsoft.Azure.Devices.Routing.Core.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Routing.Core/Microsoft.Azure.Devices.Routing.Core.csproj @@ -1,5 +1,5 @@  - + True diff --git a/edge-util/src/Microsoft.Azure.Devices.Edge.Storage.RocksDb/Microsoft.Azure.Devices.Edge.Storage.RocksDb.csproj b/edge-util/src/Microsoft.Azure.Devices.Edge.Storage.RocksDb/Microsoft.Azure.Devices.Edge.Storage.RocksDb.csproj index b4f39fef98b..ad5346685f8 100644 --- a/edge-util/src/Microsoft.Azure.Devices.Edge.Storage.RocksDb/Microsoft.Azure.Devices.Edge.Storage.RocksDb.csproj +++ b/edge-util/src/Microsoft.Azure.Devices.Edge.Storage.RocksDb/Microsoft.Azure.Devices.Edge.Storage.RocksDb.csproj @@ -1,7 +1,7 @@  - + True diff --git a/edge-util/src/Microsoft.Azure.Devices.Edge.Storage/Microsoft.Azure.Devices.Edge.Storage.csproj b/edge-util/src/Microsoft.Azure.Devices.Edge.Storage/Microsoft.Azure.Devices.Edge.Storage.csproj index e944f05f498..93a9d8c8db8 100644 --- a/edge-util/src/Microsoft.Azure.Devices.Edge.Storage/Microsoft.Azure.Devices.Edge.Storage.csproj +++ b/edge-util/src/Microsoft.Azure.Devices.Edge.Storage/Microsoft.Azure.Devices.Edge.Storage.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test.Common/Microsoft.Azure.Devices.Edge.Util.Test.Common.csproj b/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test.Common/Microsoft.Azure.Devices.Edge.Util.Test.Common.csproj index e3929bfdd99..a71b68b0ebf 100644 --- a/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test.Common/Microsoft.Azure.Devices.Edge.Util.Test.Common.csproj +++ b/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test.Common/Microsoft.Azure.Devices.Edge.Util.Test.Common.csproj @@ -1,6 +1,6 @@  - + True diff --git a/tools/IoTEdgeDevOps/DemoApp/DemoApp.csproj b/tools/IoTEdgeDevOps/DemoApp/DemoApp.csproj index 82c1563dd64..8afe2bf5497 100644 --- a/tools/IoTEdgeDevOps/DemoApp/DemoApp.csproj +++ b/tools/IoTEdgeDevOps/DemoApp/DemoApp.csproj @@ -1,10 +1,6 @@ - - Exe - netcoreapp3.1 - 7.1 - + diff --git a/tools/IoTEdgeDevOps/DevOpsLib/DevOpsLib.csproj b/tools/IoTEdgeDevOps/DevOpsLib/DevOpsLib.csproj index 23c8f57a316..e4957088d00 100644 --- a/tools/IoTEdgeDevOps/DevOpsLib/DevOpsLib.csproj +++ b/tools/IoTEdgeDevOps/DevOpsLib/DevOpsLib.csproj @@ -1,8 +1,6 @@ - - netcoreapp3.1 - + diff --git a/tools/IoTEdgeDevOps/IoTEdgeDashboard/IoTEdgeDashboard.csproj b/tools/IoTEdgeDevOps/IoTEdgeDashboard/IoTEdgeDashboard.csproj index deb5b22cd1b..251fd5a7f85 100644 --- a/tools/IoTEdgeDevOps/IoTEdgeDashboard/IoTEdgeDashboard.csproj +++ b/tools/IoTEdgeDevOps/IoTEdgeDashboard/IoTEdgeDashboard.csproj @@ -1,9 +1,6 @@ - - netcoreapp3.1 - InProcess - + From fc2802a8ad225b60b9bccc859b61e604db67f713 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Fri, 15 May 2020 12:48:09 -0700 Subject: [PATCH 085/111] fix indentation --- .../Microsoft.Azure.Devices.Edge.Util.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/Microsoft.Azure.Devices.Edge.Util.csproj b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/Microsoft.Azure.Devices.Edge.Util.csproj index 20411f7b3c8..6d87b176e36 100644 --- a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/Microsoft.Azure.Devices.Edge.Util.csproj +++ b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/Microsoft.Azure.Devices.Edge.Util.csproj @@ -1,6 +1,6 @@  - + True From b5ec53ef05e49d35350391ef1aef32f6e3e655e7 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Fri, 15 May 2020 13:44:40 -0700 Subject: [PATCH 086/111] don't run moduleuser for images using module-base-full --- test/modules/TestAnalyzer/docker/linux/arm32v7/Dockerfile | 2 -- test/modules/TestAnalyzer/docker/linux/arm64v8/Dockerfile | 2 -- .../TestResultCoordinator/docker/linux/arm32v7/Dockerfile | 2 -- .../TestResultCoordinator/docker/linux/arm64v8/Dockerfile | 2 -- 4 files changed, 8 deletions(-) diff --git a/test/modules/TestAnalyzer/docker/linux/arm32v7/Dockerfile b/test/modules/TestAnalyzer/docker/linux/arm32v7/Dockerfile index fa5d1633060..a1116606f02 100644 --- a/test/modules/TestAnalyzer/docker/linux/arm32v7/Dockerfile +++ b/test/modules/TestAnalyzer/docker/linux/arm32v7/Dockerfile @@ -9,7 +9,5 @@ WORKDIR /app COPY $EXE_DIR/ ./ -USER moduleuser - CMD echo "$(date --utc +"[%Y-%m-%d %H:%M:%S %:z]"): Starting Module" && \ exec /usr/bin/dotnet TestAnalyzer.dll diff --git a/test/modules/TestAnalyzer/docker/linux/arm64v8/Dockerfile b/test/modules/TestAnalyzer/docker/linux/arm64v8/Dockerfile index 5c2f25fa189..6a644750274 100644 --- a/test/modules/TestAnalyzer/docker/linux/arm64v8/Dockerfile +++ b/test/modules/TestAnalyzer/docker/linux/arm64v8/Dockerfile @@ -9,7 +9,5 @@ WORKDIR /app COPY $EXE_DIR/ ./ -USER moduleuser - CMD echo "$(date --utc +"%Y-%m-%d %H:%M:%S %:z") Starting Module" && \ exec /usr/bin/dotnet TestAnalyzer.dll diff --git a/test/modules/TestResultCoordinator/docker/linux/arm32v7/Dockerfile b/test/modules/TestResultCoordinator/docker/linux/arm32v7/Dockerfile index 6c736f91537..f6b44f39fd4 100644 --- a/test/modules/TestResultCoordinator/docker/linux/arm32v7/Dockerfile +++ b/test/modules/TestResultCoordinator/docker/linux/arm32v7/Dockerfile @@ -12,7 +12,5 @@ COPY $EXE_DIR/ ./ # Expose HTTP port EXPOSE 5001/tcp -USER moduleuser - CMD echo "$(date --utc +"[%Y-%m-%d %H:%M:%S %:z]"): Starting Module" && \ exec /usr/bin/dotnet TestResultCoordinator.dll diff --git a/test/modules/TestResultCoordinator/docker/linux/arm64v8/Dockerfile b/test/modules/TestResultCoordinator/docker/linux/arm64v8/Dockerfile index 9e7d7c80ff6..ff74bfe1663 100644 --- a/test/modules/TestResultCoordinator/docker/linux/arm64v8/Dockerfile +++ b/test/modules/TestResultCoordinator/docker/linux/arm64v8/Dockerfile @@ -12,7 +12,5 @@ COPY $EXE_DIR/ ./ # Expose HTTP port EXPOSE 5001/tcp -USER moduleuser - CMD echo "$(date --utc +"%Y-%m-%d %H:%M:%S %:z") Starting Module" && \ exec /usr/bin/dotnet TestResultCoordinator.dll From 8dd6f618794a5016d444e33dc8738349fa50f0ac Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Fri, 15 May 2020 16:21:25 -0700 Subject: [PATCH 087/111] merge upstream master --- scripts/linux/runE2ETest.sh | 4 ---- test/connectivity/scripts/testHelper.sh | 4 ---- 2 files changed, 8 deletions(-) diff --git a/scripts/linux/runE2ETest.sh b/scripts/linux/runE2ETest.sh index 97d8c40888b..bf18c320474 100755 --- a/scripts/linux/runE2ETest.sh +++ b/scripts/linux/runE2ETest.sh @@ -27,11 +27,7 @@ function clean_up() { docker system prune -af --volumes || true echo 'Restart docker' -<<<<<<< HEAD - systemctl restart docker -======= systemctl restart docker # needed due to https://github.com/moby/moby/issues/23302 ->>>>>>> 80dfe7097cb4e63a4fc70514d3a125a2b6126ec5 fi } diff --git a/test/connectivity/scripts/testHelper.sh b/test/connectivity/scripts/testHelper.sh index 904a265bb89..f3ca2b07424 100644 --- a/test/connectivity/scripts/testHelper.sh +++ b/test/connectivity/scripts/testHelper.sh @@ -16,11 +16,7 @@ function clean_up() { docker system prune -af --volumes || true echo 'Restart docker' -<<<<<<< HEAD - systemctl restart docker -======= systemctl restart docker # needed due to https://github.com/moby/moby/issues/23302 ->>>>>>> 80dfe7097cb4e63a4fc70514d3a125a2b6126ec5 else echo 'Remove docker containers' docker rm -f $(docker ps -aq) || true From 2f9d862eb92df62c4f406c3f0db98cccb6571de0 Mon Sep 17 00:00:00 2001 From: Philip Lin Date: Fri, 15 May 2020 19:37:52 -0700 Subject: [PATCH 088/111] Consolidate multiple versions of NuGet packages. --- .../Microsoft.Azure.Devices.Routing.Core.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Hub.CloudProxy.Test.csproj | 2 +- .../samples/EdgeHubTrigger-Csharp/EdgeHubTriggerCSharp.csproj | 2 +- .../EdgeX509AuthDownstreamDevice.csproj | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Routing.Core/Microsoft.Azure.Devices.Routing.Core.csproj b/edge-hub/src/Microsoft.Azure.Devices.Routing.Core/Microsoft.Azure.Devices.Routing.Core.csproj index 99b18051542..54f3013c223 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Routing.Core/Microsoft.Azure.Devices.Routing.Core.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Routing.Core/Microsoft.Azure.Devices.Routing.Core.csproj @@ -19,7 +19,7 @@ - + diff --git a/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.Test/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.Test.csproj b/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.Test/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.Test.csproj index 25a9c7204ad..db457a1e969 100644 --- a/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.Test/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.Test.csproj +++ b/edge-hub/test/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.Test/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.Test.csproj @@ -10,7 +10,7 @@ - + diff --git a/edge-modules/functions/samples/EdgeHubTrigger-Csharp/EdgeHubTriggerCSharp.csproj b/edge-modules/functions/samples/EdgeHubTrigger-Csharp/EdgeHubTriggerCSharp.csproj index b38cc32bd69..4a8caf486d7 100644 --- a/edge-modules/functions/samples/EdgeHubTrigger-Csharp/EdgeHubTriggerCSharp.csproj +++ b/edge-modules/functions/samples/EdgeHubTrigger-Csharp/EdgeHubTriggerCSharp.csproj @@ -24,7 +24,7 @@ - + diff --git a/samples/dotnet/EdgeX509AuthDownstreamDevice/EdgeX509AuthDownstreamDevice.csproj b/samples/dotnet/EdgeX509AuthDownstreamDevice/EdgeX509AuthDownstreamDevice.csproj index d73d1a4e65a..9ecd19598da 100644 --- a/samples/dotnet/EdgeX509AuthDownstreamDevice/EdgeX509AuthDownstreamDevice.csproj +++ b/samples/dotnet/EdgeX509AuthDownstreamDevice/EdgeX509AuthDownstreamDevice.csproj @@ -9,8 +9,8 @@ - - + + From dd78b34e8faed0998627ca79e30748ee50c24c73 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Sun, 17 May 2020 17:17:25 -0700 Subject: [PATCH 089/111] use netstandard where possible --- .../Microsoft.Azure.Devices.Edge.Agent.Core.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Agent.Diagnostics.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Agent.Docker.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Agent.Edgelet.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Agent.IoTHub.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Agent.Kubernetes.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Agent.Service.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Agent.Core.Test.csproj | 2 +- ...icrosoft.Azure.Devices.Edge.Agent.Diagnostics.Test.csproj | 2 +- ...Microsoft.Azure.Devices.Edge.Agent.Docker.E2E.Test.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Agent.Docker.Test.csproj | 2 +- ...osoft.Azure.Devices.Edge.Agent.Edgelet.Docker.Test.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test.csproj | 2 +- ...icrosoft.Azure.Devices.Edge.Agent.Integration.Test.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Agent.IoTHub.Test.csproj | 2 +- ...zure.Devices.Edge.Agent.Kubernetes.IntegrationTest.csproj | 2 +- ...Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Hub.CloudProxy.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Hub.Core.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Hub.Http.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Hub.Service.csproj | 2 +- .../Microsoft.Azure.Devices.Routing.Core.csproj | 3 ++- .../Microsoft.Azure.Devices.Edge.Hub.Amqp.Test.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Hub.CloudProxy.Test.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Hub.Core.Test.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Hub.E2E.Test.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Hub.Http.Test.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Hub.Mqtt.Test.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Hub.Service.Test.csproj | 2 +- .../Microsoft.Azure.Devices.Routing.Core.Test.csproj | 2 +- edge-modules/MetricsCollector/MetricsCollector.csproj | 2 +- .../SimulatedTemperatureSensor.csproj | 2 +- .../Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj | 2 +- .../EdgeHubTrigger-Csharp/EdgeHubTriggerCSharp.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Storage.RocksDb.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Storage.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Util.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Storage.RocksDb.Test.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Storage.Test.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Util.Test.Common.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Util.Test.csproj | 2 +- dotnetVersion.props => netcoreappVersion.props | 0 netstandardVersion.props | 5 +++++ .../dotnet/EdgeDownstreamDevice/EdgeDownstreamDevice.csproj | 2 +- .../EdgeX509AuthDownstreamDevice.csproj | 2 +- smoke/IotEdgeQuickstart/IotEdgeQuickstart.csproj | 2 +- smoke/LeafDevice/LeafDevice.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Test.Common.csproj | 2 +- .../Microsoft.Azure.Devices.Edge.Test.csproj | 2 +- .../modules/NetworkController/NetworkController.csproj | 2 +- .../CloudToDeviceMessageTester.csproj | 2 +- test/modules/DeploymentTester/DeploymentTester.csproj | 2 +- .../modules/DirectMethodReceiver/DirectMethodReceiver.csproj | 2 +- test/modules/DirectMethodSender/DirectMethodSender.csproj | 2 +- .../modules/EdgeHubRestartTester/EdgeHubRestartTester.csproj | 2 +- test/modules/MetricsValidator/MetricsValidator.csproj | 2 +- .../ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj | 2 +- test/modules/ModuleRestarter/ModuleRestarter.csproj | 2 +- test/modules/Modules.Test/Modules.Test.csproj | 2 +- test/modules/Relayer/Relayer.csproj | 2 +- test/modules/TemperatureFilter/TemperatureFilter.csproj | 2 +- test/modules/TestAnalyzer/TestAnalyzer.csproj | 2 +- .../TestResultCoordinator/TestResultCoordinator.csproj | 2 +- test/modules/TwinTester/TwinTester.csproj | 2 +- test/modules/load-gen/load-gen.csproj | 2 +- tools/IoTEdgeDevOps/DemoApp/DemoApp.csproj | 2 +- tools/IoTEdgeDevOps/DevOpsLib/DevOpsLib.csproj | 2 +- tools/IoTEdgeDevOps/IoTEdgeDashboard/IoTEdgeDashboard.csproj | 2 +- 71 files changed, 75 insertions(+), 69 deletions(-) rename dotnetVersion.props => netcoreappVersion.props (100%) create mode 100644 netstandardVersion.props diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Core/Microsoft.Azure.Devices.Edge.Agent.Core.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Core/Microsoft.Azure.Devices.Edge.Agent.Core.csproj index 5c80c3dc618..2b133a42846 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Core/Microsoft.Azure.Devices.Edge.Agent.Core.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Core/Microsoft.Azure.Devices.Edge.Agent.Core.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Diagnostics/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Diagnostics/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.csproj index aaa4aa2079e..1a4a7ebefc3 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Diagnostics/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Diagnostics/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Docker/Microsoft.Azure.Devices.Edge.Agent.Docker.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Docker/Microsoft.Azure.Devices.Edge.Agent.Docker.csproj index 6803c799987..b08892c05d8 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Docker/Microsoft.Azure.Devices.Edge.Agent.Docker.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Docker/Microsoft.Azure.Devices.Edge.Agent.Docker.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.csproj index 72e735b6f20..448b533fd8d 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.csproj @@ -1,6 +1,6 @@ - + True diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/Microsoft.Azure.Devices.Edge.Agent.Edgelet.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/Microsoft.Azure.Devices.Edge.Agent.Edgelet.csproj index d69affa7ab7..ac10a9d9cb6 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/Microsoft.Azure.Devices.Edge.Agent.Edgelet.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/Microsoft.Azure.Devices.Edge.Agent.Edgelet.csproj @@ -1,6 +1,6 @@ - + True diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/Microsoft.Azure.Devices.Edge.Agent.IoTHub.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/Microsoft.Azure.Devices.Edge.Agent.IoTHub.csproj index aa1661d4358..41df542d167 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/Microsoft.Azure.Devices.Edge.Agent.IoTHub.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/Microsoft.Azure.Devices.Edge.Agent.IoTHub.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Kubernetes/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Kubernetes/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.csproj index a836529af5f..6b28afcfeca 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Kubernetes/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Kubernetes/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Service/Microsoft.Azure.Devices.Edge.Agent.Service.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Service/Microsoft.Azure.Devices.Edge.Agent.Service.csproj index 1094a16d2fb..d123420f87d 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Service/Microsoft.Azure.Devices.Edge.Agent.Service.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Service/Microsoft.Azure.Devices.Edge.Agent.Service.csproj @@ -1,5 +1,5 @@  - + Exe diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Core.Test/Microsoft.Azure.Devices.Edge.Agent.Core.Test.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Core.Test/Microsoft.Azure.Devices.Edge.Agent.Core.Test.csproj index 429b211a1a4..4814953b99a 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Core.Test/Microsoft.Azure.Devices.Edge.Agent.Core.Test.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Core.Test/Microsoft.Azure.Devices.Edge.Agent.Core.Test.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.Test/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.Test.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.Test/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.Test.csproj index 0eff369fd16..84bade4da0f 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.Test/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.Test.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.Test/Microsoft.Azure.Devices.Edge.Agent.Diagnostics.Test.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Docker.E2E.Test/Microsoft.Azure.Devices.Edge.Agent.Docker.E2E.Test.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Docker.E2E.Test/Microsoft.Azure.Devices.Edge.Agent.Docker.E2E.Test.csproj index 599a3657014..c73886bcf3e 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Docker.E2E.Test/Microsoft.Azure.Devices.Edge.Agent.Docker.E2E.Test.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Docker.E2E.Test/Microsoft.Azure.Devices.Edge.Agent.Docker.E2E.Test.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Docker.Test/Microsoft.Azure.Devices.Edge.Agent.Docker.Test.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Docker.Test/Microsoft.Azure.Devices.Edge.Agent.Docker.Test.csproj index b5bb22fc0b3..2b948e4b700 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Docker.Test/Microsoft.Azure.Devices.Edge.Agent.Docker.Test.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Docker.Test/Microsoft.Azure.Devices.Edge.Agent.Docker.Test.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.Test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.Test.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.Test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.Test.csproj index ef4d5768b0d..e39ce9350b4 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.Test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.Test.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.Test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Docker.Test.csproj @@ -1,6 +1,6 @@  - + false diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test.csproj index d7fd8f6f972..f632dc0b082 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test/Microsoft.Azure.Devices.Edge.Agent.Edgelet.Test.csproj @@ -1,5 +1,5 @@  - + True diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Integration.Test/Microsoft.Azure.Devices.Edge.Agent.Integration.Test.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Integration.Test/Microsoft.Azure.Devices.Edge.Agent.Integration.Test.csproj index b9829bbffb3..6e76f9cf96d 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Integration.Test/Microsoft.Azure.Devices.Edge.Agent.Integration.Test.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Integration.Test/Microsoft.Azure.Devices.Edge.Agent.Integration.Test.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.IoTHub.Test/Microsoft.Azure.Devices.Edge.Agent.IoTHub.Test.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.IoTHub.Test/Microsoft.Azure.Devices.Edge.Agent.IoTHub.Test.csproj index 431954e6872..8d0930ba5b7 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.IoTHub.Test/Microsoft.Azure.Devices.Edge.Agent.IoTHub.Test.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.IoTHub.Test/Microsoft.Azure.Devices.Edge.Agent.IoTHub.Test.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.IntegrationTest/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.IntegrationTest.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.IntegrationTest/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.IntegrationTest.csproj index ea2776063c1..d5a4bfeb30d 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.IntegrationTest/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.IntegrationTest.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.IntegrationTest/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.IntegrationTest.csproj @@ -1,6 +1,6 @@ - + True diff --git a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test.csproj b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test.csproj index 4b275054780..2a7935a6efd 100644 --- a/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test.csproj +++ b/edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.Test.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj index baaa12dbb56..803e705fccd 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj @@ -1,5 +1,5 @@  - + True diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.CloudProxy/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.CloudProxy/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.csproj index 1759976d8c1..2112c2b8920 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.CloudProxy/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.CloudProxy/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Microsoft.Azure.Devices.Edge.Hub.Core.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Microsoft.Azure.Devices.Edge.Hub.Core.csproj index f026e14497f..ac576570510 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Microsoft.Azure.Devices.Edge.Hub.Core.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Microsoft.Azure.Devices.Edge.Hub.Core.csproj @@ -1,6 +1,6 @@  - + latest diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj index 32073bcbb4a..b7617bea4dc 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj index 7a129bf5995..1d04b5b32e0 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Microsoft.Azure.Devices.Edge.Hub.Service.csproj b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Microsoft.Azure.Devices.Edge.Hub.Service.csproj index ec887ac614e..e3153a94f12 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Microsoft.Azure.Devices.Edge.Hub.Service.csproj +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Microsoft.Azure.Devices.Edge.Hub.Service.csproj @@ -1,6 +1,6 @@  - + - + True diff --git a/edge-util/src/Microsoft.Azure.Devices.Edge.Storage/Microsoft.Azure.Devices.Edge.Storage.csproj b/edge-util/src/Microsoft.Azure.Devices.Edge.Storage/Microsoft.Azure.Devices.Edge.Storage.csproj index 93a9d8c8db8..9510971194b 100644 --- a/edge-util/src/Microsoft.Azure.Devices.Edge.Storage/Microsoft.Azure.Devices.Edge.Storage.csproj +++ b/edge-util/src/Microsoft.Azure.Devices.Edge.Storage/Microsoft.Azure.Devices.Edge.Storage.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/Microsoft.Azure.Devices.Edge.Util.csproj b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/Microsoft.Azure.Devices.Edge.Util.csproj index 6d87b176e36..07a513b17c5 100644 --- a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/Microsoft.Azure.Devices.Edge.Util.csproj +++ b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/Microsoft.Azure.Devices.Edge.Util.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-util/test/Microsoft.Azure.Devices.Edge.Storage.RocksDb.Test/Microsoft.Azure.Devices.Edge.Storage.RocksDb.Test.csproj b/edge-util/test/Microsoft.Azure.Devices.Edge.Storage.RocksDb.Test/Microsoft.Azure.Devices.Edge.Storage.RocksDb.Test.csproj index 92f0dc7530c..6c446c40649 100644 --- a/edge-util/test/Microsoft.Azure.Devices.Edge.Storage.RocksDb.Test/Microsoft.Azure.Devices.Edge.Storage.RocksDb.Test.csproj +++ b/edge-util/test/Microsoft.Azure.Devices.Edge.Storage.RocksDb.Test/Microsoft.Azure.Devices.Edge.Storage.RocksDb.Test.csproj @@ -1,6 +1,6 @@  - + false diff --git a/edge-util/test/Microsoft.Azure.Devices.Edge.Storage.Test/Microsoft.Azure.Devices.Edge.Storage.Test.csproj b/edge-util/test/Microsoft.Azure.Devices.Edge.Storage.Test/Microsoft.Azure.Devices.Edge.Storage.Test.csproj index 11e64f9f216..f9fd8d5fdd1 100644 --- a/edge-util/test/Microsoft.Azure.Devices.Edge.Storage.Test/Microsoft.Azure.Devices.Edge.Storage.Test.csproj +++ b/edge-util/test/Microsoft.Azure.Devices.Edge.Storage.Test/Microsoft.Azure.Devices.Edge.Storage.Test.csproj @@ -1,6 +1,6 @@  - + false diff --git a/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test.Common/Microsoft.Azure.Devices.Edge.Util.Test.Common.csproj b/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test.Common/Microsoft.Azure.Devices.Edge.Util.Test.Common.csproj index a71b68b0ebf..a857b70e52b 100644 --- a/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test.Common/Microsoft.Azure.Devices.Edge.Util.Test.Common.csproj +++ b/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test.Common/Microsoft.Azure.Devices.Edge.Util.Test.Common.csproj @@ -1,6 +1,6 @@  - + True diff --git a/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/Microsoft.Azure.Devices.Edge.Util.Test.csproj b/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/Microsoft.Azure.Devices.Edge.Util.Test.csproj index 310d836a7d1..39637421cc7 100644 --- a/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/Microsoft.Azure.Devices.Edge.Util.Test.csproj +++ b/edge-util/test/Microsoft.Azure.Devices.Edge.Util.Test/Microsoft.Azure.Devices.Edge.Util.Test.csproj @@ -1,6 +1,6 @@  - + True diff --git a/dotnetVersion.props b/netcoreappVersion.props similarity index 100% rename from dotnetVersion.props rename to netcoreappVersion.props diff --git a/netstandardVersion.props b/netstandardVersion.props new file mode 100644 index 00000000000..a7e24746702 --- /dev/null +++ b/netstandardVersion.props @@ -0,0 +1,5 @@ + + + netstandard2.1 + + diff --git a/samples/dotnet/EdgeDownstreamDevice/EdgeDownstreamDevice.csproj b/samples/dotnet/EdgeDownstreamDevice/EdgeDownstreamDevice.csproj index c213cc12fbf..6350a39cc9b 100644 --- a/samples/dotnet/EdgeDownstreamDevice/EdgeDownstreamDevice.csproj +++ b/samples/dotnet/EdgeDownstreamDevice/EdgeDownstreamDevice.csproj @@ -1,6 +1,6 @@ - + Exe diff --git a/samples/dotnet/EdgeX509AuthDownstreamDevice/EdgeX509AuthDownstreamDevice.csproj b/samples/dotnet/EdgeX509AuthDownstreamDevice/EdgeX509AuthDownstreamDevice.csproj index 9ecd19598da..874e13e97ca 100644 --- a/samples/dotnet/EdgeX509AuthDownstreamDevice/EdgeX509AuthDownstreamDevice.csproj +++ b/samples/dotnet/EdgeX509AuthDownstreamDevice/EdgeX509AuthDownstreamDevice.csproj @@ -1,6 +1,6 @@ - + Exe diff --git a/smoke/IotEdgeQuickstart/IotEdgeQuickstart.csproj b/smoke/IotEdgeQuickstart/IotEdgeQuickstart.csproj index 7d0c7beb334..66dcd284d7a 100644 --- a/smoke/IotEdgeQuickstart/IotEdgeQuickstart.csproj +++ b/smoke/IotEdgeQuickstart/IotEdgeQuickstart.csproj @@ -1,6 +1,6 @@  - + Exe diff --git a/smoke/LeafDevice/LeafDevice.csproj b/smoke/LeafDevice/LeafDevice.csproj index bcec08db417..8e4c8e62d22 100644 --- a/smoke/LeafDevice/LeafDevice.csproj +++ b/smoke/LeafDevice/LeafDevice.csproj @@ -1,6 +1,6 @@  - + Exe diff --git a/test/Microsoft.Azure.Devices.Edge.Test.Common/Microsoft.Azure.Devices.Edge.Test.Common.csproj b/test/Microsoft.Azure.Devices.Edge.Test.Common/Microsoft.Azure.Devices.Edge.Test.Common.csproj index 5c9d2db1b34..26620d706a4 100644 --- a/test/Microsoft.Azure.Devices.Edge.Test.Common/Microsoft.Azure.Devices.Edge.Test.Common.csproj +++ b/test/Microsoft.Azure.Devices.Edge.Test.Common/Microsoft.Azure.Devices.Edge.Test.Common.csproj @@ -1,6 +1,6 @@ - + Debug;Release;CheckInBuild diff --git a/test/Microsoft.Azure.Devices.Edge.Test/Microsoft.Azure.Devices.Edge.Test.csproj b/test/Microsoft.Azure.Devices.Edge.Test/Microsoft.Azure.Devices.Edge.Test.csproj index 42f800f5501..f90c0ed6609 100644 --- a/test/Microsoft.Azure.Devices.Edge.Test/Microsoft.Azure.Devices.Edge.Test.csproj +++ b/test/Microsoft.Azure.Devices.Edge.Test/Microsoft.Azure.Devices.Edge.Test.csproj @@ -1,6 +1,6 @@  - + True diff --git a/test/connectivity/modules/NetworkController/NetworkController.csproj b/test/connectivity/modules/NetworkController/NetworkController.csproj index 6d8e437aa74..71337ccd532 100644 --- a/test/connectivity/modules/NetworkController/NetworkController.csproj +++ b/test/connectivity/modules/NetworkController/NetworkController.csproj @@ -1,6 +1,6 @@  - + Exe diff --git a/test/modules/CloudToDeviceMessageTester/CloudToDeviceMessageTester.csproj b/test/modules/CloudToDeviceMessageTester/CloudToDeviceMessageTester.csproj index 3ffd1e9029b..dd7ced7edb3 100644 --- a/test/modules/CloudToDeviceMessageTester/CloudToDeviceMessageTester.csproj +++ b/test/modules/CloudToDeviceMessageTester/CloudToDeviceMessageTester.csproj @@ -1,6 +1,6 @@  - + Exe diff --git a/test/modules/DeploymentTester/DeploymentTester.csproj b/test/modules/DeploymentTester/DeploymentTester.csproj index 42ac8ca0366..89a5280fa3c 100644 --- a/test/modules/DeploymentTester/DeploymentTester.csproj +++ b/test/modules/DeploymentTester/DeploymentTester.csproj @@ -1,6 +1,6 @@ - + Exe diff --git a/test/modules/DirectMethodReceiver/DirectMethodReceiver.csproj b/test/modules/DirectMethodReceiver/DirectMethodReceiver.csproj index 330c5ee184b..e53b1e110cf 100644 --- a/test/modules/DirectMethodReceiver/DirectMethodReceiver.csproj +++ b/test/modules/DirectMethodReceiver/DirectMethodReceiver.csproj @@ -1,5 +1,5 @@  - + Exe diff --git a/test/modules/DirectMethodSender/DirectMethodSender.csproj b/test/modules/DirectMethodSender/DirectMethodSender.csproj index 527f330a3c5..59526564093 100644 --- a/test/modules/DirectMethodSender/DirectMethodSender.csproj +++ b/test/modules/DirectMethodSender/DirectMethodSender.csproj @@ -1,6 +1,6 @@  - + Exe diff --git a/test/modules/EdgeHubRestartTester/EdgeHubRestartTester.csproj b/test/modules/EdgeHubRestartTester/EdgeHubRestartTester.csproj index b43bb812afd..e0d28841bb0 100644 --- a/test/modules/EdgeHubRestartTester/EdgeHubRestartTester.csproj +++ b/test/modules/EdgeHubRestartTester/EdgeHubRestartTester.csproj @@ -1,6 +1,6 @@ - + Exe diff --git a/test/modules/MetricsValidator/MetricsValidator.csproj b/test/modules/MetricsValidator/MetricsValidator.csproj index f43d86edb43..234dce66418 100644 --- a/test/modules/MetricsValidator/MetricsValidator.csproj +++ b/test/modules/MetricsValidator/MetricsValidator.csproj @@ -1,6 +1,6 @@  - + Exe diff --git a/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj b/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj index 976a9499145..126f7201f0b 100644 --- a/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj +++ b/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj @@ -1,6 +1,6 @@  - + diff --git a/test/modules/ModuleRestarter/ModuleRestarter.csproj b/test/modules/ModuleRestarter/ModuleRestarter.csproj index a4df47eb0ca..a03fadcfb8f 100644 --- a/test/modules/ModuleRestarter/ModuleRestarter.csproj +++ b/test/modules/ModuleRestarter/ModuleRestarter.csproj @@ -1,6 +1,6 @@  - + Exe diff --git a/test/modules/Modules.Test/Modules.Test.csproj b/test/modules/Modules.Test/Modules.Test.csproj index c6afa0332d5..97952ff8483 100644 --- a/test/modules/Modules.Test/Modules.Test.csproj +++ b/test/modules/Modules.Test/Modules.Test.csproj @@ -1,6 +1,6 @@  - + True diff --git a/test/modules/Relayer/Relayer.csproj b/test/modules/Relayer/Relayer.csproj index a6a16699f97..ab230f56315 100644 --- a/test/modules/Relayer/Relayer.csproj +++ b/test/modules/Relayer/Relayer.csproj @@ -1,6 +1,6 @@  - + Exe diff --git a/test/modules/TemperatureFilter/TemperatureFilter.csproj b/test/modules/TemperatureFilter/TemperatureFilter.csproj index 583aa831cd5..b7b2abbbfc9 100644 --- a/test/modules/TemperatureFilter/TemperatureFilter.csproj +++ b/test/modules/TemperatureFilter/TemperatureFilter.csproj @@ -1,6 +1,6 @@  - + Exe diff --git a/test/modules/TestAnalyzer/TestAnalyzer.csproj b/test/modules/TestAnalyzer/TestAnalyzer.csproj index 1508e0130d4..902e68fd848 100644 --- a/test/modules/TestAnalyzer/TestAnalyzer.csproj +++ b/test/modules/TestAnalyzer/TestAnalyzer.csproj @@ -1,6 +1,6 @@  - + Exe diff --git a/test/modules/TestResultCoordinator/TestResultCoordinator.csproj b/test/modules/TestResultCoordinator/TestResultCoordinator.csproj index c3e238f856d..ce55a067e85 100644 --- a/test/modules/TestResultCoordinator/TestResultCoordinator.csproj +++ b/test/modules/TestResultCoordinator/TestResultCoordinator.csproj @@ -1,6 +1,6 @@  - + Exe diff --git a/test/modules/TwinTester/TwinTester.csproj b/test/modules/TwinTester/TwinTester.csproj index 0b87947ec96..742b2d599ea 100644 --- a/test/modules/TwinTester/TwinTester.csproj +++ b/test/modules/TwinTester/TwinTester.csproj @@ -1,6 +1,6 @@  - + Exe diff --git a/test/modules/load-gen/load-gen.csproj b/test/modules/load-gen/load-gen.csproj index d73126d28dd..505742d9e5d 100644 --- a/test/modules/load-gen/load-gen.csproj +++ b/test/modules/load-gen/load-gen.csproj @@ -1,6 +1,6 @@  - + Exe diff --git a/tools/IoTEdgeDevOps/DemoApp/DemoApp.csproj b/tools/IoTEdgeDevOps/DemoApp/DemoApp.csproj index 8afe2bf5497..3ef73fec24e 100644 --- a/tools/IoTEdgeDevOps/DemoApp/DemoApp.csproj +++ b/tools/IoTEdgeDevOps/DemoApp/DemoApp.csproj @@ -1,6 +1,6 @@ - + diff --git a/tools/IoTEdgeDevOps/DevOpsLib/DevOpsLib.csproj b/tools/IoTEdgeDevOps/DevOpsLib/DevOpsLib.csproj index e4957088d00..0c2f29bb1f1 100644 --- a/tools/IoTEdgeDevOps/DevOpsLib/DevOpsLib.csproj +++ b/tools/IoTEdgeDevOps/DevOpsLib/DevOpsLib.csproj @@ -1,6 +1,6 @@ - + diff --git a/tools/IoTEdgeDevOps/IoTEdgeDashboard/IoTEdgeDashboard.csproj b/tools/IoTEdgeDevOps/IoTEdgeDashboard/IoTEdgeDashboard.csproj index 251fd5a7f85..31dfca22592 100644 --- a/tools/IoTEdgeDevOps/IoTEdgeDashboard/IoTEdgeDashboard.csproj +++ b/tools/IoTEdgeDevOps/IoTEdgeDashboard/IoTEdgeDashboard.csproj @@ -1,6 +1,6 @@ - + From 1276752c5ae03adcf833dbf06713ddcc97e66010 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Sun, 17 May 2020 17:31:27 -0700 Subject: [PATCH 090/111] add same basic validation as in aspnet's HttpsConnectionMiddleware --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index cd61522a167..c84e8079bf7 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -3,6 +3,7 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service { using System.Collections.Generic; using System.Net; + using System.Net.Security; using System.Net.Sockets; using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; @@ -55,6 +56,11 @@ public static Hosting Initialize( options.ClientCertificateRequired = true; options.RemoteCertificateValidationCallback = (_, clientCert, chain, policyErrors) => { + if (clientCert == null || policyErrors != SslPolicyErrors.None) + { + return false; + } + Option chainOption = chain == null ? Option.None() : Option.Some(chain); TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chainOption); context.Features.Set(tlsConnectionFeatureExtended); From 0d192e65d8a2c4d6d60c3db1479b5f63567cdb76 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 18 May 2020 07:54:53 -0700 Subject: [PATCH 091/111] make moduleUtil netstandard --- .../ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj b/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj index 126f7201f0b..3c0aab54d76 100644 --- a/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj +++ b/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj @@ -1,6 +1,6 @@  - + From c6a41dcdc6d53dcbbe7454a8534028e8681e9104 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 18 May 2020 08:40:41 -0700 Subject: [PATCH 092/111] update condition to skip arm64 linux build if other steps fail --- builds/misc/templates/image-linux.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builds/misc/templates/image-linux.yaml b/builds/misc/templates/image-linux.yaml index d6bd8bda9af..30139837baa 100644 --- a/builds/misc/templates/image-linux.yaml +++ b/builds/misc/templates/image-linux.yaml @@ -17,7 +17,7 @@ steps: arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i ${{ parameters.imageName }} -n ${{ parameters.namespace }} -P ${{ parameters.project }} --target-arch armv7l - task: Bash@3 displayName: Build Image - ${{ parameters.name }} - arm64 - condition: ne('${{ parameters.name }}', 'Functions Sample') + condition: and(ne('${{ parameters.name }}', 'Functions Sample'), succeeded()) inputs: filePath: scripts/linux/buildImage.sh arguments: -r $(registry.address) -u $(registry.user) -p $(registry.password) -i ${{ parameters.imageName }} -n ${{ parameters.namespace }} -P ${{ parameters.project }} --target-arch aarch64 \ No newline at end of file From 359669f37b3f9c25033662cd84ccdc639ebc1111 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 18 May 2020 15:14:34 -0700 Subject: [PATCH 093/111] eliminate OS param from buildBranch.sh --- scripts/linux/buildBranch.sh | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/scripts/linux/buildBranch.sh b/scripts/linux/buildBranch.sh index 855bfa06ca1..e1995ea6516 100755 --- a/scripts/linux/buildBranch.sh +++ b/scripts/linux/buildBranch.sh @@ -25,7 +25,6 @@ SRC_CERT_TOOLS_DIR=$ROOT_FOLDER/tools/CACertificates FUNCTIONS_SAMPLE_DIR=$ROOT_FOLDER/edge-modules/functions/samples VERSIONINFO_FILE_PATH=$BUILD_REPOSITORY_LOCALPATH/versionInfo.json CONNECTIVITY_TEST_SCRIPT_DIR=$ROOT_FOLDER/test/connectivity/scripts -DOTNETBUILD_OS= DOTNET_RUNTIME=netcoreapp3.1 usage() @@ -35,8 +34,7 @@ usage() echo "options" echo " -c, --config Product binary configuration: Debug [default] or Release" echo " --no-rocksdb-bin Do not copy the RocksDB binaries into the project's output folders" - echo " --os Sets OS Variable for dotnet build command (Used to build for .NET Core 3.0 - Linux ARM64)" - echo " --dotnet_runtime Set the dotnet_runtime version to build. (Default netcoreapp2.1)" + echo " --dotnet_runtime Set the dotnet_runtime version to build. (Default netcoreapp3.1)" exit 1; } @@ -55,9 +53,6 @@ process_args() CONFIGURATION="$arg" save_next_arg=0 elif [ $save_next_arg -eq 2 ]; then - DOTNETBUILD_OS="$arg" - save_next_arg=0 - elif [ $save_next_arg -eq 3 ]; then DOTNET_RUNTIME="$arg" save_next_arg=0 else @@ -65,8 +60,7 @@ process_args() "-h" | "--help" ) usage;; "-c" | "--config" ) save_next_arg=1;; "--no-rocksdb-bin" ) MSBUILD_OPTIONS="-p:RocksDbAsPackage=false";; - "--os" ) save_next_arg=2;; - "--dotnet_runtime" ) save_next_arg=3;; + "--dotnet_runtime" ) save_next_arg=2;; * ) usage;; esac fi @@ -211,10 +205,6 @@ build_solution() build_command="$DOTNET_ROOT_PATH/dotnet build -c $CONFIGURATION -o \"$BUILD_BINARIESDIRECTORY\"" - if [ -n "$DOTNETBUILD_OS" ]; then - build_command="$build_command -p:OS=$DOTNETBUILD_OS" - fi - if [ -n "$DOTNET_RUNTIME" ]; then build_command="$build_command -p:DotNet_Runtime=$DOTNET_RUNTIME" fi From 411a9dbf21bea0bc9ca5c7e5e17f848a02e10894 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 18 May 2020 16:24:06 -0700 Subject: [PATCH 094/111] add comment describing aspnetcore middleware handling --- .../Hosting.cs | 72 ++++++++++++------- 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index c84e8079bf7..27591f85384 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -35,6 +35,50 @@ public static Hosting Initialize( bool clientCertAuthEnabled, SslProtocols sslProtocols) { + /* Define the HttpsConnectionAdapterOptions which integrates with aspnetcore https middleware to help us manage the client cert chain. + We need to store the client cert chain in the connection context, so that we can perform custom CA validation later to authenticate with the service identity. + We are using logic here that depends on an undocumented api, however eliminating this dependency would require a large refactor. + Context in this issue: https://github.com/dotnet/aspnetcore/issues/21606 */ + HttpsConnectionAdapterOptions connectionAdapterOptions = new HttpsConnectionAdapterOptions() + { + ServerCertificate = serverCertificate, + OnAuthenticate = (context, options) => + { + if (clientCertAuthEnabled) + { + /* Certificate authorization can be enabled in edgeHub, however direct methods will hit this logic and not need certificates. + This implies that the ClientCertificateRequired should be false. + However, the naming of this field is not semantically correct. + We looked at how aspnetcore used this field, and found that it is true when CertificateMode.AllowCertificate is set (which does not require certificates). + Therefore we can set this field to true and it will still work with direct methods. + */ + options.ClientCertificateRequired = true; + options.RemoteCertificateValidationCallback = (_, clientCert, chain, policyErrors) => + { + if (clientCert == null || policyErrors != SslPolicyErrors.None) + { + return false; + } + + Option chainOption = chain == null ? Option.None() : Option.Some(chain); + TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chainOption); + context.Features.Set(tlsConnectionFeatureExtended); + return true; + }; + } + }, + /* ClientCertificateMode.AllowCertificate is the intuitive choice here, however is not what we need + If we use this then aspnetcore will register it's own certificate validation callback when creating the SslStream. + This aspnetcore-created certificate validation callback in turn calls the HttpsConnectionAdapterOptions.ClientCertificateValidation, which we can configure In HttpsConnectionAdapterOptions. + This is not the desired solution for us because HttpsConnectionAdapterOptions.ClientCertificateValidation does not provide access to the client cert chain when the connection is in scope. + + Thus, we need to pass NoCertificate to block aspnet from creating the SslStream with the certificate validation callback. + This will let us use HttpsConnectionAdapterOptions.OnAuthenticate in order to register certificate validation with the connection in scope. + We can handle the cert / no-cert case inside of OnAuthenticate */ + ClientCertificateMode = ClientCertificateMode.NoCertificate, + SslProtocols = sslProtocols + }; + int port = configuration.GetValue("httpSettings:port", 443); IWebHostBuilder webHostBuilder = new WebHostBuilder() .UseKestrel( @@ -45,32 +89,7 @@ public static Hosting Initialize( port, listenOptions => { - listenOptions.UseHttps( - new HttpsConnectionAdapterOptions() - { - ServerCertificate = serverCertificate, - OnAuthenticate = (context, options) => - { - if (clientCertAuthEnabled) - { - options.ClientCertificateRequired = true; - options.RemoteCertificateValidationCallback = (_, clientCert, chain, policyErrors) => - { - if (clientCert == null || policyErrors != SslPolicyErrors.None) - { - return false; - } - - Option chainOption = chain == null ? Option.None() : Option.Some(chain); - TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chainOption); - context.Features.Set(tlsConnectionFeatureExtended); - return true; - }; - } - }, - ClientCertificateMode = ClientCertificateMode.NoCertificate, // we can override this in OnAuthenticate if using certs - SslProtocols = sslProtocols - }); + listenOptions.UseHttps(connectionAdapterOptions); }); }) .UseSockets() @@ -87,6 +106,7 @@ public static Hosting Initialize( return new Hosting(webHost, container); } + // This function wraps the client cert chain in special object for later storage in the connection context. public static TlsConnectionFeatureExtended GetConnectionFeatureExtended(Option chain) { IList clientCertChain = new List(); From 13fe88d8dbb37e6a146040ec8b102ca5195678ae Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 18 May 2020 18:54:00 -0700 Subject: [PATCH 095/111] clean up edgehub debug logging --- .../Microsoft.Azure.Devices.Edge.Hub.Core/Authenticator.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Authenticator.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Authenticator.cs index da855aec5dd..daa14f70eb1 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Authenticator.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/Authenticator.cs @@ -78,14 +78,14 @@ public static void InvalidDeviceId(IModuleIdentity moduleIdentity, string edgeDe public static void AuthResult(IClientCredentials clientCredentials, bool reAuthenticating, bool result) { - string operation = reAuthenticating ? "re-authenticate" : "authenticate"; + string operation = reAuthenticating ? "re-authentication" : "authentication"; if (result) { - Log.LogDebug((int)EventIds.AuthResult, Invariant($"Client {clientCredentials.Identity.Id} {operation}d successfully")); + Log.LogDebug((int)EventIds.AuthResult, Invariant($"Client {clientCredentials.Identity.Id} {operation} successful")); } else { - Log.LogDebug((int)EventIds.AuthResult, Invariant($"Unable to {operation} client {clientCredentials.Identity.Id}")); + Log.LogDebug((int)EventIds.AuthResult, Invariant($"{clientCredentials.Identity.Id} {operation} failure")); } } } From 6ff4f6bcad53db62e78f37f9931ce16a240d55af Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 18 May 2020 19:18:58 -0700 Subject: [PATCH 096/111] use netstandard for azure web jobs --- .../Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj index b4ca28346f5..cca0a4d6a4d 100644 --- a/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj +++ b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj @@ -3,7 +3,7 @@ true - + Microsoft.Azure.WebJobs.Extensions.EdgeHub From 93f9e2ebf170021f38e6712d1955733d665dce4f Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 19 May 2020 12:38:28 -0700 Subject: [PATCH 097/111] switch webjobs back to netcoreapp --- .../Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj index cca0a4d6a4d..b4ca28346f5 100644 --- a/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj +++ b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj @@ -3,7 +3,7 @@ true - + Microsoft.Azure.WebJobs.Extensions.EdgeHub From 8d5083b9478c8292160df9572f4c4698bd4b935b Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 19 May 2020 12:59:41 -0700 Subject: [PATCH 098/111] update sdk version for downstream device sample --- samples/dotnet/EdgeDownstreamDevice/EdgeDownstreamDevice.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/dotnet/EdgeDownstreamDevice/EdgeDownstreamDevice.csproj b/samples/dotnet/EdgeDownstreamDevice/EdgeDownstreamDevice.csproj index 6350a39cc9b..11129d0549a 100644 --- a/samples/dotnet/EdgeDownstreamDevice/EdgeDownstreamDevice.csproj +++ b/samples/dotnet/EdgeDownstreamDevice/EdgeDownstreamDevice.csproj @@ -9,6 +9,6 @@ - + From c8f62454097e0c4dc98575f8f06a1f0525a3c307 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 19 May 2020 14:44:49 -0700 Subject: [PATCH 099/111] don't check for null cert --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 27591f85384..41401632ae9 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -55,7 +55,7 @@ Therefore we can set this field to true and it will still work with direct metho options.ClientCertificateRequired = true; options.RemoteCertificateValidationCallback = (_, clientCert, chain, policyErrors) => { - if (clientCert == null || policyErrors != SslPolicyErrors.None) + if (policyErrors != SslPolicyErrors.None) { return false; } From 43aaaae7ddde6011b73879d2f68a0d9cf4d282f2 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 19 May 2020 15:57:05 -0700 Subject: [PATCH 100/111] use netstandard 2.0 --- .../Microsoft.Azure.Devices.Edge.Agent.Kubernetes.csproj | 2 +- netstandardVersion.props | 2 +- .../ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Kubernetes/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.csproj b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Kubernetes/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.csproj index 6b28afcfeca..23eac5eb8a0 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Kubernetes/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.csproj +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Kubernetes/Microsoft.Azure.Devices.Edge.Agent.Kubernetes.csproj @@ -1,6 +1,6 @@  - + True diff --git a/netstandardVersion.props b/netstandardVersion.props index a7e24746702..3b7a0b311d4 100644 --- a/netstandardVersion.props +++ b/netstandardVersion.props @@ -1,5 +1,5 @@ - netstandard2.1 + netstandard2.0 diff --git a/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj b/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj index 3c0aab54d76..126f7201f0b 100644 --- a/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj +++ b/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj @@ -1,6 +1,6 @@  - + From 026dce8234ffa3ec404d01d246fdb4579efb52f2 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 19 May 2020 16:56:39 -0700 Subject: [PATCH 101/111] remove erroneous sslpolicyerror check --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 41401632ae9..9e80b9d18d9 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -55,11 +55,6 @@ Therefore we can set this field to true and it will still work with direct metho options.ClientCertificateRequired = true; options.RemoteCertificateValidationCallback = (_, clientCert, chain, policyErrors) => { - if (policyErrors != SslPolicyErrors.None) - { - return false; - } - Option chainOption = chain == null ? Option.None() : Option.Some(chain); TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chainOption); context.Features.Set(tlsConnectionFeatureExtended); From 5769c5663e1705c03263723623ede0c91bb2330a Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 19 May 2020 17:37:12 -0700 Subject: [PATCH 102/111] option maybe --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 9e80b9d18d9..b8f446d8892 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -55,7 +55,7 @@ Therefore we can set this field to true and it will still work with direct metho options.ClientCertificateRequired = true; options.RemoteCertificateValidationCallback = (_, clientCert, chain, policyErrors) => { - Option chainOption = chain == null ? Option.None() : Option.Some(chain); + Option chainOption = Option.Maybe(chain); TlsConnectionFeatureExtended tlsConnectionFeatureExtended = GetConnectionFeatureExtended(chainOption); context.Features.Set(tlsConnectionFeatureExtended); return true; From 061c7c7374afc695c652717c209b1f8627264d29 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 19 May 2020 17:40:38 -0700 Subject: [PATCH 103/111] revert changes to HttpWorkloadClient --- .../generatedCode/HttpWorkloadClient.cs | 1432 ++++++++++------- .../generatedCode/HttpWorkloadClient.cs | 1431 +++++++++------- 2 files changed, 1767 insertions(+), 1096 deletions(-) diff --git a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2018_06_28/generatedCode/HttpWorkloadClient.cs b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2018_06_28/generatedCode/HttpWorkloadClient.cs index 1ebad095627..44cae8645a5 100644 --- a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2018_06_28/generatedCode/HttpWorkloadClient.cs +++ b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2018_06_28/generatedCode/HttpWorkloadClient.cs @@ -1,125 +1,46 @@ +// Copyright (c) Microsoft. All rights reserved. //---------------------- // -// Generated using the NSwag toolchain v13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v11.17.6.0 (NJsonSchema v9.10.46.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- - -#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended." -#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword." -#pragma warning disable 472 // Disable "CS0472 The result of the expression is always 'false' since a value of type 'Int32' is never equal to 'null' of type 'Int32?' -#pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ... -#pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..." +// Note: Code manually changed to replace System.Uri.EscapeDataString with System.Net.WebUtility.UrlEncode namespace Microsoft.Azure.Devices.Edge.Util.Edged.Version_2018_06_28.GeneratedCode { - using System = global::System; - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0))")] - public partial class HttpWorkloadClient +#pragma warning disable // Disable all warnings + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.17.6.0 (NJsonSchema v9.10.46.0 (Newtonsoft.Json v9.0.0.0))")] + public partial class HttpWorkloadClient { private string _baseUrl = "http://"; private System.Net.Http.HttpClient _httpClient; private System.Lazy _settings; - + public HttpWorkloadClient(System.Net.Http.HttpClient httpClient) { - _httpClient = httpClient; - _settings = new System.Lazy(CreateSerializerSettings); - } - - private Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings() - { - var settings = new Newtonsoft.Json.JsonSerializerSettings(); - UpdateJsonSerializerSettings(settings); - return settings; + _httpClient = httpClient; + _settings = new System.Lazy(() => + { + var settings = new Newtonsoft.Json.JsonSerializerSettings(); + UpdateJsonSerializerSettings(settings); + return settings; + }); } - - public string BaseUrl + + public string BaseUrl { get { return _baseUrl; } set { _baseUrl = value; } } - + protected Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get { return _settings.Value; } } - + partial void UpdateJsonSerializerSettings(Newtonsoft.Json.JsonSerializerSettings settings); partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, string url); partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder); partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response); - - /// List modules. - /// The version of the API. - /// Ok - /// A server side error occurred. - public System.Threading.Tasks.Task ListModulesAsync(string api_version) - { - return ListModulesAsync(api_version, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// List modules. - /// The version of the API. - /// Ok - /// A server side error occurred. - public async System.Threading.Tasks.Task ListModulesAsync(string api_version, System.Threading.CancellationToken cancellationToken) - { - if (api_version == null) - throw new System.ArgumentNullException("api_version"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules?"); - urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); - urlBuilder_.Length--; - - var client_ = _httpClient; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - - PrepareRequest(client_, request_, urlBuilder_); - var url_ = urlBuilder_.ToString(); - request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); - PrepareRequest(client_, request_, url_); - - var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); - try - { - var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value); - if (response_.Content != null && response_.Content.Headers != null) - { - foreach (var item_ in response_.Content.Headers) - headers_[item_.Key] = item_.Value; - } - - ProcessResponse(client_, response_); - - var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") - { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - return objectResponse_.Object; - } - else - { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - } - finally - { - if (response_ != null) - response_.Dispose(); - } - } - } - finally - { - } - } - + /// The version of the API. /// The name of the module on whose behalf the payload will be signed. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. @@ -130,32 +51,32 @@ public System.Threading.Tasks.Task SignAsync(string api_version, s { return SignAsync(api_version, name, genid, payload, System.Threading.CancellationToken.None); } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// The version of the API. /// The name of the module on whose behalf the payload will be signed. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// The data to be signed. /// Ok /// A server side error occurred. + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task SignAsync(string api_version, string name, string genid, SignRequest payload, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - + if (genid == null) throw new System.ArgumentNullException("genid"); - + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/sign?"); - urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{genid}", System.Uri.EscapeDataString(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { @@ -165,13 +86,13 @@ public async System.Threading.Tasks.Task SignAsync(string api_vers content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - + request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -181,26 +102,55 @@ public async System.Threading.Tasks.Task SignAsync(string api_vers foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") + if (status_ == "200") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - return objectResponse_.Object; + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(SignResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + return result_; + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } } else - if (status_ == "404") + if (status_ == "404") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); } else { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); } + + return default(SignResponse); } finally { @@ -213,7 +163,7 @@ public async System.Threading.Tasks.Task SignAsync(string api_vers { } } - + /// The version of the API. /// The name of the module on whose behalf the plaintext will be encrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. @@ -224,32 +174,32 @@ public System.Threading.Tasks.Task EncryptAsync(string api_vers { return EncryptAsync(api_version, name, genid, payload, System.Threading.CancellationToken.None); } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// The version of the API. /// The name of the module on whose behalf the plaintext will be encrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// The data to be encrypted. /// OK /// A server side error occurred. + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task EncryptAsync(string api_version, string name, string genid, EncryptRequest payload, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - + if (genid == null) throw new System.ArgumentNullException("genid"); - + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/encrypt?"); - urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{genid}", System.Uri.EscapeDataString(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { @@ -259,13 +209,13 @@ public async System.Threading.Tasks.Task EncryptAsync(string ap content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - + request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -275,26 +225,55 @@ public async System.Threading.Tasks.Task EncryptAsync(string ap foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") + if (status_ == "200") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - return objectResponse_.Object; + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(EncryptResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + return result_; + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } } else - if (status_ == "404") + if (status_ == "404") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); } else { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); } + + return default(EncryptResponse); } finally { @@ -307,7 +286,7 @@ public async System.Threading.Tasks.Task EncryptAsync(string ap { } } - + /// The version of the API. /// The name of the module on whose behalf the ciphertext will be decrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. @@ -318,32 +297,32 @@ public System.Threading.Tasks.Task DecryptAsync(string api_vers { return DecryptAsync(api_version, name, genid, payload, System.Threading.CancellationToken.None); } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// The version of the API. /// The name of the module on whose behalf the ciphertext will be decrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// The data to be decrypted. /// OK /// A server side error occurred. + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task DecryptAsync(string api_version, string name, string genid, DecryptRequest payload, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - + if (genid == null) throw new System.ArgumentNullException("genid"); - + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/decrypt?"); - urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{genid}", System.Uri.EscapeDataString(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { @@ -353,13 +332,13 @@ public async System.Threading.Tasks.Task DecryptAsync(string ap content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - + request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -369,26 +348,55 @@ public async System.Threading.Tasks.Task DecryptAsync(string ap foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") + if (status_ == "200") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - return objectResponse_.Object; + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(DecryptResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + return result_; + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } } else - if (status_ == "404") + if (status_ == "404") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); } else { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); } + + return default(DecryptResponse); } finally { @@ -401,53 +409,55 @@ public async System.Threading.Tasks.Task DecryptAsync(string ap { } } - + /// The version of the API. - /// The name of the module needed to obtain the certificate. (urlencoded) - /// Parameters for certificate creation. + /// The name of the module to get certificate. (urlencoded) + /// The generation identifier for the module as generated by IoT Hub. /// Ok /// A server side error occurred. - public System.Threading.Tasks.Task CreateIdentityCertificateAsync(string api_version, string name, IdentityCertificateRequest request) + public System.Threading.Tasks.Task CreateIdentityCertificateAsync(string api_version, string name, string genid) { - return CreateIdentityCertificateAsync(api_version, name, request, System.Threading.CancellationToken.None); + return CreateIdentityCertificateAsync(api_version, name, genid, System.Threading.CancellationToken.None); } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// The version of the API. - /// The name of the module needed to obtain the certificate. (urlencoded) - /// Parameters for certificate creation. + /// The name of the module to get certificate. (urlencoded) + /// The generation identifier for the module as generated by IoT Hub. /// Ok /// A server side error occurred. - public async System.Threading.Tasks.Task CreateIdentityCertificateAsync(string api_version, string name, IdentityCertificateRequest request, System.Threading.CancellationToken cancellationToken) + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + public async System.Threading.Tasks.Task CreateIdentityCertificateAsync(string api_version, string name, string genid, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - + + if (genid == null) + throw new System.ArgumentNullException("genid"); + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/certificate/identity?"); - urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/certificate/identity?"); + urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { using (var request_ = new System.Net.Http.HttpRequestMessage()) { - var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(request, _settings.Value)); - content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); - request_.Content = content_; + request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json"); request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - + request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -457,26 +467,55 @@ public async System.Threading.Tasks.Task CreateIdentityCert foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "201") + if (status_ == "200") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - return objectResponse_.Object; + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(CertificateResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + return result_; + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } } else - if (status_ == "404") + if (status_ == "404") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); } else { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); } + + return default(CertificateResponse); } finally { @@ -489,7 +528,7 @@ public async System.Threading.Tasks.Task CreateIdentityCert { } } - + /// The version of the API. /// The name of the module to get certificate. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. @@ -500,32 +539,32 @@ public System.Threading.Tasks.Task CreateServerCertificateA { return CreateServerCertificateAsync(api_version, name, genid, request, System.Threading.CancellationToken.None); } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// The version of the API. /// The name of the module to get certificate. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// Parameters for certificate creation. /// Ok /// A server side error occurred. + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task CreateServerCertificateAsync(string api_version, string name, string genid, ServerCertificateRequest request, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - + if (genid == null) throw new System.ArgumentNullException("genid"); - + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/certificate/server?"); - urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{genid}", System.Uri.EscapeDataString(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { @@ -535,13 +574,13 @@ public async System.Threading.Tasks.Task CreateServerCertif content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - + request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -551,26 +590,55 @@ public async System.Threading.Tasks.Task CreateServerCertif foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "201") + if (status_ == "201") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - return objectResponse_.Object; + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(CertificateResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + return result_; + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } } else - if (status_ == "404") + if (status_ == "404") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); } else { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); } + + return default(CertificateResponse); } finally { @@ -583,7 +651,7 @@ public async System.Threading.Tasks.Task CreateServerCertif { } } - + /// The version of the API. /// Ok /// A server side error occurred. @@ -591,34 +659,34 @@ public System.Threading.Tasks.Task TrustBundleAsync(string { return TrustBundleAsync(api_version, System.Threading.CancellationToken.None); } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// The version of the API. /// Ok /// A server side error occurred. + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task TrustBundleAsync(string api_version, System.Threading.CancellationToken cancellationToken) { if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/trust-bundle?"); - urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { using (var request_ = new System.Net.Http.HttpRequestMessage()) { request_.Method = new System.Net.Http.HttpMethod("GET"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - + request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -628,20 +696,40 @@ public async System.Threading.Tasks.Task TrustBundleAsync(s foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") + if (status_ == "200") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - return objectResponse_.Object; + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(TrustBundleResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + return result_; + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } } else { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); } + + return default(TrustBundleResponse); } finally { @@ -654,64 +742,7 @@ public async System.Threading.Tasks.Task TrustBundleAsync(s { } } - - protected struct ObjectResponseResult - { - public ObjectResponseResult(T responseObject, string responseText) - { - this.Object = responseObject; - this.Text = responseText; - } - - public T Object { get; } - - public string Text { get; } - } - - public bool ReadResponseAsString { get; set; } - - protected virtual async System.Threading.Tasks.Task> ReadObjectResponseAsync(System.Net.Http.HttpResponseMessage response, System.Collections.Generic.IReadOnlyDictionary> headers) - { - if (response == null || response.Content == null) - { - return new ObjectResponseResult(default(T), string.Empty); - } - - if (ReadResponseAsString) - { - var responseText = await response.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - var typedBody = Newtonsoft.Json.JsonConvert.DeserializeObject(responseText, JsonSerializerSettings); - return new ObjectResponseResult(typedBody, responseText); - } - catch (Newtonsoft.Json.JsonException exception) - { - var message = "Could not deserialize the response body string as " + typeof(T).FullName + "."; - throw new IoTEdgedException(message, (int)response.StatusCode, responseText, headers, exception); - } - } - else - { - try - { - using (var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false)) - using (var streamReader = new System.IO.StreamReader(responseStream)) - using (var jsonTextReader = new Newtonsoft.Json.JsonTextReader(streamReader)) - { - var serializer = Newtonsoft.Json.JsonSerializer.Create(JsonSerializerSettings); - var typedBody = serializer.Deserialize(jsonTextReader); - return new ObjectResponseResult(typedBody, string.Empty); - } - } - catch (Newtonsoft.Json.JsonException exception) - { - var message = "Could not deserialize the response body stream as " + typeof(T).FullName + "."; - throw new IoTEdgedException(message, (int)response.StatusCode, string.Empty, headers, exception); - } - } - } - + private string ConvertToString(object value, System.Globalization.CultureInfo cultureInfo) { if (value is System.Enum) @@ -722,348 +753,659 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu var field = System.Reflection.IntrospectionExtensions.GetTypeInfo(value.GetType()).GetDeclaredField(name); if (field != null) { - var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute)) + var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute)) as System.Runtime.Serialization.EnumMemberAttribute; if (attribute != null) { - return attribute.Value != null ? attribute.Value : name; + return attribute.Value; } } } } - else if (value is bool) { - return System.Convert.ToString(value, cultureInfo).ToLowerInvariant(); - } else if (value is byte[]) { - return System.Convert.ToBase64String((byte[]) value); + return System.Convert.ToBase64String((byte[])value); } - else if (value != null && value.GetType().IsArray) + else if (value.GetType().IsArray) { - var array = System.Linq.Enumerable.OfType((System.Array) value); + var array = System.Linq.Enumerable.OfType((System.Array)value); return string.Join(",", System.Linq.Enumerable.Select(array, o => ConvertToString(o, cultureInfo))); } - + return System.Convert.ToString(value, cultureInfo); } } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class ModuleList - { - [Newtonsoft.Json.JsonProperty("modules", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.Collections.Generic.ICollection Modules { get; set; } = new System.Collections.ObjectModel.Collection(); - - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class ModuleDetails - { - /// System generated unique identitier. - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Id { get; set; } - - /// The name of the module. - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Name { get; set; } - - /// The type of a module. - [Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Type { get; set; } - - [Newtonsoft.Json.JsonProperty("config", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public Config Config { get; set; } = new Config(); - - [Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public Status Status { get; set; } = new Status(); - - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class Config - { - [Newtonsoft.Json.JsonProperty("settings", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public object Settings { get; set; } = new object(); - - [Newtonsoft.Json.JsonProperty("env", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.Collections.Generic.ICollection Env { get; set; } - - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class Status - { - [Newtonsoft.Json.JsonProperty("startTime", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.DateTimeOffset? StartTime { get; set; } - - [Newtonsoft.Json.JsonProperty("exitStatus", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public ExitStatus ExitStatus { get; set; } - - [Newtonsoft.Json.JsonProperty("runtimeStatus", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public RuntimeStatus RuntimeStatus { get; set; } = new RuntimeStatus(); - - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class EnvVar - { - [Newtonsoft.Json.JsonProperty("key", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Key { get; set; } - - [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Value { get; set; } - - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class ExitStatus - { - [Newtonsoft.Json.JsonProperty("exitTime", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public System.DateTimeOffset ExitTime { get; set; } - - [Newtonsoft.Json.JsonProperty("statusCode", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string StatusCode { get; set; } - - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class RuntimeStatus - { - [Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Status { get; set; } - - [Newtonsoft.Json.JsonProperty("description", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Description { get; set; } - - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class SignRequest + + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class SignRequest : System.ComponentModel.INotifyPropertyChanged { + private string _keyId; + private SignRequestAlgo _algo; + private byte[] _data; + /// Name of key to perform sign operation. [Newtonsoft.Json.JsonProperty("keyId", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string KeyId { get; set; } - + public string KeyId + { + get { return _keyId; } + set + { + if (_keyId != value) + { + _keyId = value; + RaisePropertyChanged(); + } + } + } + /// Sign algorithm to be used. [Newtonsoft.Json.JsonProperty("algo", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public SignRequestAlgo Algo { get; set; } - + public SignRequestAlgo Algo + { + get { return _algo; } + set + { + if (_algo != value) + { + _algo = value; + RaisePropertyChanged(); + } + } + } + /// Data to be signed. [Newtonsoft.Json.JsonProperty("data", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public byte[] Data { get; set; } - - + public byte[] Data + { + get { return _data; } + set + { + if (_data != value) + { + _data = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static SignRequest FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class SignResponse + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class SignResponse : System.ComponentModel.INotifyPropertyChanged { + private byte[] _digest; + /// Signature of the data. [Newtonsoft.Json.JsonProperty("digest", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public byte[] Digest { get; set; } - - + public byte[] Digest + { + get { return _digest; } + set + { + if (_digest != value) + { + _digest = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static SignResponse FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class EncryptRequest + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class EncryptRequest : System.ComponentModel.INotifyPropertyChanged { + private byte[] _plaintext; + private byte[] _initializationVector; + /// The data to be encrypted. [Newtonsoft.Json.JsonProperty("plaintext", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public byte[] Plaintext { get; set; } - + public byte[] Plaintext + { + get { return _plaintext; } + set + { + if (_plaintext != value) + { + _plaintext = value; + RaisePropertyChanged(); + } + } + } + /// An initialization vector used to encrypt the data. [Newtonsoft.Json.JsonProperty("initializationVector", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public byte[] InitializationVector { get; set; } - - + public byte[] InitializationVector + { + get { return _initializationVector; } + set + { + if (_initializationVector != value) + { + _initializationVector = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static EncryptRequest FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class EncryptResponse + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class EncryptResponse : System.ComponentModel.INotifyPropertyChanged { + private byte[] _ciphertext; + /// The encrypted form of the data encoded in base 64. [Newtonsoft.Json.JsonProperty("ciphertext", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public byte[] Ciphertext { get; set; } - - + public byte[] Ciphertext + { + get { return _ciphertext; } + set + { + if (_ciphertext != value) + { + _ciphertext = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static EncryptResponse FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class DecryptRequest + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class DecryptRequest : System.ComponentModel.INotifyPropertyChanged { + private byte[] _ciphertext; + private byte[] _initializationVector; + /// The data to be decrypted. [Newtonsoft.Json.JsonProperty("ciphertext", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public byte[] Ciphertext { get; set; } - + public byte[] Ciphertext + { + get { return _ciphertext; } + set + { + if (_ciphertext != value) + { + _ciphertext = value; + RaisePropertyChanged(); + } + } + } + /// An initialization vector used to decrypt the data. [Newtonsoft.Json.JsonProperty("initializationVector", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public byte[] InitializationVector { get; set; } - - + public byte[] InitializationVector + { + get { return _initializationVector; } + set + { + if (_initializationVector != value) + { + _initializationVector = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static DecryptRequest FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class DecryptResponse + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class DecryptResponse : System.ComponentModel.INotifyPropertyChanged { + private byte[] _plaintext; + /// The decrypted form of the data encoded in base 64. [Newtonsoft.Json.JsonProperty("plaintext", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public byte[] Plaintext { get; set; } - - + public byte[] Plaintext + { + get { return _plaintext; } + set + { + if (_plaintext != value) + { + _plaintext = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static DecryptResponse FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class ServerCertificateRequest + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class ServerCertificateRequest : System.ComponentModel.INotifyPropertyChanged { + private string _commonName; + private System.DateTime _expiration; + /// Subject common name [Newtonsoft.Json.JsonProperty("commonName", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string CommonName { get; set; } - + public string CommonName + { + get { return _commonName; } + set + { + if (_commonName != value) + { + _commonName = value; + RaisePropertyChanged(); + } + } + } + /// Certificate expiration date-time (ISO 8601) [Newtonsoft.Json.JsonProperty("expiration", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public System.DateTimeOffset Expiration { get; set; } - - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class IdentityCertificateRequest - { - /// Certificate expiration date-time (ISO 8601) - [Newtonsoft.Json.JsonProperty("expiration", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.DateTimeOffset? Expiration { get; set; } - - + public System.DateTime Expiration + { + get { return _expiration; } + set + { + if (_expiration != value) + { + _expiration = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static ServerCertificateRequest FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class CertificateResponse + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class CertificateResponse : System.ComponentModel.INotifyPropertyChanged { + private PrivateKey _privateKey = new PrivateKey(); + private string _certificate; + private System.DateTime _expiration; + [Newtonsoft.Json.JsonProperty("privateKey", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public PrivateKey PrivateKey { get; set; } = new PrivateKey(); - + public PrivateKey PrivateKey + { + get { return _privateKey; } + set + { + if (_privateKey != value) + { + _privateKey = value; + RaisePropertyChanged(); + } + } + } + /// Base64 encoded PEM formatted byte array containing the certificate and its chain. [Newtonsoft.Json.JsonProperty("certificate", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Certificate { get; set; } - + public string Certificate + { + get { return _certificate; } + set + { + if (_certificate != value) + { + _certificate = value; + RaisePropertyChanged(); + } + } + } + /// Certificate expiration date-time (ISO 8601) [Newtonsoft.Json.JsonProperty("expiration", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public System.DateTimeOffset Expiration { get; set; } - - + public System.DateTime Expiration + { + get { return _expiration; } + set + { + if (_expiration != value) + { + _expiration = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static CertificateResponse FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class TrustBundleResponse + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class TrustBundleResponse : System.ComponentModel.INotifyPropertyChanged { + private string _certificate; + /// Base64 encoded PEM formatted byte array containing the trusted certificates. [Newtonsoft.Json.JsonProperty("certificate", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Certificate { get; set; } - - + public string Certificate + { + get { return _certificate; } + set + { + if (_certificate != value) + { + _certificate = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static TrustBundleResponse FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class PrivateKey + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class PrivateKey : System.ComponentModel.INotifyPropertyChanged { + private PrivateKeyType _type; + private string _ref; + private string _bytes; + /// Indicates format of the key (present in PEM formatted bytes or a reference) [Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public PrivateKeyType Type { get; set; } - + public PrivateKeyType Type + { + get { return _type; } + set + { + if (_type != value) + { + _type = value; + RaisePropertyChanged(); + } + } + } + /// Reference to private key. [Newtonsoft.Json.JsonProperty("ref", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Ref { get; set; } - + public string Ref + { + get { return _ref; } + set + { + if (_ref != value) + { + _ref = value; + RaisePropertyChanged(); + } + } + } + /// Base64 encoded PEM formatted byte array [Newtonsoft.Json.JsonProperty("bytes", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Bytes { get; set; } - - + public string Bytes + { + get { return _bytes; } + set + { + if (_bytes != value) + { + _bytes = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static PrivateKey FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class ErrorResponse + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class ErrorResponse : System.ComponentModel.INotifyPropertyChanged { + private string _message; + [Newtonsoft.Json.JsonProperty("message", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Message { get; set; } - - + public string Message + { + get { return _message; } + set + { + if (_message != value) + { + _message = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static ErrorResponse FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] public enum SignRequestAlgo { - [System.Runtime.Serialization.EnumMember(Value = @"HMACSHA256")] + [System.Runtime.Serialization.EnumMember(Value = "HMACSHA256")] HMACSHA256 = 0, - + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] public enum PrivateKeyType { - [System.Runtime.Serialization.EnumMember(Value = @"ref")] + [System.Runtime.Serialization.EnumMember(Value = "ref")] Ref = 0, - - [System.Runtime.Serialization.EnumMember(Value = @"key")] + + [System.Runtime.Serialization.EnumMember(Value = "key")] Key = 1, - + } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.17.6.0 (NJsonSchema v9.10.46.0 (Newtonsoft.Json v9.0.0.0))")] public partial class IoTEdgedException : System.Exception { public int StatusCode { get; private set; } public string Response { get; private set; } - public System.Collections.Generic.IReadOnlyDictionary> Headers { get; private set; } + public System.Collections.Generic.Dictionary> Headers { get; private set; } - public IoTEdgedException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, System.Exception innerException) - : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + response.Substring(0, response.Length >= 512 ? 512 : response.Length), innerException) + public IoTEdgedException(string message, int statusCode, string response, System.Collections.Generic.Dictionary> headers, System.Exception innerException) + : base(message, innerException) { StatusCode = statusCode; - Response = response; + Response = response; Headers = headers; } @@ -1073,12 +1415,12 @@ public override string ToString() } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.17.6.0 (NJsonSchema v9.10.46.0 (Newtonsoft.Json v9.0.0.0))")] public partial class IoTEdgedException : IoTEdgedException { public TResult Result { get; private set; } - public IoTEdgedException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, TResult result, System.Exception innerException) + public IoTEdgedException(string message, int statusCode, string response, System.Collections.Generic.Dictionary> headers, TResult result, System.Exception innerException) : base(message, statusCode, response, headers, innerException) { Result = result; @@ -1086,9 +1428,3 @@ public IoTEdgedException(string message, int statusCode, string response, System } } - -#pragma warning restore 1591 -#pragma warning restore 1573 -#pragma warning restore 472 -#pragma warning restore 114 -#pragma warning restore 108 diff --git a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2019_01_30/generatedCode/HttpWorkloadClient.cs b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2019_01_30/generatedCode/HttpWorkloadClient.cs index 1e7438c7568..c22b0ef0a36 100644 --- a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2019_01_30/generatedCode/HttpWorkloadClient.cs +++ b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2019_01_30/generatedCode/HttpWorkloadClient.cs @@ -1,125 +1,45 @@ //---------------------- // -// Generated using the NSwag toolchain v13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v11.17.6.0 (NJsonSchema v9.10.46.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- - -#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended." -#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword." -#pragma warning disable 472 // Disable "CS0472 The result of the expression is always 'false' since a value of type 'Int32' is never equal to 'null' of type 'Int32?' -#pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ... -#pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..." +// Note: Code manually changed to replace System.Uri.EscapeDataString with System.Net.WebUtility.UrlEncode namespace Microsoft.Azure.Devices.Edge.Util.Edged.Version_2019_01_30.GeneratedCode { - using System = global::System; - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0))")] - public partial class HttpWorkloadClient +#pragma warning disable // Disable all warnings + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.17.6.0 (NJsonSchema v9.10.46.0 (Newtonsoft.Json v9.0.0.0))")] + public partial class HttpWorkloadClient { private string _baseUrl = "http://"; private System.Net.Http.HttpClient _httpClient; private System.Lazy _settings; - + public HttpWorkloadClient(System.Net.Http.HttpClient httpClient) { - _httpClient = httpClient; - _settings = new System.Lazy(CreateSerializerSettings); - } - - private Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings() - { - var settings = new Newtonsoft.Json.JsonSerializerSettings(); - UpdateJsonSerializerSettings(settings); - return settings; + _httpClient = httpClient; + _settings = new System.Lazy(() => + { + var settings = new Newtonsoft.Json.JsonSerializerSettings(); + UpdateJsonSerializerSettings(settings); + return settings; + }); } - - public string BaseUrl + + public string BaseUrl { get { return _baseUrl; } set { _baseUrl = value; } } - + protected Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get { return _settings.Value; } } - + partial void UpdateJsonSerializerSettings(Newtonsoft.Json.JsonSerializerSettings settings); partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, string url); partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder); partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response); - - /// List modules. - /// The version of the API. - /// Ok - /// A server side error occurred. - public System.Threading.Tasks.Task ListModulesAsync(string api_version) - { - return ListModulesAsync(api_version, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// List modules. - /// The version of the API. - /// Ok - /// A server side error occurred. - public async System.Threading.Tasks.Task ListModulesAsync(string api_version, System.Threading.CancellationToken cancellationToken) - { - if (api_version == null) - throw new System.ArgumentNullException("api_version"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules?"); - urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); - urlBuilder_.Length--; - - var client_ = _httpClient; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - - PrepareRequest(client_, request_, urlBuilder_); - var url_ = urlBuilder_.ToString(); - request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); - PrepareRequest(client_, request_, url_); - - var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); - try - { - var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value); - if (response_.Content != null && response_.Content.Headers != null) - { - foreach (var item_ in response_.Content.Headers) - headers_[item_.Key] = item_.Value; - } - - ProcessResponse(client_, response_); - - var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") - { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - return objectResponse_.Object; - } - else - { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - } - finally - { - if (response_ != null) - response_.Dispose(); - } - } - } - finally - { - } - } - + /// The version of the API. /// The name of the module on whose behalf the payload will be signed. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. @@ -130,32 +50,32 @@ public System.Threading.Tasks.Task SignAsync(string api_version, s { return SignAsync(api_version, name, genid, payload, System.Threading.CancellationToken.None); } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// The version of the API. /// The name of the module on whose behalf the payload will be signed. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// The data to be signed. /// Ok /// A server side error occurred. + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task SignAsync(string api_version, string name, string genid, SignRequest payload, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - + if (genid == null) throw new System.ArgumentNullException("genid"); - + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/sign?"); - urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{genid}", System.Uri.EscapeDataString(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { @@ -165,13 +85,13 @@ public async System.Threading.Tasks.Task SignAsync(string api_vers content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - + request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -181,26 +101,55 @@ public async System.Threading.Tasks.Task SignAsync(string api_vers foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") + if (status_ == "200") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - return objectResponse_.Object; + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(SignResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + return result_; + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } } else - if (status_ == "404") + if (status_ == "404") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); } else { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); } + + return default(SignResponse); } finally { @@ -213,7 +162,7 @@ public async System.Threading.Tasks.Task SignAsync(string api_vers { } } - + /// The version of the API. /// The name of the module on whose behalf the plaintext will be encrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. @@ -224,32 +173,32 @@ public System.Threading.Tasks.Task EncryptAsync(string api_vers { return EncryptAsync(api_version, name, genid, payload, System.Threading.CancellationToken.None); } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// The version of the API. /// The name of the module on whose behalf the plaintext will be encrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// The data to be encrypted. /// OK /// A server side error occurred. + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task EncryptAsync(string api_version, string name, string genid, EncryptRequest payload, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - + if (genid == null) throw new System.ArgumentNullException("genid"); - + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/encrypt?"); - urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{genid}", System.Uri.EscapeDataString(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { @@ -259,13 +208,13 @@ public async System.Threading.Tasks.Task EncryptAsync(string ap content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - + request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -275,26 +224,55 @@ public async System.Threading.Tasks.Task EncryptAsync(string ap foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") + if (status_ == "200") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - return objectResponse_.Object; + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(EncryptResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + return result_; + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } } else - if (status_ == "404") + if (status_ == "404") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); } else { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); } + + return default(EncryptResponse); } finally { @@ -307,7 +285,7 @@ public async System.Threading.Tasks.Task EncryptAsync(string ap { } } - + /// The version of the API. /// The name of the module on whose behalf the ciphertext will be decrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. @@ -318,32 +296,32 @@ public System.Threading.Tasks.Task DecryptAsync(string api_vers { return DecryptAsync(api_version, name, genid, payload, System.Threading.CancellationToken.None); } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// The version of the API. /// The name of the module on whose behalf the ciphertext will be decrypted. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// The data to be decrypted. /// OK /// A server side error occurred. + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task DecryptAsync(string api_version, string name, string genid, DecryptRequest payload, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - + if (genid == null) throw new System.ArgumentNullException("genid"); - + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/decrypt?"); - urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{genid}", System.Uri.EscapeDataString(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { @@ -353,13 +331,13 @@ public async System.Threading.Tasks.Task DecryptAsync(string ap content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - + request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -369,26 +347,55 @@ public async System.Threading.Tasks.Task DecryptAsync(string ap foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") + if (status_ == "200") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - return objectResponse_.Object; + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(DecryptResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + return result_; + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } } else - if (status_ == "404") + if (status_ == "404") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); } else { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); } + + return default(DecryptResponse); } finally { @@ -401,53 +408,55 @@ public async System.Threading.Tasks.Task DecryptAsync(string ap { } } - + /// The version of the API. - /// The name of the module needed to obtain the certificate. (urlencoded) - /// Parameters for certificate creation. + /// The name of the module to get certificate. (urlencoded) + /// The generation identifier for the module as generated by IoT Hub. /// Ok /// A server side error occurred. - public System.Threading.Tasks.Task CreateIdentityCertificateAsync(string api_version, string name, IdentityCertificateRequest request) + public System.Threading.Tasks.Task CreateIdentityCertificateAsync(string api_version, string name, string genid) { - return CreateIdentityCertificateAsync(api_version, name, request, System.Threading.CancellationToken.None); + return CreateIdentityCertificateAsync(api_version, name, genid, System.Threading.CancellationToken.None); } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// The version of the API. - /// The name of the module needed to obtain the certificate. (urlencoded) - /// Parameters for certificate creation. + /// The name of the module to get certificate. (urlencoded) + /// The generation identifier for the module as generated by IoT Hub. /// Ok /// A server side error occurred. - public async System.Threading.Tasks.Task CreateIdentityCertificateAsync(string api_version, string name, IdentityCertificateRequest request, System.Threading.CancellationToken cancellationToken) + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + public async System.Threading.Tasks.Task CreateIdentityCertificateAsync(string api_version, string name, string genid, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - + + if (genid == null) + throw new System.ArgumentNullException("genid"); + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/certificate/identity?"); - urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/certificate/identity?"); + urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { using (var request_ = new System.Net.Http.HttpRequestMessage()) { - var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(request, _settings.Value)); - content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); - request_.Content = content_; + request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json"); request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - + request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -457,26 +466,55 @@ public async System.Threading.Tasks.Task CreateIdentityCert foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "201") + if (status_ == "200") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - return objectResponse_.Object; + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(CertificateResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + return result_; + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } } else - if (status_ == "404") + if (status_ == "404") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); } else { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); } + + return default(CertificateResponse); } finally { @@ -489,7 +527,7 @@ public async System.Threading.Tasks.Task CreateIdentityCert { } } - + /// The version of the API. /// The name of the module to get certificate. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. @@ -500,32 +538,32 @@ public System.Threading.Tasks.Task CreateServerCertificateA { return CreateServerCertificateAsync(api_version, name, genid, request, System.Threading.CancellationToken.None); } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// The version of the API. /// The name of the module to get certificate. (urlencoded) /// The generation identifier for the module as generated by IoT Hub. /// Parameters for certificate creation. /// Ok /// A server side error occurred. + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task CreateServerCertificateAsync(string api_version, string name, string genid, ServerCertificateRequest request, System.Threading.CancellationToken cancellationToken) { if (name == null) throw new System.ArgumentNullException("name"); - + if (genid == null) throw new System.ArgumentNullException("genid"); - + if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/modules/{name}/genid/{genid}/certificate/server?"); - urlBuilder_.Replace("{name}", System.Uri.EscapeDataString(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{genid}", System.Uri.EscapeDataString(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Replace("{name}", System.Net.WebUtility.UrlEncode(ConvertToString(name, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{genid}", System.Net.WebUtility.UrlEncode(ConvertToString(genid, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { @@ -535,13 +573,13 @@ public async System.Threading.Tasks.Task CreateServerCertif content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - + request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -551,26 +589,55 @@ public async System.Threading.Tasks.Task CreateServerCertif foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "201") + if (status_ == "201") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - return objectResponse_.Object; + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(CertificateResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + return result_; + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } } else - if (status_ == "404") + if (status_ == "404") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Not Found", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); } else { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); } + + return default(CertificateResponse); } finally { @@ -583,7 +650,7 @@ public async System.Threading.Tasks.Task CreateServerCertif { } } - + /// The version of the API. /// Ok /// A server side error occurred. @@ -591,34 +658,34 @@ public System.Threading.Tasks.Task TrustBundleAsync(string { return TrustBundleAsync(api_version, System.Threading.CancellationToken.None); } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// The version of the API. /// Ok /// A server side error occurred. + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. public async System.Threading.Tasks.Task TrustBundleAsync(string api_version, System.Threading.CancellationToken cancellationToken) { if (api_version == null) throw new System.ArgumentNullException("api_version"); - + var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/trust-bundle?"); - urlBuilder_.Append(System.Uri.EscapeDataString("api-version") + "=").Append(System.Uri.EscapeDataString(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); + urlBuilder_.Append("api-version=").Append(System.Net.WebUtility.UrlEncode(ConvertToString(api_version, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); urlBuilder_.Length--; - + var client_ = _httpClient; try { using (var request_ = new System.Net.Http.HttpRequestMessage()) { request_.Method = new System.Net.Http.HttpMethod("GET"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - + request_.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); - + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { @@ -628,20 +695,40 @@ public async System.Threading.Tasks.Task TrustBundleAsync(s foreach (var item_ in response_.Content.Headers) headers_[item_.Key] = item_.Value; } - + ProcessResponse(client_, response_); - + var status_ = ((int)response_.StatusCode).ToString(); - if (status_ == "200") + if (status_ == "200") { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - return objectResponse_.Object; + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(TrustBundleResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + return result_; + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } } else { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); - throw new IoTEdgedException("Error", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null); + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(ErrorResponse); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new IoTEdgedException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new IoTEdgedException("Error", (int)response_.StatusCode, responseData_, headers_, result_, null); } + + return default(TrustBundleResponse); } finally { @@ -654,64 +741,7 @@ public async System.Threading.Tasks.Task TrustBundleAsync(s { } } - - protected struct ObjectResponseResult - { - public ObjectResponseResult(T responseObject, string responseText) - { - this.Object = responseObject; - this.Text = responseText; - } - - public T Object { get; } - - public string Text { get; } - } - - public bool ReadResponseAsString { get; set; } - - protected virtual async System.Threading.Tasks.Task> ReadObjectResponseAsync(System.Net.Http.HttpResponseMessage response, System.Collections.Generic.IReadOnlyDictionary> headers) - { - if (response == null || response.Content == null) - { - return new ObjectResponseResult(default(T), string.Empty); - } - - if (ReadResponseAsString) - { - var responseText = await response.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - var typedBody = Newtonsoft.Json.JsonConvert.DeserializeObject(responseText, JsonSerializerSettings); - return new ObjectResponseResult(typedBody, responseText); - } - catch (Newtonsoft.Json.JsonException exception) - { - var message = "Could not deserialize the response body string as " + typeof(T).FullName + "."; - throw new IoTEdgedException(message, (int)response.StatusCode, responseText, headers, exception); - } - } - else - { - try - { - using (var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false)) - using (var streamReader = new System.IO.StreamReader(responseStream)) - using (var jsonTextReader = new Newtonsoft.Json.JsonTextReader(streamReader)) - { - var serializer = Newtonsoft.Json.JsonSerializer.Create(JsonSerializerSettings); - var typedBody = serializer.Deserialize(jsonTextReader); - return new ObjectResponseResult(typedBody, string.Empty); - } - } - catch (Newtonsoft.Json.JsonException exception) - { - var message = "Could not deserialize the response body stream as " + typeof(T).FullName + "."; - throw new IoTEdgedException(message, (int)response.StatusCode, string.Empty, headers, exception); - } - } - } - + private string ConvertToString(object value, System.Globalization.CultureInfo cultureInfo) { if (value is System.Enum) @@ -722,348 +752,659 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu var field = System.Reflection.IntrospectionExtensions.GetTypeInfo(value.GetType()).GetDeclaredField(name); if (field != null) { - var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute)) + var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute)) as System.Runtime.Serialization.EnumMemberAttribute; if (attribute != null) { - return attribute.Value != null ? attribute.Value : name; + return attribute.Value; } } } } - else if (value is bool) { - return System.Convert.ToString(value, cultureInfo).ToLowerInvariant(); - } else if (value is byte[]) { - return System.Convert.ToBase64String((byte[]) value); + return System.Convert.ToBase64String((byte[])value); } - else if (value != null && value.GetType().IsArray) + else if (value.GetType().IsArray) { - var array = System.Linq.Enumerable.OfType((System.Array) value); + var array = System.Linq.Enumerable.OfType((System.Array)value); return string.Join(",", System.Linq.Enumerable.Select(array, o => ConvertToString(o, cultureInfo))); } - + return System.Convert.ToString(value, cultureInfo); } } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class ModuleList - { - [Newtonsoft.Json.JsonProperty("modules", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public System.Collections.Generic.ICollection Modules { get; set; } = new System.Collections.ObjectModel.Collection(); - - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class ModuleDetails - { - /// System generated unique identitier. - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Id { get; set; } - - /// The name of the module. - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Name { get; set; } - - /// The type of a module. - [Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Type { get; set; } - - [Newtonsoft.Json.JsonProperty("config", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public Config Config { get; set; } = new Config(); - - [Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public Status Status { get; set; } = new Status(); - - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class Config - { - [Newtonsoft.Json.JsonProperty("settings", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public object Settings { get; set; } = new object(); - - [Newtonsoft.Json.JsonProperty("env", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.Collections.Generic.ICollection Env { get; set; } - - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class Status - { - [Newtonsoft.Json.JsonProperty("startTime", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.DateTimeOffset? StartTime { get; set; } - - [Newtonsoft.Json.JsonProperty("exitStatus", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public ExitStatus ExitStatus { get; set; } - - [Newtonsoft.Json.JsonProperty("runtimeStatus", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public RuntimeStatus RuntimeStatus { get; set; } = new RuntimeStatus(); - - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class EnvVar - { - [Newtonsoft.Json.JsonProperty("key", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Key { get; set; } - - [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Value { get; set; } - - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class ExitStatus - { - [Newtonsoft.Json.JsonProperty("exitTime", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public System.DateTimeOffset ExitTime { get; set; } - - [Newtonsoft.Json.JsonProperty("statusCode", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string StatusCode { get; set; } - - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class RuntimeStatus - { - [Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Status { get; set; } - - [Newtonsoft.Json.JsonProperty("description", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Description { get; set; } - - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class SignRequest + + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class SignRequest : System.ComponentModel.INotifyPropertyChanged { + private string _keyId; + private SignRequestAlgo _algo; + private byte[] _data; + /// Name of key to perform sign operation. [Newtonsoft.Json.JsonProperty("keyId", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string KeyId { get; set; } - + public string KeyId + { + get { return _keyId; } + set + { + if (_keyId != value) + { + _keyId = value; + RaisePropertyChanged(); + } + } + } + /// Sign algorithm to be used. [Newtonsoft.Json.JsonProperty("algo", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public SignRequestAlgo Algo { get; set; } - + public SignRequestAlgo Algo + { + get { return _algo; } + set + { + if (_algo != value) + { + _algo = value; + RaisePropertyChanged(); + } + } + } + /// Data to be signed. [Newtonsoft.Json.JsonProperty("data", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public byte[] Data { get; set; } - - + public byte[] Data + { + get { return _data; } + set + { + if (_data != value) + { + _data = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static SignRequest FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class SignResponse + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class SignResponse : System.ComponentModel.INotifyPropertyChanged { + private byte[] _digest; + /// Signature of the data. [Newtonsoft.Json.JsonProperty("digest", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public byte[] Digest { get; set; } - - + public byte[] Digest + { + get { return _digest; } + set + { + if (_digest != value) + { + _digest = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static SignResponse FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class EncryptRequest + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class EncryptRequest : System.ComponentModel.INotifyPropertyChanged { + private byte[] _plaintext; + private byte[] _initializationVector; + /// The data to be encrypted. [Newtonsoft.Json.JsonProperty("plaintext", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public byte[] Plaintext { get; set; } - + public byte[] Plaintext + { + get { return _plaintext; } + set + { + if (_plaintext != value) + { + _plaintext = value; + RaisePropertyChanged(); + } + } + } + /// An initialization vector used to encrypt the data. [Newtonsoft.Json.JsonProperty("initializationVector", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public byte[] InitializationVector { get; set; } - - + public byte[] InitializationVector + { + get { return _initializationVector; } + set + { + if (_initializationVector != value) + { + _initializationVector = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static EncryptRequest FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class EncryptResponse + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class EncryptResponse : System.ComponentModel.INotifyPropertyChanged { + private byte[] _ciphertext; + /// The encrypted form of the data encoded in base 64. [Newtonsoft.Json.JsonProperty("ciphertext", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public byte[] Ciphertext { get; set; } - - + public byte[] Ciphertext + { + get { return _ciphertext; } + set + { + if (_ciphertext != value) + { + _ciphertext = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static EncryptResponse FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class DecryptRequest + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class DecryptRequest : System.ComponentModel.INotifyPropertyChanged { + private byte[] _ciphertext; + private byte[] _initializationVector; + /// The data to be decrypted. [Newtonsoft.Json.JsonProperty("ciphertext", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public byte[] Ciphertext { get; set; } - + public byte[] Ciphertext + { + get { return _ciphertext; } + set + { + if (_ciphertext != value) + { + _ciphertext = value; + RaisePropertyChanged(); + } + } + } + /// An initialization vector used to decrypt the data. [Newtonsoft.Json.JsonProperty("initializationVector", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public byte[] InitializationVector { get; set; } - - + public byte[] InitializationVector + { + get { return _initializationVector; } + set + { + if (_initializationVector != value) + { + _initializationVector = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static DecryptRequest FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class DecryptResponse + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class DecryptResponse : System.ComponentModel.INotifyPropertyChanged { + private byte[] _plaintext; + /// The decrypted form of the data encoded in base 64. [Newtonsoft.Json.JsonProperty("plaintext", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public byte[] Plaintext { get; set; } - - + public byte[] Plaintext + { + get { return _plaintext; } + set + { + if (_plaintext != value) + { + _plaintext = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static DecryptResponse FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class ServerCertificateRequest + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class ServerCertificateRequest : System.ComponentModel.INotifyPropertyChanged { + private string _commonName; + private System.DateTime _expiration; + /// Subject common name [Newtonsoft.Json.JsonProperty("commonName", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string CommonName { get; set; } - + public string CommonName + { + get { return _commonName; } + set + { + if (_commonName != value) + { + _commonName = value; + RaisePropertyChanged(); + } + } + } + /// Certificate expiration date-time (ISO 8601) [Newtonsoft.Json.JsonProperty("expiration", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public System.DateTimeOffset Expiration { get; set; } - - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class IdentityCertificateRequest - { - /// Certificate expiration date-time (ISO 8601) - [Newtonsoft.Json.JsonProperty("expiration", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.DateTimeOffset? Expiration { get; set; } - - + public System.DateTime Expiration + { + get { return _expiration; } + set + { + if (_expiration != value) + { + _expiration = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static ServerCertificateRequest FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class CertificateResponse + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class CertificateResponse : System.ComponentModel.INotifyPropertyChanged { + private PrivateKey _privateKey = new PrivateKey(); + private string _certificate; + private System.DateTime _expiration; + [Newtonsoft.Json.JsonProperty("privateKey", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public PrivateKey PrivateKey { get; set; } = new PrivateKey(); - + public PrivateKey PrivateKey + { + get { return _privateKey; } + set + { + if (_privateKey != value) + { + _privateKey = value; + RaisePropertyChanged(); + } + } + } + /// Base64 encoded PEM formatted byte array containing the certificate and its chain. [Newtonsoft.Json.JsonProperty("certificate", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Certificate { get; set; } - + public string Certificate + { + get { return _certificate; } + set + { + if (_certificate != value) + { + _certificate = value; + RaisePropertyChanged(); + } + } + } + /// Certificate expiration date-time (ISO 8601) [Newtonsoft.Json.JsonProperty("expiration", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public System.DateTimeOffset Expiration { get; set; } - - + public System.DateTime Expiration + { + get { return _expiration; } + set + { + if (_expiration != value) + { + _expiration = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static CertificateResponse FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class TrustBundleResponse + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class TrustBundleResponse : System.ComponentModel.INotifyPropertyChanged { + private string _certificate; + /// Base64 encoded PEM formatted byte array containing the trusted certificates. [Newtonsoft.Json.JsonProperty("certificate", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Certificate { get; set; } - - + public string Certificate + { + get { return _certificate; } + set + { + if (_certificate != value) + { + _certificate = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static TrustBundleResponse FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class PrivateKey + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class PrivateKey : System.ComponentModel.INotifyPropertyChanged { + private PrivateKeyType _type; + private string _ref; + private string _bytes; + /// Indicates format of the key (present in PEM formatted bytes or a reference) [Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public PrivateKeyType Type { get; set; } - + public PrivateKeyType Type + { + get { return _type; } + set + { + if (_type != value) + { + _type = value; + RaisePropertyChanged(); + } + } + } + /// Reference to private key. [Newtonsoft.Json.JsonProperty("ref", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Ref { get; set; } - + public string Ref + { + get { return _ref; } + set + { + if (_ref != value) + { + _ref = value; + RaisePropertyChanged(); + } + } + } + /// Base64 encoded PEM formatted byte array [Newtonsoft.Json.JsonProperty("bytes", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Bytes { get; set; } - - + public string Bytes + { + get { return _bytes; } + set + { + if (_bytes != value) + { + _bytes = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static PrivateKey FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] - public partial class ErrorResponse + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] + public partial class ErrorResponse : System.ComponentModel.INotifyPropertyChanged { + private string _message; + [Newtonsoft.Json.JsonProperty("message", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Message { get; set; } - - + public string Message + { + get { return _message; } + set + { + if (_message != value) + { + _message = value; + RaisePropertyChanged(); + } + } + } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static ErrorResponse FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + + protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) + { + var handler = PropertyChanged; + if (handler != null) + handler(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); + } + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] public enum SignRequestAlgo { - [System.Runtime.Serialization.EnumMember(Value = @"HMACSHA256")] + [System.Runtime.Serialization.EnumMember(Value = "HMACSHA256")] HMACSHA256 = 0, - + } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v12.0.0.0)")] + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.10.46.0 (Newtonsoft.Json v9.0.0.0)")] public enum PrivateKeyType { - [System.Runtime.Serialization.EnumMember(Value = @"ref")] + [System.Runtime.Serialization.EnumMember(Value = "ref")] Ref = 0, - - [System.Runtime.Serialization.EnumMember(Value = @"key")] + + [System.Runtime.Serialization.EnumMember(Value = "key")] Key = 1, - + } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.17.6.0 (NJsonSchema v9.10.46.0 (Newtonsoft.Json v9.0.0.0))")] public partial class IoTEdgedException : System.Exception { public int StatusCode { get; private set; } public string Response { get; private set; } - public System.Collections.Generic.IReadOnlyDictionary> Headers { get; private set; } + public System.Collections.Generic.Dictionary> Headers { get; private set; } - public IoTEdgedException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, System.Exception innerException) - : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + response.Substring(0, response.Length >= 512 ? 512 : response.Length), innerException) + public IoTEdgedException(string message, int statusCode, string response, System.Collections.Generic.Dictionary> headers, System.Exception innerException) + : base(message, innerException) { StatusCode = statusCode; - Response = response; + Response = response; Headers = headers; } @@ -1073,12 +1414,12 @@ public override string ToString() } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.3.0.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v12.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "11.17.6.0 (NJsonSchema v9.10.46.0 (Newtonsoft.Json v9.0.0.0))")] public partial class IoTEdgedException : IoTEdgedException { public TResult Result { get; private set; } - public IoTEdgedException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, TResult result, System.Exception innerException) + public IoTEdgedException(string message, int statusCode, string response, System.Collections.Generic.Dictionary> headers, TResult result, System.Exception innerException) : base(message, statusCode, response, headers, innerException) { Result = result; @@ -1086,9 +1427,3 @@ public IoTEdgedException(string message, int statusCode, string response, System } } - -#pragma warning restore 1591 -#pragma warning restore 1573 -#pragma warning restore 472 -#pragma warning restore 114 -#pragma warning restore 108 From 17a34c904b12726d7188e36480008c5af4e3aac7 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 20 May 2020 12:24:41 -0700 Subject: [PATCH 104/111] re-order cert comment for clarity --- .../Hosting.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index b8f446d8892..1b7f20d39ae 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -41,6 +41,15 @@ public static Hosting Initialize( Context in this issue: https://github.com/dotnet/aspnetcore/issues/21606 */ HttpsConnectionAdapterOptions connectionAdapterOptions = new HttpsConnectionAdapterOptions() { + /* ClientCertificateMode.AllowCertificate is the intuitive choice here, however is not what we need + If we use this then aspnetcore will register it's own certificate validation callback when creating the SslStream. + This aspnetcore-created certificate validation callback in turn calls the HttpsConnectionAdapterOptions.ClientCertificateValidation, which we can configure In HttpsConnectionAdapterOptions. + This is not the desired solution for us because HttpsConnectionAdapterOptions.ClientCertificateValidation does not provide access to the client cert chain when the connection is in scope. + + Thus, we need to pass NoCertificate to block aspnet from creating the SslStream with the certificate validation callback. + This will let us use HttpsConnectionAdapterOptions.OnAuthenticate in order to register certificate validation with the connection in scope. + We can handle the cert / no-cert case inside of OnAuthenticate */ + ClientCertificateMode = ClientCertificateMode.NoCertificate, ServerCertificate = serverCertificate, OnAuthenticate = (context, options) => { @@ -62,15 +71,6 @@ Therefore we can set this field to true and it will still work with direct metho }; } }, - /* ClientCertificateMode.AllowCertificate is the intuitive choice here, however is not what we need - If we use this then aspnetcore will register it's own certificate validation callback when creating the SslStream. - This aspnetcore-created certificate validation callback in turn calls the HttpsConnectionAdapterOptions.ClientCertificateValidation, which we can configure In HttpsConnectionAdapterOptions. - This is not the desired solution for us because HttpsConnectionAdapterOptions.ClientCertificateValidation does not provide access to the client cert chain when the connection is in scope. - - Thus, we need to pass NoCertificate to block aspnet from creating the SslStream with the certificate validation callback. - This will let us use HttpsConnectionAdapterOptions.OnAuthenticate in order to register certificate validation with the connection in scope. - We can handle the cert / no-cert case inside of OnAuthenticate */ - ClientCertificateMode = ClientCertificateMode.NoCertificate, SslProtocols = sslProtocols }; From 0667b8f450cf058ef197f15f2ae931bb5df6b335 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 20 May 2020 12:31:07 -0700 Subject: [PATCH 105/111] add link to aspnet middleware --- .../Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 1b7f20d39ae..51c839d6906 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -38,7 +38,8 @@ public static Hosting Initialize( /* Define the HttpsConnectionAdapterOptions which integrates with aspnetcore https middleware to help us manage the client cert chain. We need to store the client cert chain in the connection context, so that we can perform custom CA validation later to authenticate with the service identity. We are using logic here that depends on an undocumented api, however eliminating this dependency would require a large refactor. - Context in this issue: https://github.com/dotnet/aspnetcore/issues/21606 */ + Context in this issue: https://github.com/dotnet/aspnetcore/issues/21606 + Link to aspnet https middleware: https://github.com/dotnet/aspnetcore/blob/e81033e094d4663ffd227bb4aed30b76b0631e6d/src/Servers/Kestrel/Core/src/Middleware/HttpsConnectionMiddleware.cs */ HttpsConnectionAdapterOptions connectionAdapterOptions = new HttpsConnectionAdapterOptions() { /* ClientCertificateMode.AllowCertificate is the intuitive choice here, however is not what we need @@ -51,6 +52,7 @@ This will let us use HttpsConnectionAdapterOptions.OnAuthenticate in order to re We can handle the cert / no-cert case inside of OnAuthenticate */ ClientCertificateMode = ClientCertificateMode.NoCertificate, ServerCertificate = serverCertificate, + SslProtocols = sslProtocols, OnAuthenticate = (context, options) => { if (clientCertAuthEnabled) @@ -70,8 +72,7 @@ Therefore we can set this field to true and it will still work with direct metho return true; }; } - }, - SslProtocols = sslProtocols + } }; int port = configuration.GetValue("httpSettings:port", 443); From e972a9fcd5ae24e89f71295ee9fa3afc2660ef3b Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 20 May 2020 12:37:27 -0700 Subject: [PATCH 106/111] add readme and todo to workload clients --- .../generatedCode/HttpWorkloadClient.cs | 13 ++++++++++++- .../generatedCode/HttpWorkloadClient.cs | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2018_06_28/generatedCode/HttpWorkloadClient.cs b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2018_06_28/generatedCode/HttpWorkloadClient.cs index 44cae8645a5..cf459be9631 100644 --- a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2018_06_28/generatedCode/HttpWorkloadClient.cs +++ b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2018_06_28/generatedCode/HttpWorkloadClient.cs @@ -4,7 +4,18 @@ // Generated using the NSwag toolchain v11.17.6.0 (NJsonSchema v9.10.46.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- -// Note: Code manually changed to replace System.Uri.EscapeDataString with System.Net.WebUtility.UrlEncode +/* +______ ______ _____ __ __ ______ _ _ ______ _ +| __ \| ____| /\ | __ \| \/ | ____|_ | \ | | | __ \ | | (_) +| |__) | |__ / \ | | | | \ / | |__ (_) | \| |_____ ____ _ __ _ | |__) |___ __ _ ___ _ __ ___ _ __ __ _| |_ _ ___ _ __ +| _ /| __| / /\ \ | | | | |\/| | __| | . ` / __\ \ /\ / / _` |/ _` | | _ // _ \/ _` |/ _ \ '_ \ / _ \ '__/ _` | __| |/ _ \| '_ \ +| | \ \| |____ / ____ \| |__| | | | | |____ _ | |\ \__ \\ V V / (_| | (_| | | | \ \ __/ (_| | __/ | | | __/ | | (_| | |_| | (_) | | | | +|_| \_\______/_/ \_\_____/|_| |_|______(_) |_| \_|___/ \_/\_/ \__,_|\__, | |_| \_\___|\__, |\___|_| |_|\___|_| \__,_|\__|_|\___/|_| |_| + __/ | __/ | + |___/ |___/ +Note: Code manually changed to replace System.Uri.EscapeDataString with System.Net.WebUtility.UrlEncode +TODO: Write test to ensure that WebUtility.UrlEncode is used +*/ namespace Microsoft.Azure.Devices.Edge.Util.Edged.Version_2018_06_28.GeneratedCode { diff --git a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2019_01_30/generatedCode/HttpWorkloadClient.cs b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2019_01_30/generatedCode/HttpWorkloadClient.cs index c22b0ef0a36..59fae507a98 100644 --- a/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2019_01_30/generatedCode/HttpWorkloadClient.cs +++ b/edge-util/src/Microsoft.Azure.Devices.Edge.Util/edged/version_2019_01_30/generatedCode/HttpWorkloadClient.cs @@ -3,7 +3,18 @@ // Generated using the NSwag toolchain v11.17.6.0 (NJsonSchema v9.10.46.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org) // //---------------------- -// Note: Code manually changed to replace System.Uri.EscapeDataString with System.Net.WebUtility.UrlEncode +/* +______ ______ _____ __ __ ______ _ _ ______ _ +| __ \| ____| /\ | __ \| \/ | ____|_ | \ | | | __ \ | | (_) +| |__) | |__ / \ | | | | \ / | |__ (_) | \| |_____ ____ _ __ _ | |__) |___ __ _ ___ _ __ ___ _ __ __ _| |_ _ ___ _ __ +| _ /| __| / /\ \ | | | | |\/| | __| | . ` / __\ \ /\ / / _` |/ _` | | _ // _ \/ _` |/ _ \ '_ \ / _ \ '__/ _` | __| |/ _ \| '_ \ +| | \ \| |____ / ____ \| |__| | | | | |____ _ | |\ \__ \\ V V / (_| | (_| | | | \ \ __/ (_| | __/ | | | __/ | | (_| | |_| | (_) | | | | +|_| \_\______/_/ \_\_____/|_| |_|______(_) |_| \_|___/ \_/\_/ \__,_|\__, | |_| \_\___|\__, |\___|_| |_|\___|_| \__,_|\__|_|\___/|_| |_| + __/ | __/ | + |___/ |___/ +Note: Code manually changed to replace System.Uri.EscapeDataString with System.Net.WebUtility.UrlEncode +TODO: Write test to ensure that WebUtility.UrlEncode is used +*/ namespace Microsoft.Azure.Devices.Edge.Util.Edged.Version_2019_01_30.GeneratedCode { From 0c7d811f39c988a86e09eee59447942c9b504607 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 20 May 2020 13:23:10 -0700 Subject: [PATCH 107/111] use netstandard 2.0 for all libraries --- .../Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj | 4 +++- .../samples/EdgeHubTrigger-Csharp/EdgeHubTriggerCSharp.csproj | 2 +- scripts/linux/buildBranch.sh | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj index b4ca28346f5..a12b2704b85 100644 --- a/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj +++ b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj @@ -3,7 +3,9 @@ true - + + netstandard2.0 + Microsoft.Azure.WebJobs.Extensions.EdgeHub diff --git a/edge-modules/functions/samples/EdgeHubTrigger-Csharp/EdgeHubTriggerCSharp.csproj b/edge-modules/functions/samples/EdgeHubTrigger-Csharp/EdgeHubTriggerCSharp.csproj index 54fdc05d43e..f3a9824322e 100644 --- a/edge-modules/functions/samples/EdgeHubTrigger-Csharp/EdgeHubTriggerCSharp.csproj +++ b/edge-modules/functions/samples/EdgeHubTrigger-Csharp/EdgeHubTriggerCSharp.csproj @@ -1,6 +1,6 @@  - + diff --git a/scripts/linux/buildBranch.sh b/scripts/linux/buildBranch.sh index e1995ea6516..a6d73322ca9 100755 --- a/scripts/linux/buildBranch.sh +++ b/scripts/linux/buildBranch.sh @@ -155,7 +155,7 @@ publish_app() publish_lib() { local name="$1" - publish_project library "$name" netcoreapp3.1 $CONFIGURATION "$PUBLISH_FOLDER/$name" + publish_project library "$name" netstandard2.0 $CONFIGURATION "$PUBLISH_FOLDER/$name" } publish_quickstart() From 051f097fc4834f7ac378149425e4a37599cce149 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 20 May 2020 13:27:50 -0700 Subject: [PATCH 108/111] fix stylecop --- .../src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs index 51c839d6906..8b9c6fae1be 100644 --- a/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs +++ b/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Service/Hosting.cs @@ -38,7 +38,7 @@ public static Hosting Initialize( /* Define the HttpsConnectionAdapterOptions which integrates with aspnetcore https middleware to help us manage the client cert chain. We need to store the client cert chain in the connection context, so that we can perform custom CA validation later to authenticate with the service identity. We are using logic here that depends on an undocumented api, however eliminating this dependency would require a large refactor. - Context in this issue: https://github.com/dotnet/aspnetcore/issues/21606 + Context in this issue: https://github.com/dotnet/aspnetcore/issues/21606 Link to aspnet https middleware: https://github.com/dotnet/aspnetcore/blob/e81033e094d4663ffd227bb4aed30b76b0631e6d/src/Servers/Kestrel/Core/src/Middleware/HttpsConnectionMiddleware.cs */ HttpsConnectionAdapterOptions connectionAdapterOptions = new HttpsConnectionAdapterOptions() { From c2787706d81fb651483136d842976e72aa751361 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Wed, 20 May 2020 13:50:26 -0700 Subject: [PATCH 109/111] use netstandard for windows publish --- scripts/windows/build/Publish-Branch.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/windows/build/Publish-Branch.ps1 b/scripts/windows/build/Publish-Branch.ps1 index bd59b02caee..8ddc5cf70f3 100644 --- a/scripts/windows/build/Publish-Branch.ps1 +++ b/scripts/windows/build/Publish-Branch.ps1 @@ -202,7 +202,7 @@ foreach ($libProjectFileName in $libProjectList) { Write-Host "Publishing Lib Project - $libProjectFilePath" $ProjectPublishPath = Join-Path $PUBLISH_FOLDER ($libProjectFileName -replace @(".csproj", "")) - &$DOTNET_PATH publish -f netcoreapp3.1 -c $Configuration -o $ProjectPublishPath $libProjectFilePath | + &$DOTNET_PATH publish -f netstandard2.0 -c $Configuration -o $ProjectPublishPath $libProjectFilePath | Write-Host if ($LASTEXITCODE -ne 0) { throw "Failed lib publishing $libProjectFilePath." From ed0c4dc01fc4fa21af18a73e936143641e1afeb3 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 21 May 2020 09:04:27 -0700 Subject: [PATCH 110/111] lingering direct netstandard reference in csproj --- .../Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj index a12b2704b85..cca0a4d6a4d 100644 --- a/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj +++ b/edge-modules/functions/binding/src/Microsoft.Azure.WebJobs.Extensions.EdgeHub/Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj @@ -3,9 +3,7 @@ true - - netstandard2.0 - + Microsoft.Azure.WebJobs.Extensions.EdgeHub From 9ec1e3841095d8b0502bdd408d2a4a99072b28da Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 21 May 2020 15:59:39 -0700 Subject: [PATCH 111/111] fix functions module by publishing as application instead of lib --- .../EdgeHubTrigger-Csharp/EdgeHubTriggerCSharp.csproj | 2 +- scripts/linux/buildBranch.sh | 6 +----- scripts/windows/build/Publish-Branch.ps1 | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/edge-modules/functions/samples/EdgeHubTrigger-Csharp/EdgeHubTriggerCSharp.csproj b/edge-modules/functions/samples/EdgeHubTrigger-Csharp/EdgeHubTriggerCSharp.csproj index f3a9824322e..54fdc05d43e 100644 --- a/edge-modules/functions/samples/EdgeHubTrigger-Csharp/EdgeHubTriggerCSharp.csproj +++ b/edge-modules/functions/samples/EdgeHubTrigger-Csharp/EdgeHubTriggerCSharp.csproj @@ -1,6 +1,6 @@  - + diff --git a/scripts/linux/buildBranch.sh b/scripts/linux/buildBranch.sh index a6d73322ca9..9d1a814944c 100755 --- a/scripts/linux/buildBranch.sh +++ b/scripts/linux/buildBranch.sh @@ -16,9 +16,7 @@ BUILD_REPOSITORY_LOCALPATH=${BUILD_REPOSITORY_LOCALPATH:-$DIR/../..} BUILD_BINARIESDIRECTORY=${BUILD_BINARIESDIRECTORY:-$BUILD_REPOSITORY_LOCALPATH/target} PUBLISH_FOLDER=$BUILD_BINARIESDIRECTORY/publish ROOT_FOLDER=$BUILD_REPOSITORY_LOCALPATH -SRC_DOCKER_DIR=$ROOT_FOLDER/docker SRC_SCRIPTS_DIR=$ROOT_FOLDER/scripts -SRC_STRESS_DIR=$ROOT_FOLDER/stress SRC_E2E_TEMPLATES_DIR=$ROOT_FOLDER/e2e_deployment_files SRC_E2E_TEST_FILES_DIR=$ROOT_FOLDER/e2e_test_files SRC_CERT_TOOLS_DIR=$ROOT_FOLDER/tools/CACertificates @@ -246,13 +244,11 @@ publish_app "DeploymentTester" publish_app "EdgeHubRestartTester" publish_app "MetricsValidator" publish_app "CloudToDeviceMessageTester" +publish_app "EdgeHubTriggerCSharp" publish_lib "Microsoft.Azure.WebJobs.Extensions.EdgeHub" -publish_lib "EdgeHubTriggerCSharp" -publish_files $SRC_DOCKER_DIR $PUBLISH_FOLDER publish_files $SRC_SCRIPTS_DIR $PUBLISH_FOLDER -publish_files $SRC_STRESS_DIR $PUBLISH_FOLDER publish_files $SRC_E2E_TEMPLATES_DIR $PUBLISH_FOLDER publish_files $SRC_E2E_TEST_FILES_DIR $PUBLISH_FOLDER publish_files $SRC_CERT_TOOLS_DIR $PUBLISH_FOLDER diff --git a/scripts/windows/build/Publish-Branch.ps1 b/scripts/windows/build/Publish-Branch.ps1 index 8ddc5cf70f3..4f58142d740 100644 --- a/scripts/windows/build/Publish-Branch.ps1 +++ b/scripts/windows/build/Publish-Branch.ps1 @@ -151,6 +151,7 @@ $appProjectList.Add("DeploymentTester.csproj") $appProjectList.Add("EdgeHubRestartTester.csproj") $appProjectList.Add("MetricsValidator.csproj") $appProjectList.Add("CloudToDeviceMessageTester.csproj") +$appProjectList.Add("EdgeHubTriggerCSharp.csproj") # Download latest rocksdb ARM32 library $rocksdbARMUri = "https://edgebuild.blob.core.windows.net/rocksdb/rocksdb-arm.dll" @@ -191,7 +192,6 @@ Write-Host "`nPublishing .NET Core libs`n" $libProjectList = New-Object 'System.Collections.Generic.List[String]' $libProjectList.Add("Microsoft.Azure.WebJobs.Extensions.EdgeHub.csproj") -$libProjectList.Add("EdgeHubTriggerCSharp.csproj") foreach ($libProjectFileName in $libProjectList) { $libProjectFilePath = Get-ChildItem -Include *.csproj -File -Recurse |Where-Object {$_.Name -eq "$libProjectFileName"}|Select-Object -first 1|Select -ExpandProperty "FullName"