Watch Aspire live streamsDocsTry Aspire

RadiusExtensions Methods

ClassMethods5 members
Provides extension methods for adding and configuring Radius environment resources.
AddRadiusEnvironment(IDistributedApplicationBuilder, string)Section titled AddRadiusEnvironment(IDistributedApplicationBuilder, string)extensionIResourceBuilder<RadiusEnvironmentResource>
Adds a Radius compute environment to the application model.
public static class RadiusExtensions
{
public static IResourceBuilder<RadiusEnvironmentResource> AddRadiusEnvironment(
this IDistributedApplicationBuilder builder,
string name)
{
// ...
}
}
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder.
namestringThe name of the Radius environment resource.
IResourceBuilder<RadiusEnvironmentResource>A reference to the ApplicationModel.IResourceBuilder`1.
In DistributedApplicationOperation.Run mode this returns an unregistered builder so the environment does not surface as a resource in the dashboard and no pipeline steps are wired up — matching AddKubernetesEnvironment and AddDockerComposeEnvironment. All deployment-target wiring runs in Publish mode only.
ConfigureRadiusInfrastructure(IResourceBuilder<RadiusEnvironmentResource>, Action<RadiusInfrastructureOptions>)Section titled ConfigureRadiusInfrastructure(IResourceBuilder<RadiusEnvironmentResource>, Action<RadiusInfrastructureOptions>)extensionIResourceBuilder<RadiusEnvironmentResource>
Registers a callback that can customize the generated Radius infrastructure before Bicep is emitted.
public static class RadiusExtensions
{
public static IResourceBuilder<RadiusEnvironmentResource> ConfigureRadiusInfrastructure(
this IResourceBuilder<RadiusEnvironmentResource> builder,
Action<RadiusInfrastructureOptions> configure)
{
// ...
}
}
builderIResourceBuilder<RadiusEnvironmentResource>The Radius environment resource builder.
configureAction<RadiusInfrastructureOptions>The callback that mutates the generated infrastructure options.
IResourceBuilder<RadiusEnvironmentResource>The same ApplicationModel.IResourceBuilder`1 for chaining.
WithContainerImage(IResourceBuilder<ProjectResource>, string)Section titled WithContainerImage(IResourceBuilder<ProjectResource>, string)extensionIResourceBuilder<ProjectResource>
Associates a pre-built container image reference with a project resource so the Aspire.Hosting.Radius publisher can emit a valid Radius container manifest for it.
public static class RadiusExtensions
{
public static IResourceBuilder<ProjectResource> WithContainerImage(
this IResourceBuilder<ProjectResource> builder,
string image)
{
// ...
}
}
builderIResourceBuilder<ProjectResource>The project resource builder.
imagestring A fully-qualified image reference in [registry/]image[:tag] form (for example localhost:5001/apiservice:latest). When the tag is omitted latest is used.
IResourceBuilder<ProjectResource>The same ApplicationModel.IResourceBuilder`1 for chaining.
The Radius publisher does not yet build or push images for ApplicationModel.ProjectResource (tracked at https://github.com/microsoft/aspire/issues/16844). Until that lands, callers must build and push the image themselves (for example with dotnet publish /t:PublishContainer) and then call this method to attach the resulting registry reference. Without it, aspire publish against a Radius environment fails with a clear remediation message — and aspire deploy against Radius would otherwise land pods that hit ImagePullBackOff against the publisher's <name>:latest fallback. The reference is stored as a ApplicationModel.ContainerImageAnnotation, which is also what container resources use, so the publisher's existing Registry / Image / Tag assembly path applies uniformly. The attached image is treated as a final artifact and is not modified by Aspire. Include any files required by PublishWithContainerFiles when building the image instead of combining that method with WithContainerImage.
WithContainerImage(IResourceBuilder<T>, string)Section titled WithContainerImage(IResourceBuilder<T>, string)extensionIResourceBuilder<T>
Associates a pre-built container image reference with a .NET program resource.
public static class RadiusExtensions
{
public static IResourceBuilder<T> WithContainerImage<T>(
this IResourceBuilder<T> builder,
string image)
{
// ...
}
}
builderIResourceBuilder<T>The .NET program resource builder.
imagestringA fully-qualified image reference in [registry/]image[:tag] form.
IResourceBuilder<T>The same resource builder for chaining.
The attached image is treated as a final artifact and is not modified by Aspire. Include any files required by PublishWithContainerFiles when building the image instead of combining that method with WithContainerImage.
WithNamespace(IResourceBuilder<RadiusEnvironmentResource>, string)Section titled WithNamespace(IResourceBuilder<RadiusEnvironmentResource>, string)extensionIResourceBuilder<RadiusEnvironmentResource>
Sets the Kubernetes namespace for the Radius environment.
public static class RadiusExtensions
{
public static IResourceBuilder<RadiusEnvironmentResource> WithNamespace(
this IResourceBuilder<RadiusEnvironmentResource> builder,
string kubernetesNamespace)
{
// ...
}
}
builderIResourceBuilder<RadiusEnvironmentResource>The Radius environment resource builder.
kubernetesNamespacestringA valid RFC 1123 namespace name.
IResourceBuilder<RadiusEnvironmentResource>A reference to the ApplicationModel.IResourceBuilder`1.
ArgumentExceptionThrown when the namespace is not a valid RFC 1123 label.