Introduction to C#


With microservices, you can extend the Cumulocity IoT platform with customer-specific functionality. For example, you can develop integrations to 3rd-party software or provide server-side business logic. Technically, microservices are docker containers, hosted by Cumulocity. For a general introduction to microservices, see Developing applications in the Concepts guide.

Using Microservice SDK for C#, you can develop microservices in C#. This DeveloperĀ“s guide explains

To get started, check the "Hello World" examples for the various C# variants.

  • The most simple starting point is the C# example.

Info: You can develop Cumulocity with any IDE and any build tool that you prefer, but the examples focus on Cake (C# Make) and Visual Studio.

General prerequisites

Development prerequisites

To use the C# client libraries for development, you need to install .NET Core SDK for the platform used for development such as Windows, Linux or Mac (at least Version 2 of the .NET Core SDK). Note that .NET Core Runtime and .NET Core SDK are different things.

To verify the version of your .NET Core SDK, type

$ dotnet --info

The output must show a version number later than "2.0.0" to perform the basic examples.

For Docker installation, review the information at Docker for Windows: What to know before you install and install Docker For Windows.

For .NET development, Microsoft provides a number of different images depending on what you're trying to achieve.

Whether you need the .NET Core SDK or the .NET Core runtime depends on what you want to do:

  • .NET Core SDK - includes tools and libraries to build .NET Core applications.

  • .NET Core Runtime - is required to run .NET Core applications.

Windows system requirements

  • Powershell (at least Version 6 or Core)
  • .NET Core SDK (at least Version 2.0)
  • Docker for Windows (at least Version 17.06)

Unix system requirements

  • .NET Core SDK (at least Version 2 .0)
  • Docker (at least Version 17.06)
  • Mono (at least Version 5.4.0)

Runtime prerequisites

The most important requirement is an installation of Docker 17.06 or later of the Docker client.

Recommended as production image is microsoft/dotnet:-runtime: This image contains the .NET Core (runtime and libraries) and is optimized for running .NET Core apps.

Assumed, only Linux containers are supported. However, for the development itself it is possible to use Windows containers.

The SDK is based on the package Cumulocity.SDK.Microservices has dependency on:

  • Cumulocity.AspNetCore.Authentication.Basic - a package wrapper around Bazinga.AspNetCore.Authentication.Basic Ensures adding basic authentication to Asp.Net Core in the right way because ASP.NET Core 2.0 introduced breaking changes to Authentication and Identity. From this version of the web framework Microsoft doesn't ship a Basic Authentication package with ASP.NET Core Security.