Skip to content

Commit 4df619f

Browse files
committed
Update to dotnet 6
1 parent 0105f01 commit 4df619f

File tree

9 files changed

+33
-39
lines changed

9 files changed

+33
-39
lines changed

content/dotnet-template-azure-iot-edge-module/CSharp/Dockerfile.amd64

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build-env
1+
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
22
WORKDIR /app
33

44
COPY *.csproj ./
@@ -7,7 +7,7 @@ RUN dotnet restore
77
COPY . ./
88
RUN dotnet publish -c Release -o out
99

10-
FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim
10+
FROM mcr.microsoft.com/dotnet/runtime:6.0
1111
WORKDIR /app
1212
COPY --from=build-env /app/out ./
1313

content/dotnet-template-azure-iot-edge-module/CSharp/Dockerfile.amd64.debug

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base
1+
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
22

33
RUN apt-get update && \
44
apt-get install -y --no-install-recommends unzip procps && \
@@ -8,7 +8,7 @@ RUN useradd -ms /bin/bash moduleuser
88
USER moduleuser
99
RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg
1010

11-
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build-env
11+
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
1212
WORKDIR /app
1313

1414
COPY *.csproj ./

content/dotnet-template-azure-iot-edge-module/CSharp/Dockerfile.arm32v7

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster-arm32v7 AS build-env
1+
FROM mcr.microsoft.com/dotnet/sdk:6.0-bullseye-slim-arm32v7 AS build-env
22
WORKDIR /app
33

44
COPY *.csproj ./
@@ -7,7 +7,7 @@ RUN dotnet restore
77
COPY . ./
88
RUN dotnet publish -c Release -o out
99

10-
FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim-arm32v7
10+
FROM mcr.microsoft.com/dotnet/runtime:6.0-bullseye-slim-arm32v7
1111
WORKDIR /app
1212
COPY --from=build-env /app/out ./
1313

content/dotnet-template-azure-iot-edge-module/CSharp/Dockerfile.arm32v7.debug

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim-arm32v7 AS base
1+
FROM mcr.microsoft.com/dotnet/runtime:6.0-bullseye-slim-arm32v7 AS base
22

33
RUN apt-get update && \
44
apt-get install -y --no-install-recommends unzip procps && \
@@ -8,7 +8,7 @@ RUN useradd -ms /bin/bash moduleuser
88
USER moduleuser
99
RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg
1010

11-
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster-arm32v7 AS build-env
11+
FROM mcr.microsoft.com/dotnet/sdk:6.0-bullseye-slim-arm32v7 AS build-env
1212
WORKDIR /app
1313

1414
COPY *.csproj ./

content/dotnet-template-azure-iot-edge-module/CSharp/Dockerfile.arm64v8

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster-arm64v8 AS build-env
1+
FROM mcr.microsoft.com/dotnet/sdk:6.0-bullseye-slim-arm64v8 AS build-env
22
WORKDIR /app
33

44
COPY *.csproj ./
@@ -7,7 +7,7 @@ RUN dotnet restore
77
COPY . ./
88
RUN dotnet publish -c Release -o out
99

10-
FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim-arm64v8
10+
FROM mcr.microsoft.com/dotnet/runtime:6.0-bullseye-slim-arm64v8
1111
WORKDIR /app
1212
COPY --from=build-env /app/out ./
1313

content/dotnet-template-azure-iot-edge-module/CSharp/Dockerfile.arm64v8.debug

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim-arm64v8 AS base
1+
FROM mcr.microsoft.com/dotnet/runtime:6.0-bullseye-slim-arm64v8 AS base
22

33
RUN apt-get update && \
44
apt-get install -y --no-install-recommends unzip procps && \
@@ -8,7 +8,7 @@ RUN useradd -ms /bin/bash moduleuser
88
USER moduleuser
99
RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg
1010

11-
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster-arm64v8 AS build-env
11+
FROM mcr.microsoft.com/dotnet/sdk:6.0-bullseye-slim-arm64v8 AS build-env
1212
WORKDIR /app
1313

