diff --git a/.gitignore b/.gitignore index 7af2bd181b9..41985c0f13d 100644 --- a/.gitignore +++ b/.gitignore @@ -332,3 +332,6 @@ parts/ stage/ prime/ *.snap + +# used by the C# Dev Kit (VS Code extension) +.mono/ diff --git a/builds/checkin/dotnet.yaml b/builds/checkin/dotnet.yaml index 0abb615af2a..928560cb89a 100644 --- a/builds/checkin/dotnet.yaml +++ b/builds/checkin/dotnet.yaml @@ -37,12 +37,12 @@ jobs: steps: - script: scripts/linux/installPrereqs.sh displayName: Install Prerequisites - - script: scripts/linux/buildBranch.sh -c '$(configuration)' - displayName: Build - - script: scripts/linux/runTests.sh '--filter Category=Unit&Category!=GetLogsTests' - displayName: Test - - script: scripts/linux/runTests.sh '--filter Category=GetLogsTests' - displayName: Run GetLogsTests Tests + - script: | + dotnet test \ + --configuration $(configuration) \ + --filter 'Category=Unit' \ + --logger trx \ + displayName: Build and run unit tests - task: PublishTestResults@2 displayName: Publish Test Results inputs: @@ -69,19 +69,10 @@ jobs: dotnet test \ --logger trx \ --results-directory '$(Agent.TempDirectory)' \ - --filter 'Category=Unit&Category!=GetLogsTests' \ + --filter 'Category=Unit' \ --collect 'xplat code coverage' \ --settings CodeCoverage.runsettings displayName: Run unit tests with code coverage - - script: | - dotnet test 'edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Core.Test' \ - --logger trx \ - --results-directory '$(Agent.TempDirectory)' \ - --filter 'Category=GetLogsTests' \ - --collect 'xplat code coverage' \ - --settings CodeCoverage.runsettings - displayName: Run GetLogsTests unit tests with code coverage - condition: succeededOrFailed() - script: | dotnet new tool-manifest dotnet tool install dotnet-reportgenerator-globaltool diff --git a/builds/ci/dotnet.yaml b/builds/ci/dotnet.yaml index b74db1ff2c3..12d9cdb37c1 100644 --- a/builds/ci/dotnet.yaml +++ b/builds/ci/dotnet.yaml @@ -49,7 +49,7 @@ jobs: CERT_VALUE: $(IotHubMqttHeadCert) - script: scripts/linux/buildBranch.sh -c $(Build.Configuration) --no-rocksdb-bin --skip-quickstart displayName: Build - - script: sudo -E bash -c './scripts/linux/runTests.sh "--filter $(test.filter)&Category!=Kubernetes" $(Build.Configuration)' + - script: sudo -E bash -c './scripts/linux/runTests.sh "$(test.filter)" "$(Build.Configuration)"' displayName: Integration Tests env: DummySecret1: $(DummySecret1) @@ -59,28 +59,6 @@ jobs: IotDevice3ConnStr2: $(IotDevice3ConnStr2) IotHubConnStr2: $(IotHubConnStr2) IotHubMqttHeadCert: $(IotHubMqttHeadCert) -# - script: | -# # download kind binary and make it executable -# curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.5.1/kind-$(uname)-amd64 -# chmod +x ./kind -# # move it to $AGENT_TOOLSDIRECTORY\kind -# mkdir $AGENT_TOOLSDIRECTORY/kind -# mv ./kind $AGENT_TOOLSDIRECTORY/kind/kind -# # make kind to be available for integration tests -# echo "##vso[task.setvariable variable=PATH;]$AGENT_TOOLSDIRECTORY/kind:$PATH" -# displayName: Install Kubernetes cluster manager (kind) -# condition: succeededOrFailed() -# - script: | -# kind create cluster --name "edgy" --wait 5m -# KUBECONFIG=$(kind get kubeconfig-path --name "edgy") -# echo "##vso[task.setvariable variable=KUBECONFIG;]$KUBECONFIG" -# echo "##vso[task.setvariable variable=USE_EXISTING_KUBERNETES_CLUSTER;]true" -# displayName: Create Kubernetes cluster (edgy) -# condition: succeededOrFailed() -# - script: | -# sudo -E bash -c './scripts/linux/runTests.sh "--filter $(test.filter)&Category=Kubernetes" $(Build.Configuration)' -# displayName: Kubernetes Integration Tests -# condition: succeededOrFailed() - task: PublishTestResults@2 displayName: Publish test results inputs: diff --git a/builds/e2e/templates/e2e-setup.yaml b/builds/e2e/templates/e2e-setup.yaml index 55e32449d41..dded40d0bdd 100644 --- a/builds/e2e/templates/e2e-setup.yaml +++ b/builds/e2e/templates/e2e-setup.yaml @@ -113,7 +113,7 @@ steps: $testDir = '$(Build.SourcesDirectory)/test/Microsoft.Azure.Devices.Edge.Test' dotnet build $testDir - $binDir = Convert-Path "$testDir/bin/Debug/net6.0" + $binDir = Convert-Path "$testDir/bin/Debug/net8.0" Write-Output "##vso[task.setvariable variable=binDir]$binDir" env: http_proxy: $(Agent.ProxyUrl) diff --git a/doc/devguide.md b/doc/devguide.md index 82a9a894476..e06c877d00d 100644 --- a/doc/devguide.md +++ b/doc/devguide.md @@ -59,7 +59,7 @@ scripts/linux/downloadAndInstallCert.sh -v -c Then run the tests either with Test Explorer in Visual Studio IDE, or with: ```sh -scripts/linux/runTests.sh "--filter Category=Integration" +scripts/linux/runTests.sh "Category=Integration" ``` The syntax of the "filter" argument is described [here](https://docs.microsoft.com/dotnet/core/tools/dotnet-test#filter-option-details). All IoT Edge tests are categorized as one of `Unit`, `Integration`, or `Bvt`. diff --git a/edge-agent/docker/linux/Dockerfile b/edge-agent/docker/linux/Dockerfile index 7d8c56ce923..3b75b3d2236 100644 --- a/edge-agent/docker/linux/Dockerfile +++ b/edge-agent/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine ARG EXE_DIR=. ARG TARGETPLATFORM 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 4d89139bb8f..4e34e3026ca 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 @@ -9,7 +9,7 @@ - + diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/AzureAppendBlob.cs b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/AzureAppendBlob.cs index 422fcf07ae7..1dcf581cdcb 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/AzureAppendBlob.cs +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/AzureAppendBlob.cs @@ -2,21 +2,23 @@ namespace Microsoft.Azure.Devices.Edge.Agent.IoTHub { using System; + using System.IO; using System.Threading.Tasks; + using global::Azure.Storage.Blobs.Specialized; using Microsoft.Azure.Devices.Edge.Util; - using Microsoft.WindowsAzure.Storage.Blob; class AzureAppendBlob : IAzureAppendBlob { - readonly CloudAppendBlob appendBlob; + readonly AppendBlobClient appendBlob; - public AzureAppendBlob(CloudAppendBlob appendBlob) + public AzureAppendBlob(AppendBlobClient appendBlob) { this.appendBlob = Preconditions.CheckNotNull(appendBlob, nameof(appendBlob)); } public string Name => this.appendBlob.Name; - public Task AppendByteArray(ArraySegment bytes) => this.appendBlob.AppendFromByteArrayAsync(bytes.Array, bytes.Offset, bytes.Count); + public Task AppendByteArray(ArraySegment bytes) => + this.appendBlob.AppendBlockAsync(new MemoryStream(bytes.Array, bytes.Offset, bytes.Count)); } } 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 78bfe5473a3..e5a9630359e 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 @@ -9,8 +9,9 @@ - - + + + diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/blob/AzureBlob.cs b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/blob/AzureBlob.cs index 03cdc3ed45c..d78c296d7ff 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/blob/AzureBlob.cs +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/blob/AzureBlob.cs @@ -3,22 +3,29 @@ namespace Microsoft.Azure.Devices.Edge.Agent.IoTHub.Blob { using System.IO; using System.Threading.Tasks; + using global::Azure.Storage.Blobs.Models; + using global::Azure.Storage.Blobs.Specialized; using Microsoft.Azure.Devices.Edge.Util; - using Microsoft.WindowsAzure.Storage.Blob; class AzureBlob : IAzureBlob { - readonly CloudBlockBlob blockBlob; + readonly BlockBlobClient blockBlob; + readonly BlobHttpHeaders headers; - public AzureBlob(CloudBlockBlob blockBlob) + public AzureBlob(BlockBlobClient blockBlob, BlobHttpHeaders headers) { this.blockBlob = Preconditions.CheckNotNull(blockBlob, nameof(blockBlob)); + this.headers = Preconditions.CheckNotNull(headers, nameof(headers)); } public string Name => this.blockBlob.Name; - public Task UploadFromByteArrayAsync(byte[] bytes) => this.blockBlob.UploadFromByteArrayAsync(bytes, 0, bytes.Length); + public Task UploadFromByteArrayAsync(byte[] bytes) + { + var options = new BlobUploadOptions { HttpHeaders = this.headers }; + return this.blockBlob.UploadAsync(new MemoryStream(bytes), options); + } - public Task UploadFromStreamAsync(Stream source) => this.blockBlob.UploadFromStreamAsync(source); + public Task UploadFromStreamAsync(Stream source) => this.blockBlob.UploadAsync(source); } } diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/blob/AzureBlobRequestsUploader.cs b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/blob/AzureBlobRequestsUploader.cs index ed9e34044ec..2b064e7ffc0 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/blob/AzureBlobRequestsUploader.cs +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/blob/AzureBlobRequestsUploader.cs @@ -5,12 +5,12 @@ namespace Microsoft.Azure.Devices.Edge.Agent.IoTHub.Blob using System.Globalization; using System.IO; using System.Threading.Tasks; + using global::Azure.Storage.Blobs; using Microsoft.Azure.Devices.Edge.Agent.Core; using Microsoft.Azure.Devices.Edge.Agent.Core.Logs; using Microsoft.Azure.Devices.Edge.Util; using Microsoft.Azure.Devices.Edge.Util.TransientFaultHandling; using Microsoft.Extensions.Logging; - using Microsoft.WindowsAzure.Storage.Blob; public class AzureBlobRequestsUploader : IRequestsUploader { @@ -47,7 +47,7 @@ public async Task UploadLogs(string uri, string id, byte[] payload, LogsContentE { var containerUri = new Uri(uri); string blobName = this.GetBlobName(id, GetLogsExtension(logsContentEncoding, logsContentType)); - var container = new CloudBlobContainer(containerUri); + var container = new BlobContainerClient(containerUri); Events.Uploading(blobName, container.Name); await ExecuteWithRetry( @@ -74,7 +74,7 @@ public async Task, Task>> GetLogsUploaderCallback(string var containerUri = new Uri(uri); string blobName = this.GetBlobName(id, GetLogsExtension(logsContentEncoding, logsContentType)); - var container = new CloudBlobContainer(containerUri); + var container = new BlobContainerClient(containerUri); Events.Uploading(blobName, container.Name); IAzureAppendBlob blob = await this.azureBlobUploader.GetAppendBlob(containerUri, blobName, GetContentType(logsContentType), GetContentEncoding(logsContentEncoding)); return blob.AppendByteArray; @@ -89,7 +89,7 @@ public async Task UploadSupportBundle(string uri, Stream source) { var containerUri = new Uri(uri); string blobName = this.GetBlobName("support-bundle", "zip"); - var container = new CloudBlobContainer(containerUri); + var container = new BlobContainerClient(containerUri); Events.Uploading(blobName, container.Name); await ExecuteWithRetry( () => diff --git a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/blob/AzureBlobUploader.cs b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/blob/AzureBlobUploader.cs index 7a6dd395deb..6767883644b 100644 --- a/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/blob/AzureBlobUploader.cs +++ b/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/blob/AzureBlobUploader.cs @@ -3,28 +3,33 @@ namespace Microsoft.Azure.Devices.Edge.Agent.IoTHub.Blob { using System; using System.Threading.Tasks; + using global::Azure.Storage.Blobs; + using global::Azure.Storage.Blobs.Models; + using global::Azure.Storage.Blobs.Specialized; using Microsoft.Azure.Devices.Edge.Util; - using Microsoft.WindowsAzure.Storage.Blob; class AzureBlobUploader : IAzureBlobUploader { public IAzureBlob GetBlob(Uri containerUri, string blobName, Option contentType, Option contentEncoding) { - var container = new CloudBlobContainer(Preconditions.CheckNotNull(containerUri, nameof(containerUri))); - CloudBlockBlob blob = container.GetBlockBlobReference(Preconditions.CheckNonWhiteSpace(blobName, nameof(blobName))); - contentType.ForEach(c => blob.Properties.ContentType = c); - contentEncoding.ForEach(c => blob.Properties.ContentEncoding = c); - var azureBlob = new AzureBlob(blob); + var container = new BlobContainerClient(Preconditions.CheckNotNull(containerUri, nameof(containerUri))); + BlockBlobClient blob = container.GetBlockBlobClient(Preconditions.CheckNonWhiteSpace(blobName, nameof(blobName))); + var headers = new BlobHttpHeaders(); + contentType.ForEach(c => headers.ContentType = c); + contentEncoding.ForEach(c => headers.ContentEncoding = c); + var azureBlob = new AzureBlob(blob, headers); return azureBlob; } public async Task GetAppendBlob(Uri containerUri, string blobName, Option contentType, Option contentEncoding) { - var container = new CloudBlobContainer(Preconditions.CheckNotNull(containerUri, nameof(containerUri))); - CloudAppendBlob blob = container.GetAppendBlobReference(Preconditions.CheckNonWhiteSpace(blobName, nameof(blobName))); - contentType.ForEach(c => blob.Properties.ContentType = c); - contentEncoding.ForEach(c => blob.Properties.ContentEncoding = c); - await blob.CreateOrReplaceAsync(); + var container = new BlobContainerClient(Preconditions.CheckNotNull(containerUri, nameof(containerUri))); + AppendBlobClient blob = container.GetAppendBlobClient(Preconditions.CheckNonWhiteSpace(blobName, nameof(blobName))); + var headers = new BlobHttpHeaders(); + contentType.ForEach(c => headers.ContentType = c); + contentEncoding.ForEach(c => headers.ContentEncoding = c); + var options = new AppendBlobCreateOptions { HttpHeaders = headers }; + await blob.CreateAsync(options); var azureBlob = new AzureAppendBlob(blob); return azureBlob; } diff --git a/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj b/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj index f7592abd347..8a891902b45 100644 --- a/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj +++ b/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj @@ -9,7 +9,7 @@ - + diff --git a/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.CloudProxy/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.csproj b/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.CloudProxy/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.csproj index 9c97baf936c..c67fb8ae4b9 100644 --- a/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.CloudProxy/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.csproj +++ b/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.CloudProxy/Microsoft.Azure.Devices.Edge.Hub.CloudProxy.csproj @@ -9,7 +9,7 @@ - + diff --git a/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Core/Microsoft.Azure.Devices.Edge.Hub.Core.csproj b/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Core/Microsoft.Azure.Devices.Edge.Hub.Core.csproj index 9d0b002c8b5..29518955067 100644 --- a/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Core/Microsoft.Azure.Devices.Edge.Hub.Core.csproj +++ b/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Core/Microsoft.Azure.Devices.Edge.Hub.Core.csproj @@ -18,21 +18,8 @@ - + - - - - - - - - diff --git a/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj b/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj index 2dcf71ff3a6..958f1483b00 100644 --- a/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj +++ b/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Http/Microsoft.Azure.Devices.Edge.Hub.Http.csproj @@ -13,7 +13,7 @@ - + diff --git a/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Http/controllers/RegistryController.cs b/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Http/controllers/RegistryController.cs index 5a642cb9a00..15972f73e35 100644 --- a/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Http/controllers/RegistryController.cs +++ b/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Http/controllers/RegistryController.cs @@ -536,7 +536,7 @@ async Task SendResponseAsync(HttpStatusCode status, Dictionary h foreach (var header in headers) { - this.Response.Headers.Add(header.Key, header.Value); + this.Response.Headers.Append(header.Key, header.Value); } if (!string.IsNullOrEmpty(jsonContent)) diff --git a/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj b/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj index 746ed7e1e95..ed48ee5ab49 100644 --- a/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj +++ b/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj @@ -11,19 +11,6 @@ - - - - - - - - diff --git a/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs b/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs index 6b9d6da86a1..14907acbf7e 100644 --- a/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs +++ b/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Service/Startup.cs @@ -2,11 +2,13 @@ namespace Microsoft.Azure.Devices.Edge.Hub.Service { using System; + using System.Linq; using System.Threading.Tasks; using Autofac; using Autofac.Extensions.DependencyInjection; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; + using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.Devices.Edge.Hub.Core; using Microsoft.Azure.Devices.Edge.Hub.Http; @@ -86,7 +88,7 @@ public void Configure(IApplicationBuilder app) async (context, next) => { // Response header is added to prevent MIME type sniffing - context.Response.Headers.Add("X-Content-Type-Options", "nosniff"); + context.Response.Headers.Append("X-Content-Type-Options", "nosniff"); await next(); }); diff --git a/edge-hub/core/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/HttpProxiedCertificateExtractorTest.cs b/edge-hub/core/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/HttpProxiedCertificateExtractorTest.cs index 1da246f230d..d04076c0541 100644 --- a/edge-hub/core/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/HttpProxiedCertificateExtractorTest.cs +++ b/edge-hub/core/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/HttpProxiedCertificateExtractorTest.cs @@ -52,7 +52,7 @@ public async Task AuthenticateRequestTestX509ApiProxyForward_NoSasToken_ShouldTh string certContentBase64 = Convert.ToBase64String(certContentBytes); string clientCertString = $"-----BEGIN CERTIFICATE-----\n{certContentBase64}\n-----END CERTIFICATE-----\n"; clientCertString = WebUtility.UrlEncode(clientCertString); - httpContext.Request.Headers.Add(Constants.ClientCertificateHeaderKey, new StringValues(clientCertString)); + httpContext.Request.Headers.Append(Constants.ClientCertificateHeaderKey, new StringValues(clientCertString)); httpContext.Request.QueryString = new QueryString("?api-version=2017-10-20"); var authenticator = new Mock(); @@ -76,10 +76,10 @@ public async Task AuthenticateRequestTestX509ApiProxyForward_InvalidCertificate_ string certContentBase64 = Convert.ToBase64String(certContentBytes); string clientCertString = $"{certContentBase64}"; clientCertString = WebUtility.UrlEncode(clientCertString); - httpContext.Request.Headers.Add(Constants.ClientCertificateHeaderKey, new StringValues(clientCertString)); + httpContext.Request.Headers.Append(Constants.ClientCertificateHeaderKey, new StringValues(clientCertString)); httpContext.Request.QueryString = new QueryString("?api-version=2017-10-20"); string sasToken = TokenHelper.CreateSasToken($"{iothubHostName}/devices/{deviceId}/modules/{apiProxyId}"); - httpContext.Request.Headers.Add(HeaderNames.Authorization, new StringValues(sasToken)); + httpContext.Request.Headers.Append(HeaderNames.Authorization, new StringValues(sasToken)); var authenticator = new Mock(); var identityFactory = new ClientCredentialsFactory(new IdentityProvider(iothubHostName)); @@ -101,9 +101,9 @@ public async Task AuthenticateRequestTestX509ApiProxyForward_ProxyAuthFailed_Sho string certContentBase64 = Convert.ToBase64String(certContentBytes); string clientCertString = $"-----BEGIN CERTIFICATE-----\n{certContentBase64}\n-----END CERTIFICATE-----\n"; clientCertString = WebUtility.UrlEncode(clientCertString); - httpContext.Request.Headers.Add(Constants.ClientCertificateHeaderKey, new StringValues(clientCertString)); + httpContext.Request.Headers.Append(Constants.ClientCertificateHeaderKey, new StringValues(clientCertString)); string sasToken = TokenHelper.CreateSasToken($"{iothubHostName}/devices/{deviceId}/modules/{apiProxyId}"); - httpContext.Request.Headers.Add(HeaderNames.Authorization, new StringValues(sasToken)); + httpContext.Request.Headers.Append(HeaderNames.Authorization, new StringValues(sasToken)); httpContext.Request.QueryString = new QueryString("?api-version=2017-10-20"); var authenticator = new Mock(); authenticator.Setup(a => a.AuthenticateAsync(It.Is(c => c.Identity.Id == "device_2/iotedgeApiProxy"))).ReturnsAsync(false); @@ -128,9 +128,9 @@ public async Task AuthenticateRequestTestX509ApiProxyForward_ProxyAuthSuccess_Sh string certContentBase64 = Convert.ToBase64String(certContentBytes); string clientCertString = $"-----BEGIN CERTIFICATE-----\n{certContentBase64}\n-----END CERTIFICATE-----\n"; clientCertString = WebUtility.UrlEncode(clientCertString); - httpContext.Request.Headers.Add(Constants.ClientCertificateHeaderKey, new StringValues(clientCertString)); + httpContext.Request.Headers.Append(Constants.ClientCertificateHeaderKey, new StringValues(clientCertString)); string sasToken = TokenHelper.CreateSasToken($"{iothubHostName}/devices/{deviceId}/modules/{apiProxyId}"); - httpContext.Request.Headers.Add(HeaderNames.Authorization, new StringValues(sasToken)); + httpContext.Request.Headers.Append(HeaderNames.Authorization, new StringValues(sasToken)); httpContext.Request.QueryString = new QueryString("?api-version=2017-10-20"); var authenticator = new Mock(); authenticator.Setup(a => a.AuthenticateAsync(It.Is(c => c.Identity.Id == "device_2/iotedgeApiProxy"))).ReturnsAsync(true); diff --git a/edge-hub/core/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/HttpRequestAuthenticatorTest.cs b/edge-hub/core/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/HttpRequestAuthenticatorTest.cs index de91fa7f3cb..870b2ca2244 100644 --- a/edge-hub/core/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/HttpRequestAuthenticatorTest.cs +++ b/edge-hub/core/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/HttpRequestAuthenticatorTest.cs @@ -29,7 +29,7 @@ public async Task AuthenticateRequestTest_Success() string moduleId = "module_1"; var httpContext = new DefaultHttpContext(); string sasToken = TokenHelper.CreateSasToken($"{iothubHostName}/devices/{deviceId}/modules/{moduleId}"); - httpContext.Request.Headers.Add(HeaderNames.Authorization, new StringValues(sasToken)); + httpContext.Request.Headers.Append(HeaderNames.Authorization, new StringValues(sasToken)); httpContext.Request.QueryString = new QueryString("?api-version=2017-10-20"); var authenticator = new Mock(); @@ -51,7 +51,7 @@ public async Task InvalidAuthenticateRequestTest_MultipleAuthHeaders() string deviceId = "device_2"; string moduleId = "module_1"; var httpContext = new DefaultHttpContext(); - httpContext.Request.Headers.Add(HeaderNames.Authorization, new StringValues(new[] { "sasToken1", "sasToken2" })); + httpContext.Request.Headers.Append(HeaderNames.Authorization, new StringValues(new[] { "sasToken1", "sasToken2" })); httpContext.Request.QueryString = new QueryString("?api-version=2017-10-20"); var authenticator = new Mock(); @@ -73,7 +73,7 @@ public async Task InvalidAuthenticateRequestTest_InvalidToken() string deviceId = "device_2"; string moduleId = "module_1"; var httpContext = new DefaultHttpContext(); - httpContext.Request.Headers.Add(HeaderNames.Authorization, new StringValues("invalidSasToken")); + httpContext.Request.Headers.Append(HeaderNames.Authorization, new StringValues("invalidSasToken")); httpContext.Request.QueryString = new QueryString("?api-version=2017-10-20"); var authenticator = new Mock(); @@ -96,7 +96,7 @@ public async Task InvalidAuthenticateRequestTest_TokenExpired() string moduleId = "module_1"; var httpContext = new DefaultHttpContext(); string sasToken = TokenHelper.CreateSasToken($"{iothubHostName}/devices/{deviceId}/modules/{moduleId}", expired: true); - httpContext.Request.Headers.Add(HeaderNames.Authorization, new StringValues(sasToken)); + httpContext.Request.Headers.Append(HeaderNames.Authorization, new StringValues(sasToken)); httpContext.Request.QueryString = new QueryString("?api-version=2017-10-20"); var authenticator = new Mock(); @@ -119,7 +119,7 @@ public async Task AuthenticateRequestTest_NoApiVersion_Success() string moduleId = "module_1"; var httpContext = new DefaultHttpContext(); string sasToken = TokenHelper.CreateSasToken($"{iothubHostName}/devices/{deviceId}/modules/{moduleId}"); - httpContext.Request.Headers.Add(HeaderNames.Authorization, new StringValues(sasToken)); + httpContext.Request.Headers.Append(HeaderNames.Authorization, new StringValues(sasToken)); var authenticator = new Mock(); authenticator.Setup(a => a.AuthenticateAsync(It.IsAny())).ReturnsAsync(true); @@ -141,7 +141,7 @@ public async Task InvalidCredentialsRequestTest_AuthFailed() string moduleId = "module_1"; var httpContext = new DefaultHttpContext(); string sasToken = TokenHelper.CreateSasToken($"{iothubHostName}/devices/{deviceId}/modules/{moduleId}"); - httpContext.Request.Headers.Add(HeaderNames.Authorization, new StringValues(sasToken)); + httpContext.Request.Headers.Append(HeaderNames.Authorization, new StringValues(sasToken)); httpContext.Request.QueryString = new QueryString("?api-version=2017-10-20"); var authenticator = new Mock(); @@ -186,7 +186,7 @@ public async Task AuthenticateRequestTestX509IgnoresAuthorizationHeader_Success( string moduleId = "module_1"; var httpContext = new DefaultHttpContext(); var clientCert = CertificateHelper.GenerateSelfSignedCert($"test_cert"); - httpContext.Request.Headers.Add(HeaderNames.Authorization, new StringValues("blah")); + httpContext.Request.Headers.Append(HeaderNames.Authorization, new StringValues("blah")); httpContext.Request.QueryString = new QueryString("?api-version=2017-10-20"); httpContext.Connection.ClientCertificate = clientCert; var authenticator = new Mock(); @@ -215,8 +215,8 @@ public async Task AuthenticateRequestTestX509ApiProxyForward_CheckProxyAuthoriza string clientCertString = $"-----BEGIN CERTIFICATE-----\n{certContentBase64}\n-----END CERTIFICATE-----\n"; clientCertString = WebUtility.UrlEncode(clientCertString); string sasToken = TokenHelper.CreateSasToken($"{iothubHostName}/devices/{deviceId}/modules/{apiProxyId}"); - httpContext.Request.Headers.Add(Constants.ClientCertificateHeaderKey, new StringValues(clientCertString)); - httpContext.Request.Headers.Add(HeaderNames.Authorization, new StringValues(sasToken)); + httpContext.Request.Headers.Append(Constants.ClientCertificateHeaderKey, new StringValues(clientCertString)); + httpContext.Request.Headers.Append(HeaderNames.Authorization, new StringValues(sasToken)); httpContext.Request.QueryString = new QueryString("?api-version=2017-10-20"); var authenticator = new Mock(); authenticator.Setup(a => a.AuthenticateAsync(It.IsAny())).ReturnsAsync(true); @@ -246,7 +246,7 @@ public async Task AuthenticateRequestTestX509ApiProxyForward_NoProxyAuthorizatio string certContentBase64 = Convert.ToBase64String(certContentBytes); string clientCertString = $"-----BEGIN CERTIFICATE-----\n{certContentBase64}\n-----END CERTIFICATE-----\n"; clientCertString = WebUtility.UrlEncode(clientCertString); - httpContext.Request.Headers.Add(Constants.ClientCertificateHeaderKey, new StringValues(clientCertString)); + httpContext.Request.Headers.Append(Constants.ClientCertificateHeaderKey, new StringValues(clientCertString)); httpContext.Request.QueryString = new QueryString("?api-version=2017-10-20"); var authenticator = new Mock(); authenticator.Setup(a => a.AuthenticateAsync(It.IsAny())).ReturnsAsync(true); @@ -269,7 +269,7 @@ public async Task AuthenticateRequestX509Test_NoApiVersion_Success() string moduleId = "module_1"; var httpContext = new DefaultHttpContext(); var clientCert = CertificateHelper.GenerateSelfSignedCert($"test_cert"); - httpContext.Request.Headers.Add(HeaderNames.Authorization, new StringValues("blah")); + httpContext.Request.Headers.Append(HeaderNames.Authorization, new StringValues("blah")); httpContext.Connection.ClientCertificate = clientCert; var authenticator = new Mock(); authenticator.Setup(a => a.AuthenticateAsync(It.IsAny())).ReturnsAsync(true); diff --git a/edge-hub/core/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/TwinsControllerTest.cs b/edge-hub/core/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/TwinsControllerTest.cs index 2c2f0a461b6..fd1343ee145 100644 --- a/edge-hub/core/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/TwinsControllerTest.cs +++ b/edge-hub/core/test/Microsoft.Azure.Devices.Edge.Hub.Http.Test/TwinsControllerTest.cs @@ -33,7 +33,7 @@ public async Task InvokeDeviceMethodNoPayloadReturnsOk() { string toDeviceId = "device1"; var sut = SetupControllerToRespond(toDeviceId, Option.None(), 200, new byte[0]); - sut.HttpContext.Request.Headers.Add(Constants.ServiceApiIdHeaderKey, actorId); + sut.HttpContext.Request.Headers.Append(Constants.ServiceApiIdHeaderKey, actorId); string command = "showdown"; string payload = "{ \"prop1\" : \"value1\" }"; @@ -54,7 +54,7 @@ public async Task InvokeModuleMethodNoPayloadReturnsOk() string toDeviceId = "edgedevice"; string toModuleId = "module2"; var sut = SetupControllerToRespond(toDeviceId, Option.Some(toModuleId), 200, new byte[0]); - sut.HttpContext.Request.Headers.Add(Constants.ServiceApiIdHeaderKey, actorId); + sut.HttpContext.Request.Headers.Append(Constants.ServiceApiIdHeaderKey, actorId); string command = "showdown"; string payload = "{ \"prop1\" : \"value1\" }"; @@ -77,7 +77,7 @@ public async Task InvokeDeviceMethodExpectPayloadReturnsOk() var responsePayloadBytes = Encoding.UTF8.GetBytes(reponsePayloadJson); var sut = SetupControllerToRespond(toDeviceId, Option.None(), 200, responsePayloadBytes); - sut.HttpContext.Request.Headers.Add(Constants.ServiceApiIdHeaderKey, actorId); + sut.HttpContext.Request.Headers.Append(Constants.ServiceApiIdHeaderKey, actorId); string command = "showdown"; string cmdPayload = "{ \"prop1\" : \"value1\" }"; @@ -101,7 +101,7 @@ public async Task InvokeModuleMethodExpectPayloadReturnsOk() var responsePayloadBytes = Encoding.UTF8.GetBytes(reponsePayloadJson); var sut = SetupControllerToRespond(toDeviceId, Option.Some(toModuleId), 200, responsePayloadBytes); - sut.HttpContext.Request.Headers.Add(Constants.ServiceApiIdHeaderKey, actorId); + sut.HttpContext.Request.Headers.Append(Constants.ServiceApiIdHeaderKey, actorId); string command = "showdown"; string payload = "{ \"prop1\" : \"value1\" }"; @@ -136,7 +136,7 @@ public async Task ActorNotModuleReturnsError() { string toDeviceId = "device1"; var sut = SetupControllerToRespond(toDeviceId, Option.None(), 200, new byte[0]); - sut.HttpContext.Request.Headers.Add(Constants.ServiceApiIdHeaderKey, $"{actorDevice}"); + sut.HttpContext.Request.Headers.Append(Constants.ServiceApiIdHeaderKey, $"{actorDevice}"); string command = "showdown"; string payload = "{ \"prop1\" : \"value1\" }"; @@ -152,7 +152,7 @@ public async Task ActorTargetDeviceMismatchReturnsError() { string toDeviceId = "device1"; var sut = SetupControllerToRespond(toDeviceId, Option.None(), 200, new byte[0]); - sut.HttpContext.Request.Headers.Add(Constants.ServiceApiIdHeaderKey, $"differentEdge/module1"); + sut.HttpContext.Request.Headers.Append(Constants.ServiceApiIdHeaderKey, $"differentEdge/module1"); string command = "showdown"; string payload = "{ \"prop1\" : \"value1\" }"; @@ -168,7 +168,7 @@ public async Task InvokeDeviceMethodThrowingReturnsError() { string toDeviceId = "device1"; var sut = SetupControllerToThrow(toDeviceId, Option.None(), HttpStatusCode.GatewayTimeout, new EdgeHubTimeoutException("EdgeHub timed out")); - sut.HttpContext.Request.Headers.Add(Constants.ServiceApiIdHeaderKey, actorId); + sut.HttpContext.Request.Headers.Append(Constants.ServiceApiIdHeaderKey, actorId); string command = "showdown"; string cmdPayload = "{ \"prop1\" : \"value1\" }"; @@ -195,7 +195,7 @@ public async Task InvokeModuleMethodMultibyteContentSetsContentLength() Assert.True(reponsePayloadJson.Length != responsePayloadBytes.Length); var sut = SetupControllerToRespond(toDeviceId, Option.Some(toModuleId), 200, responsePayloadBytes); - sut.HttpContext.Request.Headers.Add(Constants.ServiceApiIdHeaderKey, actorId); + sut.HttpContext.Request.Headers.Append(Constants.ServiceApiIdHeaderKey, actorId); string command = "showdown"; string payload = "{ \"prop1\" : \"value1\" }"; diff --git a/edge-hub/docker/linux/Dockerfile b/edge-hub/docker/linux/Dockerfile index 5f498662bcd..6d94718b239 100644 --- a/edge-hub/docker/linux/Dockerfile +++ b/edge-hub/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine ARG EXE_DIR=. ARG TARGETPLATFORM diff --git a/edge-modules/SimulatedTemperatureSensor/SimulatedTemperatureSensor.csproj b/edge-modules/SimulatedTemperatureSensor/SimulatedTemperatureSensor.csproj index a525dd3abed..ff319deeac0 100644 --- a/edge-modules/SimulatedTemperatureSensor/SimulatedTemperatureSensor.csproj +++ b/edge-modules/SimulatedTemperatureSensor/SimulatedTemperatureSensor.csproj @@ -14,13 +14,7 @@ - - - + diff --git a/edge-modules/SimulatedTemperatureSensor/docker/linux/Dockerfile b/edge-modules/SimulatedTemperatureSensor/docker/linux/Dockerfile index 9612e982840..01dfabafcff 100644 --- a/edge-modules/SimulatedTemperatureSensor/docker/linux/Dockerfile +++ b/edge-modules/SimulatedTemperatureSensor/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ARG EXE_DIR=. 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 a2f92f4ea83..d276d9b681e 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 @@ -33,7 +33,7 @@ - + - + diff --git a/edge-modules/iotedge-diagnostics-dotnet/docker/linux/Dockerfile b/edge-modules/iotedge-diagnostics-dotnet/docker/linux/Dockerfile index b3b575e316a..48e85c14aea 100644 --- a/edge-modules/iotedge-diagnostics-dotnet/docker/linux/Dockerfile +++ b/edge-modules/iotedge-diagnostics-dotnet/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ARG EXE_DIR=. diff --git a/edge-modules/metrics-collector/docker/linux/Dockerfile b/edge-modules/metrics-collector/docker/linux/Dockerfile index 60cb61fa2e4..7e76ae82bf0 100755 --- a/edge-modules/metrics-collector/docker/linux/Dockerfile +++ b/edge-modules/metrics-collector/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ARG EXE_DIR=. diff --git a/edge-modules/metrics-collector/src/Microsoft.Azure.Devices.Edge.Azure.Monitor.csproj b/edge-modules/metrics-collector/src/Microsoft.Azure.Devices.Edge.Azure.Monitor.csproj index 635288ea25c..19a66dc8309 100755 --- a/edge-modules/metrics-collector/src/Microsoft.Azure.Devices.Edge.Azure.Monitor.csproj +++ b/edge-modules/metrics-collector/src/Microsoft.Azure.Devices.Edge.Azure.Monitor.csproj @@ -13,13 +13,7 @@ - - - + diff --git a/netcoreappVersion.props b/netcoreappVersion.props index 11938b1c240..fa67997ec8e 100644 --- a/netcoreappVersion.props +++ b/netcoreappVersion.props @@ -1,5 +1,5 @@ - net6.0 + net8.0 \ No newline at end of file diff --git a/samples/dotnet/EdgeDownstreamDevice/EdgeDownstreamDevice.csproj b/samples/dotnet/EdgeDownstreamDevice/EdgeDownstreamDevice.csproj index 25824dd4e6a..697d41602d5 100644 --- a/samples/dotnet/EdgeDownstreamDevice/EdgeDownstreamDevice.csproj +++ b/samples/dotnet/EdgeDownstreamDevice/EdgeDownstreamDevice.csproj @@ -9,24 +9,12 @@ - + - - - - diff --git a/samples/dotnet/EdgeX509AuthDownstreamDevice/EdgeX509AuthDownstreamDevice.csproj b/samples/dotnet/EdgeX509AuthDownstreamDevice/EdgeX509AuthDownstreamDevice.csproj index 321b63d96df..dbe01332b22 100644 --- a/samples/dotnet/EdgeX509AuthDownstreamDevice/EdgeX509AuthDownstreamDevice.csproj +++ b/samples/dotnet/EdgeX509AuthDownstreamDevice/EdgeX509AuthDownstreamDevice.csproj @@ -9,25 +9,13 @@ - + - - - - diff --git a/scripts/linux/buildBranch.sh b/scripts/linux/buildBranch.sh index 433f4f90186..b4c766fde03 100755 --- a/scripts/linux/buildBranch.sh +++ b/scripts/linux/buildBranch.sh @@ -22,7 +22,7 @@ SRC_E2E_TEST_FILES_DIR=$ROOT_FOLDER/e2e_test_files 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 -DOTNET_RUNTIME=net6.0 +DOTNET_RUNTIME=net8.0 SKIP_QUICKSTART=0 usage() @@ -32,7 +32,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 " --dotnet_runtime Set the dotnet_runtime version to build. (Default net6.0)" + echo " --dotnet_runtime Set the dotnet_runtime version to build. (Default net8.0)" echo " --skip-quickstart Do not build the quickstart test tool or copy {e2e_deployment_files,e2e_test_files}" exit 1; } @@ -127,10 +127,9 @@ publish_project() { local type="$1" local name="$2" - local framework="$3" - local config="$4" - local output="$5" - local option="$6" + local config="$3" + local output="$4" + local option="$5" local path=$(find $ROOT_FOLDER -type f -name $name.csproj) if [ -z "$path" ]; then @@ -139,8 +138,7 @@ publish_project() fi echo "Publishing $type '$name'" - echo "$DOTNET_ROOT_PATH/dotnet publish -f $framework -p:DotNet_Runtime=$DOTNET_RUNTIME -c $config $option -o $output $path" - $DOTNET_ROOT_PATH/dotnet publish -f $framework -p:DotNet_Runtime=$DOTNET_RUNTIME -c $config $option -o $output $path + $DOTNET_ROOT_PATH/dotnet publish -c $config $option -o $output $path if [ $? -gt 0 ]; then RES=1 @@ -150,21 +148,13 @@ publish_project() publish_app() { local name="$1" - local dotnet_runtime="$2" - - if [ -z "$dotnet_runtime" ] - then - dotnet_runtime=$DOTNET_RUNTIME - fi - - publish_project app \ - "$name" $dotnet_runtime $CONFIGURATION "$PUBLISH_FOLDER/$name" $MSBUILD_OPTIONS + publish_project app "$name" $CONFIGURATION "$PUBLISH_FOLDER/$name" $MSBUILD_OPTIONS } publish_lib() { local name="$1" - publish_project library "$name" net6.0 $CONFIGURATION "$PUBLISH_FOLDER/$name" + publish_project library "$name" $CONFIGURATION "$PUBLISH_FOLDER/$name" } publish_quickstart() @@ -212,14 +202,7 @@ build_solution() echo "Building IoT Edge solution" dotnet --version - build_command="$DOTNET_ROOT_PATH/dotnet build -c $CONFIGURATION -o \"$BUILD_BINARIESDIRECTORY\"" - - if [ -n "$DOTNET_RUNTIME" ]; then - build_command="$build_command -p:DotNet_Runtime=$DOTNET_RUNTIME" - fi - build_command="$build_command $ROOT_FOLDER/Microsoft.Azure.Devices.Edge.sln" - - eval ${build_command} + $DOTNET_ROOT_PATH/dotnet build -c $CONFIGURATION $ROOT_FOLDER/Microsoft.Azure.Devices.Edge.sln if [ $? -gt 0 ]; then RES=1 fi diff --git a/scripts/linux/runTests.sh b/scripts/linux/runTests.sh index ccbc74a2403..fa480df4b42 100755 --- a/scripts/linux/runTests.sh +++ b/scripts/linux/runTests.sh @@ -1,99 +1,30 @@ #!/bin/bash -# This script runs all the .Net Core test projects (*test*.csproj) in the -# repo by looking up build output from previous build step. -# This script expects that .Net Core is installed at -# $AGENT_WORKFOLDER/dotnet and output binaries are at $BUILD_BINARIESDIRECTORY +# This script runs all the .NET test projects (*test*.csproj) in the repo using +# binaries built previously (see buildBranch.sh). -# Get directory of running script -DIR=$(cd "$(dirname "$0")" && pwd) - -# Check if Environment variables are set. -BUILD_REPOSITORY_LOCALPATH=${BUILD_REPOSITORY_LOCALPATH:-$DIR/../..} -AGENT_WORKFOLDER=${AGENT_WORKFOLDER:-/usr/share} -BUILD_BINARIESDIRECTORY=${BUILD_BINARIESDIRECTORY:-$BUILD_REPOSITORY_LOCALPATH/target} - -# Process script arguments TEST_FILTER="$1" BUILD_CONFIG="$2" -SUFFIX='Microsoft.Azure*test.dll' -OUTPUT_FOLDER=$BUILD_BINARIESDIRECTORY - -if [ ! -f "$DOTNET_ROOT_PATH" ]; then - dotnet_path=$(command -v dotnet) - if [ $? -eq 0 ]; then - DOTNET_ROOT_PATH=$(dirname $dotnet_path) - elif [ -f "$AGENT_WORKFOLDER/dotnet/dotnet" ]; then # VSTS Linux - DOTNET_ROOT_PATH="$AGENT_WORKFOLDER/dotnet" - elif [ -f "/usr/share/dotnet/dotnet" ]; then # default Linux - DOTNET_ROOT_PATH="/usr/share/dotnet" - elif [ -f "/usr/local/share/dotnet/dotnet" ]; then # default macOS - DOTNET_ROOT_PATH="/usr/local/share/dotnet" - else - echo "dotnet not found" 1>&2 - exit 1 - fi -fi - -if [ ! -d "$BUILD_BINARIESDIRECTORY" ]; then - echo "Path $BUILD_BINARIESDIRECTORY does not exist" 1>&2 - exit 1 -fi - -testFilterValue="${TEST_FILTER#--filter }" - if [ -z "$BUILD_CONFIG" ] then BUILD_CONFIG="CheckInBuild" fi -echo "Running tests in all test projects with filter: $testFilterValue and $BUILD_CONFIG configuration" - -# Find all test project dlls -testProjectRunSerially=( "Microsoft.Azure.Devices.Edge.Agent.Docker.Test.dll" ) -testProjectDllsRunSerially=() -testProjectDlls="" - -while read testDll; do - echo "Try to run test project:$testDll" - - if (for t in "${testProjectRunSerially[@]}"; do [[ $testDll == */$t ]] && exit 0; done) - then - echo "Run Serially for $testDll" - testProjectDllsRunSerially+=($testDll) - else - testProjectDlls="$testProjectDlls $testDll" - fi -done < <(find $OUTPUT_FOLDER -type f -iname $SUFFIX -not -path "$OUTPUT_FOLDER/bin/*") - -testCommandPrefix="$DOTNET_ROOT_PATH/dotnet vstest /Logger:trx;LogFileName=result.trx /TestAdapterPath:\"$OUTPUT_FOLDER\" /Parallel /InIsolation" -if [ ! -z "$testFilterValue" ] -then - testCommandPrefix+=" /TestCaseFilter:"$testFilterValue"" -fi - -for testDll in ${testProjectDllsRunSerially[@]} -do - testCommand="$testCommandPrefix $testDll" - testCommand=${testCommand/result.trx/$(basename "$testDll" ".dll").trx} - echo "Run test command serially:$testCommand" - $testCommand - - if [ $? -gt 0 ] - then - exit 1 - fi -done - -testCommand="$testCommandPrefix$testProjectDlls" -testCommand=${testCommand/result.trx/$(mktemp result.XXXXXXXX.trx)} -echo "Run test command:$testCommand" -$testCommand - -if [ $? -gt 0 ] -then - exit 1 -fi - -exit 0 +run_tests() +{ + local project="$1" + dotnet test $project \ + --configuration $BUILD_CONFIG \ + --filter "$TEST_FILTER" \ + --logger "trx;LogFileName=$(basename "$testProject").trx" \ + --no-build +} + +echo "Running tests with filter: '$TEST_FILTER' and configuration: '$BUILD_CONFIG'" + +while read testProject; do + testPath="$(dirname $testProject)" + echo "Found test project: $testPath" + run_tests $testPath +done < <(find . -iname '*.Test.csproj') diff --git a/smoke/IotEdgeQuickstart/IotEdgeQuickstart.csproj b/smoke/IotEdgeQuickstart/IotEdgeQuickstart.csproj index 3867164d8f6..0fd7e5d0a0b 100644 --- a/smoke/IotEdgeQuickstart/IotEdgeQuickstart.csproj +++ b/smoke/IotEdgeQuickstart/IotEdgeQuickstart.csproj @@ -10,7 +10,7 @@ - + diff --git a/smoke/LeafDevice/LeafDevice.csproj b/smoke/LeafDevice/LeafDevice.csproj index 731c265e9fc..5bff0abafd3 100644 --- a/smoke/LeafDevice/LeafDevice.csproj +++ b/smoke/LeafDevice/LeafDevice.csproj @@ -10,8 +10,8 @@ - - + + 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 c9c564e0bba..7f7ffb96242 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 @@ -8,8 +8,8 @@ - - + + diff --git a/test/Microsoft.Azure.Devices.Edge.Test/EdgeAgentDirectMethods.cs b/test/Microsoft.Azure.Devices.Edge.Test/EdgeAgentDirectMethods.cs index 61f24694683..6bd44df4e87 100644 --- a/test/Microsoft.Azure.Devices.Edge.Test/EdgeAgentDirectMethods.cs +++ b/test/Microsoft.Azure.Devices.Edge.Test/EdgeAgentDirectMethods.cs @@ -214,7 +214,7 @@ await this.runtime.DeployConfigurationAsync( filter = new { }, }, encoding = 0, - contentYtpe = 1, + contentType = 1, sasUrl, }; diff --git a/test/connectivity/modules/NetworkController/CommandExecutionException.cs b/test/connectivity/modules/NetworkController/CommandExecutionException.cs index 240916ca9a2..1cedf52a594 100644 --- a/test/connectivity/modules/NetworkController/CommandExecutionException.cs +++ b/test/connectivity/modules/NetworkController/CommandExecutionException.cs @@ -4,7 +4,6 @@ namespace NetworkController using System; using System.Runtime.Serialization; - [Serializable] class CommandExecutionException : Exception { public CommandExecutionException() @@ -20,10 +19,5 @@ public CommandExecutionException(string message, Exception innerException) : base(message, innerException) { } - - protected CommandExecutionException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } diff --git a/test/connectivity/modules/NetworkController/TestInitializationException.cs b/test/connectivity/modules/NetworkController/TestInitializationException.cs index 459b81f7430..d0d0208f00d 100644 --- a/test/connectivity/modules/NetworkController/TestInitializationException.cs +++ b/test/connectivity/modules/NetworkController/TestInitializationException.cs @@ -4,7 +4,6 @@ namespace NetworkController using System; using System.Runtime.Serialization; - [Serializable] class TestInitializationException : Exception { public TestInitializationException() @@ -20,10 +19,5 @@ public TestInitializationException(string message, Exception innerException) : base(message, innerException) { } - - protected TestInitializationException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } diff --git a/test/connectivity/modules/NetworkController/TestShutdownException.cs b/test/connectivity/modules/NetworkController/TestShutdownException.cs index 1cc70518ac3..3a2a05a6dcb 100644 --- a/test/connectivity/modules/NetworkController/TestShutdownException.cs +++ b/test/connectivity/modules/NetworkController/TestShutdownException.cs @@ -4,7 +4,6 @@ namespace NetworkController using System; using System.Runtime.Serialization; - [Serializable] class TestShutdownException : Exception { public TestShutdownException() @@ -20,10 +19,5 @@ public TestShutdownException(string message, Exception innerException) : base(message, innerException) { } - - protected TestShutdownException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } diff --git a/test/connectivity/modules/NetworkController/docker/linux/Dockerfile b/test/connectivity/modules/NetworkController/docker/linux/Dockerfile index 7f71aeb04ce..b6e0eed9713 100644 --- a/test/connectivity/modules/NetworkController/docker/linux/Dockerfile +++ b/test/connectivity/modules/NetworkController/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ARG EXE_DIR=. diff --git a/test/modules/CloudToDeviceMessageTester/CloudToDeviceMessageTester.csproj b/test/modules/CloudToDeviceMessageTester/CloudToDeviceMessageTester.csproj index 2a87781f327..374ccfe3ef2 100644 --- a/test/modules/CloudToDeviceMessageTester/CloudToDeviceMessageTester.csproj +++ b/test/modules/CloudToDeviceMessageTester/CloudToDeviceMessageTester.csproj @@ -14,8 +14,8 @@ - - + + diff --git a/test/modules/CloudToDeviceMessageTester/docker/linux/Dockerfile b/test/modules/CloudToDeviceMessageTester/docker/linux/Dockerfile index 53df3af4152..d540a9ce191 100644 --- a/test/modules/CloudToDeviceMessageTester/docker/linux/Dockerfile +++ b/test/modules/CloudToDeviceMessageTester/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ARG EXE_DIR=. diff --git a/test/modules/DeploymentTester/DeploymentTester.csproj b/test/modules/DeploymentTester/DeploymentTester.csproj index c6fa4380d7d..845ca88be8c 100644 --- a/test/modules/DeploymentTester/DeploymentTester.csproj +++ b/test/modules/DeploymentTester/DeploymentTester.csproj @@ -14,7 +14,7 @@ - + diff --git a/test/modules/DeploymentTester/docker/linux/Dockerfile b/test/modules/DeploymentTester/docker/linux/Dockerfile index 508ddcd04c7..4b6313c62f7 100644 --- a/test/modules/DeploymentTester/docker/linux/Dockerfile +++ b/test/modules/DeploymentTester/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ARG EXE_DIR=. diff --git a/test/modules/DirectMethodReceiver/DirectMethodReceiver.csproj b/test/modules/DirectMethodReceiver/DirectMethodReceiver.csproj index 41e75da46b1..f34bd79982d 100644 --- a/test/modules/DirectMethodReceiver/DirectMethodReceiver.csproj +++ b/test/modules/DirectMethodReceiver/DirectMethodReceiver.csproj @@ -13,7 +13,7 @@ - + diff --git a/test/modules/DirectMethodReceiver/docker/linux/Dockerfile b/test/modules/DirectMethodReceiver/docker/linux/Dockerfile index a73d3e11bb7..60d0171a2ac 100644 --- a/test/modules/DirectMethodReceiver/docker/linux/Dockerfile +++ b/test/modules/DirectMethodReceiver/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ARG EXE_DIR=. diff --git a/test/modules/DirectMethodSender/DirectMethodSender.csproj b/test/modules/DirectMethodSender/DirectMethodSender.csproj index 2cb85ad65c3..7836b9e3cca 100644 --- a/test/modules/DirectMethodSender/DirectMethodSender.csproj +++ b/test/modules/DirectMethodSender/DirectMethodSender.csproj @@ -14,8 +14,8 @@ - - + + diff --git a/test/modules/DirectMethodSender/docker/linux/Dockerfile b/test/modules/DirectMethodSender/docker/linux/Dockerfile index 1321542f266..ef8b1c9e9a4 100644 --- a/test/modules/DirectMethodSender/docker/linux/Dockerfile +++ b/test/modules/DirectMethodSender/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ARG EXE_DIR=. diff --git a/test/modules/EdgeHubRestartTester/EdgeHubRestartTester.csproj b/test/modules/EdgeHubRestartTester/EdgeHubRestartTester.csproj index 3a57561484f..1c82f7c0279 100644 --- a/test/modules/EdgeHubRestartTester/EdgeHubRestartTester.csproj +++ b/test/modules/EdgeHubRestartTester/EdgeHubRestartTester.csproj @@ -27,8 +27,8 @@ - - + + diff --git a/test/modules/EdgeHubRestartTester/docker/linux/Dockerfile b/test/modules/EdgeHubRestartTester/docker/linux/Dockerfile index 1c3d8d9213a..8873bfe537d 100644 --- a/test/modules/EdgeHubRestartTester/docker/linux/Dockerfile +++ b/test/modules/EdgeHubRestartTester/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ARG EXE_DIR=. diff --git a/test/modules/MetricsValidator/MetricsValidator.csproj b/test/modules/MetricsValidator/MetricsValidator.csproj index 23389eeb920..f18cd8c2aea 100644 --- a/test/modules/MetricsValidator/MetricsValidator.csproj +++ b/test/modules/MetricsValidator/MetricsValidator.csproj @@ -14,7 +14,7 @@ - + diff --git a/test/modules/MetricsValidator/docker/linux/Dockerfile b/test/modules/MetricsValidator/docker/linux/Dockerfile index 207f23941f7..bbfb8621a2f 100644 --- a/test/modules/MetricsValidator/docker/linux/Dockerfile +++ b/test/modules/MetricsValidator/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ARG EXE_DIR=. diff --git a/test/modules/MetricsValidator/src/tests/ValidateMessages.cs b/test/modules/MetricsValidator/src/tests/ValidateMessages.cs index c83fc3799ad..67276d8692b 100644 --- a/test/modules/MetricsValidator/src/tests/ValidateMessages.cs +++ b/test/modules/MetricsValidator/src/tests/ValidateMessages.cs @@ -12,7 +12,6 @@ namespace MetricsValidator.Tests using Microsoft.Azure.Devices.Client; using Microsoft.Azure.Devices.Edge.Agent.Diagnostics; using Microsoft.Azure.Devices.Edge.Util; - using Microsoft.WindowsAzure.Storage.Table; public class ValidateMessages : TestBase { diff --git a/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj b/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj index b4dbacf1706..1181bdd9834 100644 --- a/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj +++ b/test/modules/ModuleLib/Microsoft.Azure.Devices.Edge.ModuleUtil.csproj @@ -3,13 +3,7 @@ - - - + diff --git a/test/modules/ModuleRestarter/ModuleRestarter.csproj b/test/modules/ModuleRestarter/ModuleRestarter.csproj index 163bfbdd0e2..9a3c85d0b06 100644 --- a/test/modules/ModuleRestarter/ModuleRestarter.csproj +++ b/test/modules/ModuleRestarter/ModuleRestarter.csproj @@ -14,8 +14,8 @@ - - + + diff --git a/test/modules/ModuleRestarter/docker/linux/Dockerfile b/test/modules/ModuleRestarter/docker/linux/Dockerfile index a6501d083f6..ad943af219a 100644 --- a/test/modules/ModuleRestarter/docker/linux/Dockerfile +++ b/test/modules/ModuleRestarter/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ARG EXE_DIR=. diff --git a/test/modules/NumberLogger/docker/linux/Dockerfile b/test/modules/NumberLogger/docker/linux/Dockerfile index 7868126f559..ef79dab5a79 100644 --- a/test/modules/NumberLogger/docker/linux/Dockerfile +++ b/test/modules/NumberLogger/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ARG EXE_DIR=. diff --git a/test/modules/Relayer/Relayer.csproj b/test/modules/Relayer/Relayer.csproj index fd3c43ff148..455ac70bf96 100644 --- a/test/modules/Relayer/Relayer.csproj +++ b/test/modules/Relayer/Relayer.csproj @@ -14,7 +14,7 @@ - + diff --git a/test/modules/Relayer/docker/linux/Dockerfile b/test/modules/Relayer/docker/linux/Dockerfile index 785b071a41b..3b1c8166e2a 100644 --- a/test/modules/Relayer/docker/linux/Dockerfile +++ b/test/modules/Relayer/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ARG EXE_DIR=. diff --git a/test/modules/TemperatureFilter/TemperatureFilter.csproj b/test/modules/TemperatureFilter/TemperatureFilter.csproj index 3aeb804b6cf..b71cc347358 100644 --- a/test/modules/TemperatureFilter/TemperatureFilter.csproj +++ b/test/modules/TemperatureFilter/TemperatureFilter.csproj @@ -14,7 +14,7 @@ - + diff --git a/test/modules/TemperatureFilter/docker/linux/Dockerfile b/test/modules/TemperatureFilter/docker/linux/Dockerfile index c84548511a9..c9b837d2121 100644 --- a/test/modules/TemperatureFilter/docker/linux/Dockerfile +++ b/test/modules/TemperatureFilter/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ARG EXE_DIR=. diff --git a/test/modules/TestAnalyzer/TestAnalyzer.csproj b/test/modules/TestAnalyzer/TestAnalyzer.csproj index 5a6dc88a1c4..e2a8103842e 100644 --- a/test/modules/TestAnalyzer/TestAnalyzer.csproj +++ b/test/modules/TestAnalyzer/TestAnalyzer.csproj @@ -19,7 +19,7 @@ - + diff --git a/test/modules/TestAnalyzer/docker/linux/Dockerfile b/test/modules/TestAnalyzer/docker/linux/Dockerfile index 1b5a3013499..5ca951bb4ba 100644 --- a/test/modules/TestAnalyzer/docker/linux/Dockerfile +++ b/test/modules/TestAnalyzer/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine ARG EXE_DIR=. ARG TARGETPLATFORM diff --git a/test/modules/TestMetricsCollector/TestMetricsCollector.csproj b/test/modules/TestMetricsCollector/TestMetricsCollector.csproj index 5469fcf99dd..98378152401 100644 --- a/test/modules/TestMetricsCollector/TestMetricsCollector.csproj +++ b/test/modules/TestMetricsCollector/TestMetricsCollector.csproj @@ -14,7 +14,7 @@ - + diff --git a/test/modules/TestMetricsCollector/docker/linux/Dockerfile b/test/modules/TestMetricsCollector/docker/linux/Dockerfile index 0f637271d32..35c417e1a2b 100644 --- a/test/modules/TestMetricsCollector/docker/linux/Dockerfile +++ b/test/modules/TestMetricsCollector/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ARG EXE_DIR=. diff --git a/test/modules/TestResultCoordinator/TestReportUtil.cs b/test/modules/TestResultCoordinator/TestReportUtil.cs index e10d9a571d0..b3534751a2e 100644 --- a/test/modules/TestResultCoordinator/TestReportUtil.cs +++ b/test/modules/TestResultCoordinator/TestReportUtil.cs @@ -6,11 +6,10 @@ namespace TestResultCoordinator using System.Linq; using System.Threading.Tasks; using Azure.Storage.Blobs; + using Azure.Storage.Sas; using Microsoft.Azure.Devices; using Microsoft.Azure.Devices.Edge.Util; using Microsoft.Extensions.Logging; - using Microsoft.WindowsAzure.Storage; - using Microsoft.WindowsAzure.Storage.Blob; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using TestResultCoordinator.Reports; @@ -139,9 +138,7 @@ internal static async Task GetOrCreateBlobContainerSasUriForLogAsync(string await containerClient.CreateAsync(); } - CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageAccountConnectionString); - var container = new CloudBlobContainer(containerClient.Uri, storageAccount.Credentials); - return GetContainerSasUri(container); + return GetContainerSasUri(containerClient); } internal static async Task UploadLogsAsync(string iotHubConnectionString, Uri blobContainerWriteUri, Option logUploadDuration, ILogger logger) @@ -224,18 +221,12 @@ static string GetAzureBlobContainerNameForLog() return $"logs{DateTime.UtcNow.ToString("yyyyMMdd")}"; } - static Uri GetContainerSasUri(CloudBlobContainer container) + static Uri GetContainerSasUri(BlobContainerClient container) { - var adHocPolicy = new SharedAccessBlobPolicy() - { - // When the start time for the SAS is omitted, the start time is assumed to be the time when the storage service receives the request. - // Omitting the start time for a SAS that is effective immediately helps to avoid clock skew. - SharedAccessExpiryTime = DateTime.UtcNow.AddHours(1), - Permissions = SharedAccessBlobPermissions.Write | SharedAccessBlobPermissions.List - }; - - string sasContainerToken = container.GetSharedAccessSignature(adHocPolicy, null); - return new Uri(container.Uri + sasContainerToken); + var permissions = BlobContainerSasPermissions.Write | BlobContainerSasPermissions.List; + // When the start time for the SAS is omitted, the start time is assumed to be the time when the storage service receives the request. + // Omitting the start time for a SAS that is effective immediately helps to avoid clock skew. + return container.GenerateSasUri(permissions, DateTime.UtcNow.AddHours(1)); } enum UploadLogResponseStatus diff --git a/test/modules/TestResultCoordinator/TestResultCoordinator.csproj b/test/modules/TestResultCoordinator/TestResultCoordinator.csproj index 2bab9b10417..bc4a548b377 100644 --- a/test/modules/TestResultCoordinator/TestResultCoordinator.csproj +++ b/test/modules/TestResultCoordinator/TestResultCoordinator.csproj @@ -18,9 +18,9 @@ - + - + diff --git a/test/modules/TestResultCoordinator/docker/linux/Dockerfile b/test/modules/TestResultCoordinator/docker/linux/Dockerfile index 42d2700613d..02b59c3e161 100644 --- a/test/modules/TestResultCoordinator/docker/linux/Dockerfile +++ b/test/modules/TestResultCoordinator/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine ARG EXE_DIR=. ARG TARGETPLATFORM diff --git a/test/modules/TwinTester/TwinTester.csproj b/test/modules/TwinTester/TwinTester.csproj index cb558baad06..23df3de49d4 100644 --- a/test/modules/TwinTester/TwinTester.csproj +++ b/test/modules/TwinTester/TwinTester.csproj @@ -14,8 +14,8 @@ - - + + diff --git a/test/modules/TwinTester/docker/linux/Dockerfile b/test/modules/TwinTester/docker/linux/Dockerfile index 42b6dec959c..7983963f1d0 100644 --- a/test/modules/TwinTester/docker/linux/Dockerfile +++ b/test/modules/TwinTester/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ARG EXE_DIR=. ARG TARGETPLATFORM diff --git a/test/modules/load-gen/docker/linux/Dockerfile b/test/modules/load-gen/docker/linux/Dockerfile index 7aaf5df2217..9b38acf38df 100644 --- a/test/modules/load-gen/docker/linux/Dockerfile +++ b/test/modules/load-gen/docker/linux/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1.4 -FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine +FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine ARG EXE_DIR=. diff --git a/test/modules/load-gen/load-gen.csproj b/test/modules/load-gen/load-gen.csproj index 37b322efd86..e2709c1db8f 100644 --- a/test/modules/load-gen/load-gen.csproj +++ b/test/modules/load-gen/load-gen.csproj @@ -15,7 +15,7 @@ - +