Getting Started with the Agora Edge App .NET SDK
The .NET SDK provides functionality for developing .NET edge applications using .NET6.0 and above.
The .NET SDK is distributed on Nuget as AgoraIoT.Edge.App.SDK.
Several methods for getting started are provided using several environments, including:
- Command Line
- Visual Studio (Community, Pro, etc.)
- Visual Studio Code
Create a Console App
Pick the method you would like to create a new Console App.
Creating an Agora Edge App using Visual Studio 2022 and .NET Core 6
Create Console App:
- Start Visual Studio.
- Create a new project targeting a Console App (File > New Project...).
- Enter a Project Name, Location, and Solution Name.
- For the framework select .NET Core 6 (Long-term support).
Add 'AgoraIoT.Edge.App.SDK' NuGet Package:
- On the Solution Explorer, right click on the solution and select Manage Nuget Packages for Solution to bring up the NuGet Package Manager.
- Click the check box Include prerelease and make sure the Package Source is set to Nuget.
- Search for AgoraIoT.
- Select AgoraIoT.Edge.App.SDK in the list of packages.
- Agree to the License Agreement.
Creating an Agora Edge App using Visual Studio Code and .NET Core 6
Create Console App:
Follow the Microsoft tutorial to create a Console app, EXCEPT in Step 6 run the following commands:
> dotnet new console -n ProjectName -f net6.0 --use-program-main
> cd ProjectName
> dotnet add ProjectName.csproj package AgoraIoT.Edge.App.SDK --version 1.0.11-beta
Creating an Agora Edge App using Command Line and .NET Core 6
Create Console App:
From folder where you want to create a project within, enter
> dotnet new console -n ProjectName -f net6.0 --use-program-main
> cd ProjectName
> dotnet add ProjectName.csproj package AgoraIoT.Edge.App.SDK --version 1.0.11-beta
"Hello World!"
Replace the code in Program.cs with the following code and run the application:
"Hello World!".LogInfo();
Creating an Edge Application Container Image
Using the Dockerfile.sample provided within the application, create a Dockerfile for your project.
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-alpine AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY src/. /src
RUN dotnet restore "ConsoleApp/ConsoleApp.csproj" -r linux-musl-x64
RUN dotnet build "ConsoleApp/ConsoleApp.csproj" -c Release -o /app/build --no-restore -r linux-musl-x64
FROM build AS publish
RUN dotnet publish "ConsoleApp/ConsoleApp.csproj" -p:PublishSingleFile=true -r linux-musl-x64 --self-contained true -p:PublishTrimmed=False -p:TrimMode=Link -c Release -o /app/publish --no-restore
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["./ConsoleApp"]
Create your docker container by running the following command within the project folder with the Dockerfile:
> docker build .