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)
959 references to IResource
Aspire.Hosting (467)
ApplicationModel\ResourceExtensions.cs (76)
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 Task<IReadOnlySet<IResource>> GetResourceDependenciesAsync(
1258this IResource resource,
1293internal static async Task<IReadOnlySet<IResource>> GetDependenciesAsync(
1294IEnumerable<IResource> resources,
1299var dependencies = new HashSet<IResource>();
1300var newDependencies = new HashSet<IResource>();
1301var toProcess = new Queue<IResource>();
1303foreach (var resource in resources)
1312foreach(var nd in newDependencies)
1319var dep = toProcess.Dequeue();
1324foreach (var newDep in newDependencies)
1336foreach (var resource in resources)
1353IResource resource,
1354HashSet<IResource> dependencies,
1355HashSet<IResource> newDependencies,
1377IResource resource,
1421private static void CollectAnnotationDependencies(IResource resource, HashSet<IResource> dependencies, HashSet<IResource> newDependencies)
1457private static void CollectDependenciesFromValue(object? value, HashSet<IResource> dependencies, HashSet<IResource> newDependencies, HashSet<object> visitedValues)
1465if (value is IResource resource)
1474if (value is IResourceBuilder<IResource> resourceBuilder)
1497internal 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 (17)
503_resourceState.ApplicationModel.TryGetValue(resourceName, out var appModelResource))
608private static string GetResourceType<T>(T resource, IResource appModelResource) where T : CustomResource
795_resourceState.ApplicationModel.TryGetValue(appModelResourceName, out var appModelResource))
1536private void EnsureRequiredAnnotations(IResource resource)
1544private static void SetInitialResourceState(IResource resource, IAnnotationHolder annotationHolder)
1576var groupKey = group.Key;
1591IResource resource,
1912foreach (var container in modelContainerResources)
1978private static DcpInstance GetDcpInstance(IResource resource, int instanceIndex)
2068var modelContainerResource = cr.ModelResource;
2275private static async Task ApplyBuildArgumentsAsync(Container dcpContainerResource, IResource modelContainerResource, IServiceProvider serviceProvider, CancellationToken cancellationToken)
2356private void AddServicesProducedInfo(IResource modelResource, IAnnotationHolder dcpResource, RenderedModelResource appResource)
2655public required IResource Resource { get; init; }
2698private async Task<(List<string>, bool)> BuildRunArgsAsync(ILogger resourceLogger, IResource modelResource, CancellationToken cancellationToken)
2921private static List<VolumeMount> BuildContainerMounts(IResource container)
2944private static bool TryGetEndpoint(IResource resource, string? endpointName, [NotNullWhen(true)] out EndpointAnnotation? endpoint)
2960private static HostResourceWithEndpoints? AsHostResourceWithEndpoints(IResource resource)
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)
515public async Task PushImageAsync(IResource resource, CancellationToken cancellationToken)
521private async Task<bool> ResourcesRequireContainerRuntimeAsync(IEnumerable<IResource> resources, CancellationToken cancellationToken)
523foreach (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
1153where T : IResource
1177where T : IResource
1215where T : IResource
1254where T : IResource
1277where T : IResource
1333where T : IResource
1473public static IResourceBuilder<T> ExcludeFromManifest<T>(this IResourceBuilder<T> builder) where T : IResource
1491/// resources, calling <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource})"/> also results
1508public static IResourceBuilder<T> WaitFor<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency) where T : IResourceWithWaitSupport
1528/// resources, calling <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource}, WaitBehavior)"/> also results
1536/// behavior with the <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource})"/> overload.</para>
1550public static IResourceBuilder<T> WaitFor<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, WaitBehavior waitBehavior) where T : IResourceWithWaitSupport
1558private static IResourceBuilder<T> WaitForCore<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, WaitBehavior? waitBehavior, bool addRelationship) where T : IResourceWithWaitSupport
1560if (builder.Resource as IResource == dependency.Resource)
1600/// <para>Unlike <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource})"/>, this method
1614public static IResourceBuilder<T> WaitForStart<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency) where T : IResourceWithWaitSupport
1634/// <para>Unlike <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource}, WaitBehavior)"/>, this method
1640/// behavior with the <see cref="WaitForStart{T}(IResourceBuilder{T}, IResourceBuilder{IResource})"/> overload.</para>
1654public static IResourceBuilder<T> WaitForStart<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, WaitBehavior waitBehavior) where T : IResourceWithWaitSupport
1662private static IResourceBuilder<T> WaitForStartCore<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, WaitBehavior? waitBehavior, bool addRelationship) where T : IResourceWithWaitSupport
1664if (builder.Resource as IResource == dependency.Resource)
1689foreach (var referencedResource in cs.ConnectionStringExpression.ValueProviders.OfType<IResource>())
1725public static IResourceBuilder<T> WithExplicitStart<T>(this IResourceBuilder<T> builder) where T : IResource
1757public static IResourceBuilder<T> WaitForCompletion<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, int exitCode = 0) where T : IResourceWithWaitSupport
1762if (builder.Resource as IResource == dependency.Resource)
1787/// the <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource})"/> to associate a resource
1814public static IResourceBuilder<T> WithHealthCheck<T>(this IResourceBuilder<T> builder, string key) where T : IResource
2015CommandOptions? commandOptions = null) where T : IResource
2082bool isHighlighted = false) where T : IResource
2721IResource resource,
2722string type) where T : IResource
2740IResource resource) where T : IResource
2757ReferenceExpression expression) where T : IResource
2768where T : IResource
2772void AddReference(IResource resource)
2784if (value is IResource resource)
2788else if (value is IResourceBuilder<IResource> resourceBuilder)
2816IResourceBuilder<IResource> resourceBuilder) where T : IResource
2850IResourceBuilder<IResource> parent) where T : IResource
2880IResource parent) where T : IResource
2911IResourceBuilder<IResource> child) where T : IResource
2943IResource child) where T : IResource
2977public static IResourceBuilder<T> WithIconName<T>(this IResourceBuilder<T> builder, string iconName, IconVariant iconVariant = IconVariant.Filled) where T : IResource
3013where T : IResource
3163public static IResourceBuilder<T> ExcludeFromMcp<T>(this IResourceBuilder<T> builder) where T : IResource
3199where T : IResource
3238where T : IResource
3270where T : IResource
3305where T : IResource
Aspire.Hosting.Azure (23)
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 (6)
Aspire.Hosting.Azure.EventHubs (3)
Aspire.Hosting.Azure.Functions (2)
Aspire.Hosting.Azure.KeyVault (6)
Aspire.Hosting.Azure.Kusto (3)
Aspire.Hosting.Azure.Network (1)
Aspire.Hosting.Azure.Search (3)
Aspire.Hosting.Azure.ServiceBus (4)
Aspire.Hosting.Azure.SignalR (3)
Aspire.Hosting.Azure.Storage (4)
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 (75)
Aspire.Hosting.Yarp (1)
Aspire.Playground.Tests (3)
Pipelines.Library (1)
Stress.AppHost (7)