1414
COPY *.csproj ./
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-nanoserver-1809 AS build-env
1+
FROM mcr.microsoft.com/dotnet/sdk:6.0-nanoserver-ltsc2022 AS build-env
22
WORKDIR /app
33

44
COPY *.csproj ./
@@ -7,7 +7,7 @@ RUN dotnet restore
77
COPY . ./
88
RUN dotnet publish -c Release -o out
99

10-
FROM mcr.microsoft.com/dotnet/core/runtime:3.1-nanoserver-1809
10+
FROM mcr.microsoft.com/dotnet/runtime:6.0-nanoserver-ltsc2022
1111
WORKDIR /app
1212
COPY --from=build-env /app/out ./
1313
ENTRYPOINT ["dotnet", "SampleModule.dll"]

content/dotnet-template-azure-iot-edge-module/CSharp/Program.cs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
namespace SampleModule
22
{
3+
using Microsoft.Azure.Devices.Client;
4+
using Microsoft.Azure.Devices.Client.Transport.Mqtt;
35
using System;
4-
using System.IO;
5-
using System.Runtime.InteropServices;
66
using System.Runtime.Loader;
7-
using System.Security.Cryptography.X509Certificates;
87
using System.Text;
98
using System.Threading;
109
using System.Threading.Tasks;
11-
using Microsoft.Azure.Devices.Client;
12-
using Microsoft.Azure.Devices.Client.Transport.Mqtt;
1310

1411
class Program
1512
{
1613
static int counter;
1714

18-
static void Main(string[] args)
15+
static void Main()
1916
{
2017
Init().Wait();
2118

@@ -42,7 +39,7 @@ public static Task WhenCancelled(CancellationToken cancellationToken)
4239
/// </summary>
4340
static async Task Init()
4441
{
45-
MqttTransportSettings mqttSetting = new MqttTransportSettings(TransportType.Mqtt_Tcp_Only);
42+
MqttTransportSettings mqttSetting = new (TransportType.Mqtt_Tcp_Only);
4643
ITransportSettings[] settings = { mqttSetting };
4744

4845
// Open a connection to the Edge runtime
@@ -63,8 +60,7 @@ static async Task<MessageResponse> PipeMessage(Message message, object userConte
6360
{
6461
int counterValue = Interlocked.Increment(ref counter);
6562

66-
var moduleClient = userContext as ModuleClient;
67-
if (moduleClient == null)
63+
if (userContext is not ModuleClient moduleClient)
6864
{
6965
throw new InvalidOperationException("UserContext doesn't contain " + "expected values");
7066
}
@@ -75,16 +71,14 @@ static async Task<MessageResponse> PipeMessage(Message message, object userConte
7571

7672
if (!string.IsNullOrEmpty(messageString))
7773
{
78-
using (var pipeMessage = new Message(messageBytes))
74+
using var pipeMessage = new Message(messageBytes);
75+
foreach (var prop in message.Properties)
7976
{
80-
foreach (var prop in message.Properties)
81-
{
82-
pipeMessage.Properties.Add(prop.Key, prop.Value);
83-
}
84-
await moduleClient.SendEventAsync("output1", pipeMessage);
85-
86-
Console.WriteLine("Received message sent");
77+
pipeMessage.Properties.Add(prop.Key, prop.Value);
8778
}
79+
await moduleClient.SendEventAsync("output1", pipeMessage);
80+
81+
Console.WriteLine("Received message sent");
8882
}
8983
return MessageResponse.Completed;
9084
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
</PropertyGroup>
66

77
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp3.1|AnyCPU'">
@@ -10,17 +10,17 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<ProjectCapability Include="AzureIoTEdgeModule"/>
13+
<ProjectCapability Include="AzureIoTEdgeModule" />
1414
</ItemGroup>
1515

1616
<ItemGroup>
1717
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.*" />
18-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
19-
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.1.1" />
20-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.1.1" />
21-
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.1.1" />
22-
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.1.1" />
23-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />
18+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.*" />
19+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.*" />
20+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.*" />
21+
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.*" />
22+
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.*" />
23+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.*" />
2424
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
2525
</ItemGroup>
2626
</Project>

0 commit comments

Comments
 (0)