Temporalio.Extensions.Gcp.CloudRun.Id
1.20.0
Prefix Reserved
dotnet add package Temporalio.Extensions.Gcp.CloudRun.Id --version 1.20.0
NuGet\Install-Package Temporalio.Extensions.Gcp.CloudRun.Id -Version 1.20.0
<PackageReference Include="Temporalio.Extensions.Gcp.CloudRun.Id" Version="1.20.0" />
<PackageVersion Include="Temporalio.Extensions.Gcp.CloudRun.Id" Version="1.20.0" />
<PackageReference Include="Temporalio.Extensions.Gcp.CloudRun.Id" />
paket add Temporalio.Extensions.Gcp.CloudRun.Id --version 1.20.0
#r "nuget: Temporalio.Extensions.Gcp.CloudRun.Id, 1.20.0"
#:package Temporalio.Extensions.Gcp.CloudRun.Id@1.20.0
#addin nuget:?package=Temporalio.Extensions.Gcp.CloudRun.Id&version=1.20.0
#tool nuget:?package=Temporalio.Extensions.Gcp.CloudRun.Id&version=1.20.0
Google Cloud Run worker identity support
This extension provides CloudRunIdPlugin, a Temporal client/worker plugin that derives a client
identity from Google Cloud Run instance metadata, for Cloud Run worker pools and services.
Add the Temporalio.Extensions.Gcp.CloudRun.Id package from
NuGet. For example,
using the dotnet CLI:
dotnet add package Temporalio.Extensions.Gcp.CloudRun.Id
Quick Start
Construct a CloudRunIdPlugin, register it on your client connect options via Plugins, then run a
normal long-lived worker. Registering it once on the client is enough: the plugin sets the client
identity at connect time, and workers created from that client inherit it.
using System;
using System.Runtime.InteropServices;
using System.Threading;
using Temporalio.Client;
using Temporalio.Extensions.Gcp.CloudRun.Id;
using Temporalio.Worker;
var connectOptions = new TemporalClientConnectOptions("my-namespace.a1b2c.tmprl.cloud:7233")
{
Namespace = "my-namespace",
// Register the plugin once on the client. It reads the Cloud Run metadata at connect time and
// propagates to workers created from the connected client.
Plugins = new[] { new CloudRunIdPlugin() },
// ... Temporal Cloud API key / mTLS credentials ...
};
var client = await TemporalClient.ConnectAsync(connectOptions);
using var worker = new TemporalWorker(
client,
new TemporalWorkerOptions("my-task-queue").
AddWorkflow<MyWorkflow>().
AddActivity(MyActivities.DoThing));
// Cloud Run sends SIGTERM before stopping the instance; cancel the worker on it.
using var shutdown = new CancellationTokenSource();
using var sigterm = PosixSignalRegistration.Create(PosixSignal.SIGTERM, context =>
{
context.Cancel = true;
shutdown.Cancel();
});
try
{
await worker.ExecuteAsync(shutdown.Token);
}
catch (OperationCanceledException)
{
// Expected shutdown path.
}
Note: the plugin applies the identity when the client connects, so it only runs if your client connects with the plugin registered. If the client is created lazily — as some dependency-injection setups do — the plugin may not be applied; in that case set the identity yourself before building the client:
var metadata = await GoogleCloudRunMetadata.FetchAsync();
connectOptions.Identity = metadata.Identity;
How it works
You register the plugin on the client you already build, and it sets the client identity for you.
At connect time the plugin's client hook fetches the Cloud Run metadata once and caches it. The
metadata is three values gathered by GoogleCloudRunMetadata.FetchAsync:
Name— the Cloud Run worker pool name (from theCLOUD_RUN_WORKER_POOLenvironment variable), or the service name (fromK_SERVICE).Revisionfrom theCLOUD_RUN_REVISIONenvironment variable, then theK_REVISIONenvironment variable.InstanceIdfrom the Cloud Run metadata server (http://metadata.google.internal/computeMetadata/v1/instance/id), read with the requiredMetadata-Flavor: Googlerequest header. This is the only value not available as an environment variable, so the plugin makes a single HTTP GET at startup.
Cloud Run worker pools receive the CLOUD_RUN_* variables (and no K_* variables), while Cloud Run
services receive the K_* variables. The metadata server is available on both, so resolving the
name and revision in that order covers both worker pools and services.
From those values the client hook sets TemporalConnectionOptions.Identity to Identity,
which is {InstanceId}@{Revision}, falling back to {InstanceId}@{Name} when the revision is empty,
or just {InstanceId} when both are empty. It only sets the identity when one is not already
configured, so an explicitly configured identity wins. Workers created from the connected client
inherit that identity.
If the metadata server cannot be reached, the plugin throws an InvalidOperationException at connect
time, which usually means the process is not running on a Cloud Run worker pool or service.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Temporalio (>= 1.20.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.20.0 | 0 | 9/28/2026 |