18 interfaces inheriting from IResource
Aspire.Hosting (13)
Aspire.Hosting.Azure (5)
11 implementations of IResource
Aspire.Hosting (1)
Aspire.Hosting.Azure.AppConfiguration (1)
Aspire.Hosting.Azure.CosmosDB (1)
Aspire.Hosting.Azure.EventHubs (1)
Aspire.Hosting.Azure.ServiceBus (1)
Aspire.Hosting.Azure.SignalR (1)
Aspire.Hosting.Azure.Storage (1)
Aspire.Hosting.Tests (4)
946 references to IResource
Aspire.Hosting (460)
ApplicationModel\ResourceExtensions.cs (71)
16/// Provides extension methods for the <see cref="IResource"/> interface.
27public static bool TryGetLastAnnotation<T>(this IResource resource, [NotNullWhen(true)] out T? annotation) where T : IResourceAnnotation
48public static bool TryGetAnnotationsOfType<T>(this IResource resource, [NotNullWhen(true)] out IEnumerable<T>? result) where T : IResourceAnnotation
70public static bool HasAnnotationOfType<T>(this IResource resource) where T : IResourceAnnotation
82public static bool TryGetAnnotationsIncludingAncestorsOfType<T>(this IResource resource, [NotNullWhen(true)] out IEnumerable<T>? result) where T : IResourceAnnotation
119public static bool HasAnnotationIncludingAncestorsOfType<T>(this IResource resource) where T : IResourceAnnotation
152public static bool TryGetEnvironmentVariables(this IResource resource, [NotNullWhen(true)] out IEnumerable<EnvironmentCallbackAnnotation>? environmentVariables)
258this IResource resource,
293this IResource resource,
333this IResource resource,
356this IResource resource,
390this IResource resource,
426this IResource resource,
448this IResource resource,
483where T : IResource, IComputeResource
502where T : IResource, IComputeResource
510internal static NetworkIdentifier GetDefaultResourceNetwork(this IResource resource)
515internal static IEnumerable<NetworkIdentifier> GetSupportedNetworks(this IResource resource)
521this IResource resource,
532(DistributedApplicationOperation.Run, IResourceBuilder<IResource> rb) when rb.Resource is IValueProvider provider => await resource.GetValue(executionContext, key, provider, logger, cancellationToken).ConfigureAwait(false),
534(DistributedApplicationOperation.Publish, IResourceBuilder<IResource> rb) when rb.Resource is IManifestExpressionProvider provider => new(provider.ValueExpression, false),
544public static bool IsExcludedFromPublish(this IResource resource) =>
548this IResource resource,
591private static async Task<ResolvedValue?> GetValue(this IResource resource, DistributedApplicationExecutionContext executionContext, string? key, IValueProvider valueProvider, ILogger logger, CancellationToken cancellationToken)
597if (valueProvider is IResource providerResource)
634public static bool TryGetContainerMounts(this IResource resource, [NotNullWhen(true)] out IEnumerable<ContainerMountAnnotation>? volumeMounts)
645public static bool TryGetEndpoints(this IResource resource, [NotNullWhen(true)] out IEnumerable<EndpointAnnotation>? endpoints)
656public static bool TryGetUrls(this IResource resource, [NotNullWhen(true)] out IEnumerable<ResourceUrlAnnotation>? urls)
665/// <returns>An enumeration of <see cref="EndpointReference"/> based on the <see cref="EndpointAnnotation"/> annotations from the resources' <see cref="IResource.Annotations"/> collection.</returns>
681/// <returns>An enumeration of <see cref="EndpointReference"/> based on the <see cref="EndpointAnnotation"/> annotations from the resources' <see cref="IResource.Annotations"/> collection.</returns>
744public static IReadOnlyList<ResolvedEndpoint> ResolveEndpoints(this IResource resource, IPortAllocator? portAllocator = null)
827public static bool TryGetContainerImageName(this IResource resource, [NotNullWhen(true)] out string? imageName)
839public static bool TryGetContainerImageName(this IResource resource, bool useBuiltImage, [NotNullWhen(true)] out string? imageName)
880public static int GetReplicaCount(this IResource resource)
901public static bool RequiresImageBuild(this IResource resource)
921public static bool RequiresImageBuildAndPush(this IResource resource)
926internal static bool IsBuildOnlyContainer(this IResource resource)
937public static IComputeEnvironmentResource? GetComputeEnvironment(this IResource resource)
950public static DeploymentTargetAnnotation? GetDeploymentTargetAnnotation(this IResource resource, IComputeEnvironmentResource? targetComputeEnvironment = null)
995internal static ContainerLifetime GetContainerLifetimeType(this IResource resource)
1011internal static bool TryGetContainerImagePullPolicy(this IResource resource, [NotNullWhen(true)] out ImagePullPolicy? pullPolicy)
1029internal static bool SupportsProxy(this IResource resource)
1039internal static IResource GetRootResource(this IResource resource) =>
1050internal static string GetResolvedResourceName(this IResource resource)
1071internal static bool TryGetInstances(this IResource resource, out ImmutableArray<DcpInstance> instances)
1088internal static string[] GetResolvedResourceNames(this IResource resource)
1108this IResource resource,
1148internal static IContainerRegistry GetContainerRegistry(this IResource resource)
1173var registryNames = string.Join(", ", registryTargetAnnotations.Select(a => a.Registry is IResource res ? res.Name : a.Registry.ToString()));
1195this IResource resource,
1224internal static ILogger GetLogger(this IResource resource, IServiceProvider serviceProvider)
1257public static async Task<IReadOnlySet<IResource>> GetResourceDependenciesAsync(
1258this IResource resource,
1263var dependencies = new HashSet<IResource>();
1264var newDependencies = new HashSet<IResource>();
1270var toProcess = new Queue<IResource>(dependencies);
1273var dep = toProcess.Dequeue();
1278foreach (var newDep in newDependencies)
1301IResource resource,
1302HashSet<IResource> dependencies,
1303HashSet<IResource> newDependencies,
1325IResource resource,
1369private static void CollectAnnotationDependencies(IResource resource, HashSet<IResource> dependencies, HashSet<IResource> newDependencies)
1405private static void CollectDependenciesFromValue(object? value, HashSet<IResource> dependencies, HashSet<IResource> newDependencies, HashSet<object> visitedValues)
1413if (value is IResource resource)
1423if (value is IResourceBuilder<IResource> resourceBuilder)
1447internal static string GetResourceType(this IResource resource) => resource switch
ApplicationModel\ResourceNotificationService.cs (19)
139private async Task WaitUntilHealthyAsync(IResource resource, IResource dependency, WaitBehavior waitBehavior, CancellationToken cancellationToken)
266private async Task WaitUntilCompletionAsync(IResource resource, IResource dependency, int exitCode, CancellationToken cancellationToken)
325private async Task WaitUntilStateAsync(IResource resource, IResource dependency, WaitBehavior waitBehavior,
396private async Task WaitUntilStartedAsync(IResource resource, IResource dependency, WaitBehavior waitBehavior, CancellationToken cancellationToken)
414public async Task WaitForDependenciesAsync(IResource resource, CancellationToken cancellationToken)
619public Task PublishUpdateAsync(IResource resource, string resourceId, Func<CustomResourceSnapshot, CustomResourceSnapshot> stateFactory)
719private CustomResourceSnapshot UpdateCommands(IResource resource, CustomResourceSnapshot previousState)
793private static CustomResourceSnapshot UpdateIcons(IResource resource, CustomResourceSnapshot previousState)
823public async Task PublishUpdateAsync(IResource resource, Func<CustomResourceSnapshot, CustomResourceSnapshot> stateFactory)
832private static CustomResourceSnapshot GetCurrentSnapshot(IResource resource, ResourceNotificationState notificationState)
860private ResourceNotificationState GetResourceNotificationState(string resourceId, IResource resource) =>
936private sealed class ResourceNotificationState(IResource resource)
941public IResource Resource { get; } = resource;
968public class ResourceEvent(IResource resource, string resourceId, CustomResourceSnapshot snapshot)
973public IResource Resource { get; } = resource;
Dcp\DcpExecutor.cs (16)
439_resourceState.ApplicationModel.TryGetValue(resourceName, out var appModelResource))
544private static string GetResourceType<T>(T resource, IResource appModelResource) where T : CustomResource
731_resourceState.ApplicationModel.TryGetValue(appModelResourceName, out var appModelResource))
1449private void EnsureRequiredAnnotations(IResource resource)
1457private static void SetInitialResourceState(IResource resource, IAnnotationHolder annotationHolder)
1489var groupKey = group.Key;
1504IResource resource,
1825foreach (var container in modelContainerResources)
1891private static DcpInstance GetDcpInstance(IResource resource, int instanceIndex)
1981var modelContainerResource = cr.ModelResource;
2187private static async Task ApplyBuildArgumentsAsync(Container dcpContainerResource, IResource modelContainerResource, IServiceProvider serviceProvider, CancellationToken cancellationToken)
2268private void AddServicesProducedInfo(IResource modelResource, IAnnotationHolder dcpResource, RenderedModelResource appResource)
2567public required IResource Resource { get; init; }
2610private async Task<(List<string>, bool)> BuildRunArgsAsync(ILogger resourceLogger, IResource modelResource, CancellationToken cancellationToken)
2833private static List<VolumeMount> BuildContainerMounts(IResource container)
2856private static bool TryGetEndpoint(IResource resource, string? endpointName, [NotNullWhen(true)] out EndpointAnnotation? endpoint)
Dcp\DcpExecutorEvents.cs (3)
11internal record OnResourceStartingContext(CancellationToken CancellationToken, string ResourceType, IResource Resource, string? DcpResourceName);
13internal record OnResourceChangedContext(CancellationToken CancellationToken, string ResourceType, IResource Resource, string DcpResourceName, ResourceStatus Status, Func<CustomResourceSnapshot, CustomResourceSnapshot> UpdateSnapshot);
14internal record OnResourceFailedToStartContext(CancellationToken CancellationToken, string ResourceType, IResource Resource, string? DcpResourceName);
Orchestrator\ApplicationOrchestrator.cs (16)
24private readonly ILookup<IResource, IResource> _parentChildLookup;
140private async Task PublishResourceEndpointUrls(IResource resource, CancellationToken cancellationToken)
150private static IEnumerable<UrlSnapshot> GetResourceUrls(IResource resource)
201static Task PublishUpdateAsync(ResourceNotificationService notificationService, IResource resource, string? resourceId, Func<CustomResourceSnapshot, CustomResourceSnapshot> stateFactory)
214private async Task ProcessResourceUrlCallbacks(IResource resource, CancellationToken cancellationToken)
596private async Task SetChildResourceAsync(IResource resource, string? state, DateTime? startTimeStamp, DateTime? stopTimeStamp)
598foreach (var child in _parentChildLookup[resource].Where(c => c is IResourceWithParent))
625foreach (var resource in _model.Resources)
629var parent = resource is IResourceWithParent hasParent
651private static ImmutableArray<HealthReportSnapshot> GetInitialHealthReports(IResource resource)
662private async Task PublishConnectionStringAvailableEvent(IResource resource, CancellationToken cancellationToken)
688private async Task PublishEventToHierarchy<TEvent>(Func<IResource, TEvent> createEvent, IResource resource, CancellationToken cancellationToken)
697foreach (var child in children.Where(c => c is IResourceWithParent))
712private static bool ResourceHasOwnLifetime(IResource resource) =>
Orchestrator\RelationshipEvaluator.cs (19)
13public static ILookup<IResource, IResource> GetParentChildLookup(DistributedApplicationModel model)
18.Select(x => (Child: (IResource)x, Parent: x.Parent))
24private static IEnumerable<(IResource Child, IResource Parent)> GetParentChildRelationshipsFromAnnotations(DistributedApplicationModel model)
26static bool TryGetParent(IResource resource, [NotNullWhen(true)] out IResource? parent)
39static IResource? SelectParentResource(IResource? resource) => resource switch
41IResource r when TryGetParent(r, out var parent) => parent,
54private static void ValidateRelationships((IResource Child, IResource Parent)[] relationships)
64var visited = new Stack<IResource>();
70static void ValidateNoCircularDependencies(Dictionary<IResource, IResource> childToParentLookup, IResource child, Stack<IResource> visited)
73if (childToParentLookup.TryGetValue(child, out var parent))
Publishing\ResourceContainerImageManager.cs (13)
141Task BuildImageAsync(IResource resource, CancellationToken cancellationToken = default);
149Task BuildImagesAsync(IEnumerable<IResource> resources, CancellationToken cancellationToken = default);
156Task PushImageAsync(IResource resource, CancellationToken cancellationToken);
181IResource resource,
206public async Task BuildImagesAsync(IEnumerable<IResource> resources, CancellationToken cancellationToken = default)
226foreach (var resource in resources)
235public async Task BuildImageAsync(IResource resource, CancellationToken cancellationToken = default)
295private async Task BuildProjectContainerImageAsync(IResource resource, ResolvedContainerBuildOptions options, CancellationToken cancellationToken)
322private async Task<bool> ExecuteDotnetPublishAsync(IResource resource, ResolvedContainerBuildOptions options, CancellationToken cancellationToken)
419private async Task BuildContainerImageFromDockerfileAsync(IResource resource, DockerfileBuildAnnotation dockerfileBuildAnnotation, string imageName, ResolvedContainerBuildOptions options, CancellationToken cancellationToken)
513public async Task PushImageAsync(IResource resource, CancellationToken cancellationToken)
519private async Task<bool> ResourcesRequireContainerRuntimeAsync(IEnumerable<IResource> resources, CancellationToken cancellationToken)
521foreach (var resource in resources)
ResourceBuilderExtensions.cs (58)
408public static IResourceBuilder<T> WithManifestPublishingCallback<T>(this IResourceBuilder<T> builder, Action<ManifestPublishingContext> callback) where T : IResource
424public static IResourceBuilder<T> WithManifestPublishingCallback<T>(this IResourceBuilder<T> builder, Func<ManifestPublishingContext, Task> callback) where T : IResource
1133where T : IResource
1157where T : IResource
1195where T : IResource
1234where T : IResource
1257where T : IResource
1313where T : IResource
1453public static IResourceBuilder<T> ExcludeFromManifest<T>(this IResourceBuilder<T> builder) where T : IResource
1471/// resources, calling <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource})"/> also results
1488public static IResourceBuilder<T> WaitFor<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency) where T : IResourceWithWaitSupport
1508/// resources, calling <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource}, WaitBehavior)"/> also results
1516/// behavior with the <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource})"/> overload.</para>
1530public static IResourceBuilder<T> WaitFor<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, WaitBehavior waitBehavior) where T : IResourceWithWaitSupport
1538private static IResourceBuilder<T> WaitForCore<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, WaitBehavior? waitBehavior, bool addRelationship) where T : IResourceWithWaitSupport
1540if (builder.Resource as IResource == dependency.Resource)
1580/// <para>Unlike <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource})"/>, this method
1594public static IResourceBuilder<T> WaitForStart<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency) where T : IResourceWithWaitSupport
1614/// <para>Unlike <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource}, WaitBehavior)"/>, this method
1620/// behavior with the <see cref="WaitForStart{T}(IResourceBuilder{T}, IResourceBuilder{IResource})"/> overload.</para>
1634public static IResourceBuilder<T> WaitForStart<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, WaitBehavior waitBehavior) where T : IResourceWithWaitSupport
1642private static IResourceBuilder<T> WaitForStartCore<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, WaitBehavior? waitBehavior, bool addRelationship) where T : IResourceWithWaitSupport
1644if (builder.Resource as IResource == dependency.Resource)
1669foreach (var referencedResource in cs.ConnectionStringExpression.ValueProviders.OfType<IResource>())
1705public static IResourceBuilder<T> WithExplicitStart<T>(this IResourceBuilder<T> builder) where T : IResource
1737public static IResourceBuilder<T> WaitForCompletion<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, int exitCode = 0) where T : IResourceWithWaitSupport
1742if (builder.Resource as IResource == dependency.Resource)
1767/// the <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource})"/> to associate a resource
1794public static IResourceBuilder<T> WithHealthCheck<T>(this IResourceBuilder<T> builder, string key) where T : IResource
1995CommandOptions? commandOptions = null) where T : IResource
2062bool isHighlighted = false) where T : IResource
2701IResource resource,
2702string type) where T : IResource
2720IResource resource) where T : IResource
2737ReferenceExpression expression) where T : IResource
2748where T : IResource
2752void AddReference(IResource resource)
2764if (value is IResource resource)
2768else if (value is IResourceBuilder<IResource> resourceBuilder)
2796IResourceBuilder<IResource> resourceBuilder) where T : IResource
2830IResourceBuilder<IResource> parent) where T : IResource
2860IResource parent) where T : IResource
2891IResourceBuilder<IResource> child) where T : IResource
2923IResource child) where T : IResource
2957public static IResourceBuilder<T> WithIconName<T>(this IResourceBuilder<T> builder, string iconName, IconVariant iconVariant = IconVariant.Filled) where T : IResource
2993where T : IResource
3143public static IResourceBuilder<T> ExcludeFromMcp<T>(this IResourceBuilder<T> builder) where T : IResource
3179where T : IResource
3218where T : IResource
3250where T : IResource
3285where T : IResource
Aspire.Hosting.Azure (24)
Provisioning\Provisioners\AzureProvisioner.cs (7)
29private ILookup<IResource, IResourceWithParent>? _parentChildLookup;
43async Task UpdateStateAsync((IResource Resource, IAzureResource AzureResource) resource, Func<CustomResourceSnapshot, CustomResourceSnapshot> stateFactory)
78async Task AfterProvisionAsync((IResource Resource, IAzureResource AzureResource) resource)
112async Task<bool> WaitForRoleAssignments((IResource Resource, IAzureResource AzureResource) resource)
162IList<(IResource Resource, IAzureResource AzureResource)> azureResources,
187private async Task ProcessResourceAsync(IConfiguration configuration, Lazy<Task<ProvisioningContext>> provisioningContextLazy, (IResource Resource, IAzureResource AzureResource) resource, CancellationToken cancellationToken)
258async Task PublishConnectionStringAvailableEventRecursiveAsync(IResource targetResource)
Aspire.Hosting.Azure.AIFoundry (3)
Aspire.Hosting.Azure.AppConfiguration (3)
Aspire.Hosting.Azure.AppContainers (24)
Aspire.Hosting.Azure.AppService (21)
Aspire.Hosting.Azure.CognitiveServices (3)
Aspire.Hosting.Azure.ContainerRegistry (5)
Aspire.Hosting.Azure.EventHubs (3)
Aspire.Hosting.Azure.Functions (2)
Aspire.Hosting.Azure.KeyVault (5)
Aspire.Hosting.Azure.Kusto (3)
Aspire.Hosting.Azure.Network (1)
Aspire.Hosting.Azure.Search (3)
Aspire.Hosting.Azure.ServiceBus (3)
Aspire.Hosting.Azure.SignalR (3)
Aspire.Hosting.Azure.Storage (3)
Aspire.Hosting.Azure.Tests (65)
Aspire.Hosting.Azure.WebPubSub (3)
Aspire.Hosting.CodeGeneration.Go (1)
Aspire.Hosting.CodeGeneration.Go.Tests (15)
Aspire.Hosting.CodeGeneration.Java (1)
Aspire.Hosting.CodeGeneration.Java.Tests (15)
Aspire.Hosting.CodeGeneration.Python (1)
Aspire.Hosting.CodeGeneration.Python.Tests (15)
Aspire.Hosting.CodeGeneration.Rust (1)
Aspire.Hosting.CodeGeneration.Rust.Tests (15)
Aspire.Hosting.CodeGeneration.TypeScript.Tests (15)
Aspire.Hosting.Containers.Tests (13)
Aspire.Hosting.DevTunnels (6)
Aspire.Hosting.Docker (27)
Aspire.Hosting.Docker.Tests (13)
Aspire.Hosting.JavaScript.Tests (4)
Aspire.Hosting.Kafka.Tests (1)
Aspire.Hosting.Keycloak.Tests (2)
Aspire.Hosting.Kubernetes (20)
Aspire.Hosting.Kubernetes.Tests (4)
Aspire.Hosting.Maui (5)
Aspire.Hosting.Maui.Tests (8)
Aspire.Hosting.Milvus.Tests (2)
Aspire.Hosting.MySql (1)
Aspire.Hosting.MySql.Tests (4)
Aspire.Hosting.Oracle.Tests (3)
Aspire.Hosting.PostgreSQL (2)
Aspire.Hosting.PostgreSQL.Tests (7)
Aspire.Hosting.Qdrant.Tests (4)
Aspire.Hosting.Redis (2)
Aspire.Hosting.Redis.Tests (4)
Aspire.Hosting.SqlServer (1)
Aspire.Hosting.Testing (10)
Aspire.Hosting.Testing.Tests (3)
Aspire.Hosting.Tests (72)
Aspire.Hosting.Yarp (1)
Aspire.Playground.Tests (3)
Pipelines.Library (1)
Stress.AppHost (7)