Connect Microservices

Your stack:

Goal

Connect a .NET backend service to another remote service using Graftcode - so the remote integration stays strongly typed and reads like a normal method call.

What You'll See

  • Install a remote service as a strongly-typed Graft via NuGet.
  • Configure the generated client to point at the remote host.
  • Call a remote method from your own service logic as if it were a local class.
  • Use IDE autocompletion on the remote service's methods and classes.

Prerequisites

Step 1. Create a .NET service

Create a new console application for your backend service:

dotnet new console -n EnergyConsumer
cd EnergyConsumer

Step 2. Find the remote method in Graftcode Vision

We're hosting this sample service for you so you can see exactly what connecting to another team's service looks like in practice - open it in Graftcode Vision to explore.

Graftcode Vision shows all public classes and methods exposed by the remote service - their names, parameter types, and return types. It also gives you the exact package manager command needed to install that service as a Graft.

Step 3. Install the Graft

Open Graftcode Vision, pick NuGet, and copy the generated install command.

dotnet add package -s https://grft.dev/4b4e411f-60a0-4868-b8a6-46f5dee07448__free graft.nuget.energypriceservice --version 1.2.0

This adds the generated strongly-typed client for the remote service to your project.

Step 4. Call the remote method and run it

The exact configuration snippet for your language is available in Graftcode Vision under the Configuration installation tab. Replace the contents of Program.cs:

using graft.nuget.EnergyPriceService;
GraftConfig.Host = "wss://gc-d-ca-polc-demo-ecbe-01.blackgrass-d2c29aae.polandcentral.azurecontainerapps.io/ws";

var consumption = MeterLogic.NetConsumptionKWh(1000, 1150);
Console.WriteLine($"Net consumption: {consumption}");

Run it:

dotnet run

You should see the net consumption value printed in your terminal. MeterLogic.NetConsumptionKWh(...) is a remote call, but your code reads like a normal method invocation - no HTTP request, no response parsing, no serialization.

Your IDE can autocomplete available methods on MeterLogic, BillingLogic, and any other class from that service because the Graft is a real installed package.

Everything above works without any account - perfect for learning and local development. When you're ready for real-world usage, create a free account at portal.graftcode.com, set up a project, and copy its Project Key.

With a Project Key, point GraftConfig.Host at your project's stable registry URL instead of a raw WebSocket address. A Project Key gives you:

  • Stable registry URL - the address for your Grafts stays permanent, so install commands don't change when you redeploy.
  • Portal visibility - see all your gateways and services in one place at gateways.graftcode.com.
  • Access control - decide who can download your Grafts using package manager authentication and permissions.