46 interfaces inheriting from IResource
Aspire.Hosting (14)
Aspire.Hosting.Azure (6)
Aspire.Hosting.CodeGeneration.Go.Tests (5)
Aspire.Hosting.CodeGeneration.Java.Tests (5)
Aspire.Hosting.CodeGeneration.Python.Tests (5)
Aspire.Hosting.CodeGeneration.Rust.Tests (5)
Aspire.Hosting.CodeGeneration.TypeScript.Tests (6)
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)
1554 references to IResource
Aspire.Hosting (637)
ApplicationModel\ResourceCommandService.cs (6)
115public async Task<ExecuteCommandResult> ExecuteCommandAsync(IResource resource, string commandName, CancellationToken cancellationToken = default)
130public async Task<ExecuteCommandResult> ExecuteCommandAsync(IResource resource, string commandName, InteractionInputCollection arguments, CancellationToken cancellationToken = default)
230private static (InteractionInputCollection Arguments, string? ErrorMessage) CreateCommandArguments(IResource resource, string commandName, IReadOnlyDictionary<string, string?>? argumentValues)
313internal async Task<ExecuteCommandResult> ExecuteCommandAsync(IResource resource, string commandName, IReadOnlyDictionary<string, string?>? argumentValues, CancellationToken cancellationToken)
326internal async Task<ExecuteCommandResult> ExecuteCommandCoreAsync(string resourceId, IResource resource, string commandName, InteractionInputCollection arguments, bool argumentsProvided, bool nonInteractive, CancellationToken cancellationToken)
529private static ResourceCommandAnnotation? ResolveCommandAnnotation(IResource resource, ref string commandName, ILogger? logger = null)
ApplicationModel\ResourceExtensions.cs (89)
18/// Provides extension methods for the <see cref="IResource"/> interface.
30public static bool TryGetLastAnnotation<T>(this IResource resource, [NotNullWhen(true)] out T? annotation) where T : IResourceAnnotation
54public static bool TryGetAnnotationsOfType<T>(this IResource resource, [NotNullWhen(true)] out IEnumerable<T>? result) where T : IResourceAnnotation
77public static bool HasAnnotationOfType<T>(this IResource resource) where T : IResourceAnnotation
90public static bool TryGetAnnotationsIncludingAncestorsOfType<T>(this IResource resource, [NotNullWhen(true)] out IEnumerable<T>? result) where T : IResourceAnnotation
128public static bool HasAnnotationIncludingAncestorsOfType<T>(this IResource resource) where T : IResourceAnnotation
162public static bool TryGetEnvironmentVariables(this IResource resource, [NotNullWhen(true)] out IEnumerable<EnvironmentCallbackAnnotation>? environmentVariables)
266this IResource resource,
299IResource resource,
351this IResource resource,
391this IResource resource,
414this IResource resource,
448this IResource resource,
484this IResource resource,
509this IResource resource,
547where T : IResource, IComputeResource
567where T : IResource, IComputeResource
575internal static NetworkIdentifier GetDefaultResourceNetwork(this IResource resource)
580internal static IEnumerable<NetworkIdentifier> GetSupportedNetworks(this IResource resource)
586this IResource resource,
597(DistributedApplicationOperation.Run, IResourceBuilder<IResource> rb) when rb.Resource is IValueProvider provider => await resource.GetValue(executionContext, key, provider, logger, cancellationToken).ConfigureAwait(false),
599(DistributedApplicationOperation.Publish, IResourceBuilder<IResource> rb) when rb.Resource is IManifestExpressionProvider provider => new(provider.ValueExpression, false),
610public static bool IsExcludedFromPublish(this IResource resource) =>
614this IResource resource,
657private static async Task<ResolvedValue?> GetValue(this IResource resource, DistributedApplicationExecutionContext executionContext, string? key, IValueProvider valueProvider, ILogger logger, CancellationToken cancellationToken)
663if (valueProvider is IResource providerResource)
721public static bool TryGetContainerMounts(this IResource resource, [NotNullWhen(true)] out IEnumerable<ContainerMountAnnotation>? volumeMounts)
733public static bool TryGetEndpoints(this IResource resource, [NotNullWhen(true)] out IEnumerable<EndpointAnnotation>? endpoints)
745public static bool TryGetUrls(this IResource resource, [NotNullWhen(true)] out IEnumerable<ResourceUrlAnnotation>? urls)
754/// <returns>An enumeration of <see cref="EndpointReference"/> based on the <see cref="EndpointAnnotation"/> annotations from the resources' <see cref="IResource.Annotations"/> collection.</returns>
771/// <returns>An enumeration of <see cref="EndpointReference"/> based on the <see cref="EndpointAnnotation"/> annotations from the resources' <see cref="IResource.Annotations"/> collection.</returns>
838public static IReadOnlyList<ResolvedEndpoint> ResolveEndpoints(this IResource resource, IPortAllocator? portAllocator = null)
925public static bool TryGetContainerImageName(this IResource resource, [NotNullWhen(true)] out string? imageName)
938public static bool TryGetContainerImageName(this IResource resource, bool useBuiltImage, [NotNullWhen(true)] out string? imageName)
980public static int GetReplicaCount(this IResource resource)
1002public static bool RequiresImageBuild(this IResource resource)
1023public static bool RequiresImageBuildAndPush(this IResource resource)
1028internal static bool IsBuildOnlyContainer(this IResource resource)
1040public static IComputeEnvironmentResource? GetComputeEnvironment(this IResource resource)
1054public static DeploymentTargetAnnotation? GetDeploymentTargetAnnotation(this IResource resource, IComputeEnvironmentResource? targetComputeEnvironment = null)
1108internal static Lifetime GetLifetimeType(this IResource resource)
1113private static Lifetime GetLifetimeType(IResource resource, HashSet<IResource> visitedResources)
1152internal static bool HasPersistentLifetime(this IResource resource)
1157internal static string GetOtelServiceInstanceId(this IResource resource, DcpInstance instance)
1169internal static bool TryGetParentProcessLifetime(this IResource resource, out int parentProcessId, out DateTime parentProcessTimestamp)
1174private static bool TryGetParentProcessLifetime(IResource resource, HashSet<IResource> visitedResources, out int parentProcessId, out DateTime parentProcessTimestamp)
1213internal static bool TryGetContainerImagePullPolicy(this IResource resource, [NotNullWhen(true)] out ImagePullPolicy? pullPolicy)
1231internal static bool SupportsProxy(this IResource resource)
1241internal static IResource GetRootResource(this IResource resource) =>
1252internal static string GetResolvedResourceName(this IResource resource)
1272internal static string GetResolvedDisplayResourceName(this IResource resource, string resourceId)
1283internal static bool TryGetInstances(this IResource resource, out ImmutableArray<DcpInstance> instances)
1300internal static string[] GetResolvedResourceNames(this IResource resource)
1320this IResource resource,
1360internal static IContainerRegistry GetContainerRegistry(this IResource resource)
1385var registryNames = string.Join(", ", registryTargetAnnotations.Select(a => a.Registry is IResource res ? res.Name : a.Registry.ToString()));
1407this IResource resource,
1450internal static ILogger GetLogger(this IResource resource, IServiceProvider serviceProvider)
1484public static Task<IReadOnlySet<IResource>> GetResourceDependenciesAsync(
1485this IResource resource,
1516public static Task<IReadOnlySet<IResource>> GetResourceDependenciesAsync(
1517this IResource resource,
1547internal static async Task<IReadOnlySet<IResource>> GetDependenciesAsync(
1548IEnumerable<IResource> resources,
1553var dependencies = new HashSet<IResource>();
1554var newDependencies = new HashSet<IResource>();
1555var toProcess = new Queue<IResource>();
1558foreach (var resource in resources)
1567foreach (var nd in newDependencies)
1574var dep = toProcess.Dequeue();
1579foreach (var newDep in newDependencies)
1591foreach (var resource in resources)
1609IResource resource,
1610HashSet<IResource> dependencies,
1611HashSet<IResource> newDependencies,
1634IResource resource,
1740private static void CollectAnnotationDependencies(IResource resource, HashSet<IResource> dependencies, HashSet<IResource> newDependencies)
1778HashSet<IResource> dependencies,
1779HashSet<IResource> newDependencies,
1794if (value is IResource resource)
1803if (value is IResourceBuilder<IResource> resourceBuilder)
1824HashSet<IResource> dependencies,
1825HashSet<IResource> newDependencies,
1861internal static string GetResourceType(this IResource resource) => resource switch
ApplicationModel\ResourceNotificationService.cs (24)
142private async Task WaitUntilHealthyAsync(IResource resource, IResource dependency, WaitBehavior waitBehavior, CancellationToken cancellationToken, Func<string, Task>? onDependencyReady = null)
298private async Task WaitUntilCompletionAsync(IResource resource, IResource dependency, int exitCode, CancellationToken cancellationToken, Func<string, Task>? onDependencyReady = null)
372private async Task WaitUntilStateAsync(IResource resource, IResource dependency, WaitBehavior waitBehavior,
448private async Task WaitUntilStartedAsync(IResource resource, IResource dependency, WaitBehavior waitBehavior, CancellationToken cancellationToken, Func<string, Task>? onDependencyReady = null)
476public async Task WaitForDependenciesAsync(IResource resource, CancellationToken cancellationToken)
597private Task PublishWaitingForDependenciesAsync(IResource resource, IEnumerable<string> dependencyNames)
626private Task ClearWaitingForDependenciesAsync(IResource resource)
828public Task PublishUpdateAsync(IResource resource, string resourceId, Func<CustomResourceSnapshot, CustomResourceSnapshot> stateFactory)
955IResource resource,
1042IResource resource,
1090private CustomResourceSnapshot UpdateCommands(IResource resource, CustomResourceSnapshot previousState)
1170private static CustomResourceSnapshot UpdateIcons(IResource resource, CustomResourceSnapshot previousState)
1198private static CustomResourceSnapshot UpdateDashboardVisibility(IResource resource, CustomResourceSnapshot previousState)
1229public async Task PublishUpdateAsync(IResource resource, Func<CustomResourceSnapshot, CustomResourceSnapshot> stateFactory)
1238private static CustomResourceSnapshot GetCurrentSnapshot(IResource resource, ResourceNotificationState notificationState)
1266private ResourceNotificationState GetResourceNotificationState(string resourceId, IResource resource) =>
1388private sealed class ResourceNotificationState(IResource resource)
1393public IResource Resource { get; } = resource;
1442public class ResourceEvent(IResource resource, string resourceId, CustomResourceSnapshot snapshot)
1447public IResource Resource { get; } = resource;
Dcp\ContainerCreator.cs (13)
27internal static HostResourceWithEndpoints? Create(IResource resource)
141foreach (var container in modelContainerResources)
210private static void ApplyMonitorProcess(IResource resource, ContainerSpec spec)
219private void ValidateContainerTunnelContainerNameConflicts(IEnumerable<IResource> modelContainerResources)
226foreach (var container in modelContainerResources)
303var modelContainer = cr.ModelResource;
636internal async Task<IEnumerable<HostResourceWithEndpoints>> GetHostDependenciesAsync(IResource resource, CancellationToken cancellationToken)
653if (_model.Resources.TryGetByName(KnownResourceNames.AspireDashboard, out var dashboardResource)
903private async Task<(List<string>, bool)> BuildRunArgsAsync(ILogger resourceLogger, IResource modelResource, CancellationToken cancellationToken)
929private static async Task ApplyBuildArgumentsAsync(Container dcpContainerResource, IResource modelContainerResource, DistributedApplicationExecutionContext executionContext, ILogger logger, CancellationToken cancellationToken)
1059private static List<VolumeMount> BuildContainerMounts(IResource container)
1080private void EnsureRequiredAnnotations(IResource resource)
1088public required IResource Resource { get; init; }
Dcp\DcpExecutor.cs (17)
213List<IResource> endpointAllocatedResources = [];
240foreach (var resource in endpointAllocatedResources.Distinct())
374internal static string GetResourceType<T>(T resource, IResource appModelResource) where T : CustomResource
747private static bool GetEffectiveIsProxied(IResource resource, EndpointAnnotation endpoint, bool randomizePorts)
780private static bool TryGetEffectiveFixedPublicPort(IResource resource, EndpointAnnotation endpoint, bool randomizePorts, out int publicPort)
802private void EnsureProxylessEndpointPort(IResource resource, EndpointAnnotation endpoint)
837private static bool NeedsPublicPort(IResource resource, EndpointAnnotation endpoint)
846private int? TryGetPersistedProxylessEndpointPort(IResource resource, EndpointAnnotation endpoint)
869private static string GetPersistedProxylessEndpointPortKey(IResource resource, EndpointAnnotation endpoint)
876internal static void SetInitialResourceState(IResource resource, IAnnotationHolder annotationHolder)
910var groupKey = group.Key;
921IResource modelResource,
1077internal static DcpInstance GetDcpInstance(IResource resource, int instanceIndex)
1333private static void ForgetCachedCallbackResults(IResource resource)
1360private void ForgetConnectionStringAvailableEvent(IResource resource)
1368private async Task<bool> PublishEndpointsAllocatedEventAsync(IResource resource, CancellationToken ct)
1383private async Task PublishConnectionStringAvailableEventAsync(IResource resource, CancellationToken ct)
Dcp\DcpExecutorEvents.cs (4)
11internal record OnResourceStartingContext(CancellationToken CancellationToken, string ResourceType, IResource Resource, string? DcpResourceName);
12internal record OnConnectionStringAvailableContext(CancellationToken CancellationToken, IResource Resource);
14internal record OnResourceChangedContext(CancellationToken CancellationToken, string ResourceType, IResource Resource, string DcpResourceName, ResourceStatus Status, Func<CustomResourceSnapshot, CustomResourceSnapshot> UpdateSnapshot);
15internal record OnResourceFailedToStartContext(CancellationToken CancellationToken, string ResourceType, IResource Resource, string? DcpResourceName, string? ErrorMessage = null);
Dcp\DcpNameGenerator.cs (8)
35public void EnsureDcpInstancesPopulated(IResource resource)
67private static void AddInstancesAnnotation(IResource resource, ImmutableArray<DcpInstance> instances)
72private static void ThrowIfPersistentExecutableHasReplicas(IResource resource)
85public (string Name, string Suffix) GetContainerName(IResource container)
96public (string Name, string Suffix) GetExecutableName(IResource project)
109public (string, bool) GetServiceName(IResource resource, EndpointAnnotation endpoint, NetworkIdentifier targetNetworkId)
157public static string GetObjectNameForResource(IResource resource, DcpOptions options, string suffix = "")
176private static string NetworkServiceKey(IResource resource, EndpointAnnotation endpoint, NetworkIdentifier targetNetworkId)
Diagnostics\ProfilingTelemetry.cs (13)
385IResource appModelResource,
402public static ActivityScope StartResourceBeforeStartWait(IConfiguration? configuration, IResource resource)
409public static ActivityScope StartResourceCreate(IConfiguration? configuration, IResource resource, string resourceKind, int replicaCount)
419IResource resource,
429public static ActivityScope StartResourceStart(IConfiguration? configuration, IResource resource, string resourceKind, string resourceName, string resourceType)
467public static ActivityScope StartResourceStop(IConfiguration? configuration, IResource resource, string resourceKind, string resourceName)
475public static ActivityScope StartResourceWaitForDependencies(IConfiguration? configuration, IResource resource, int dependencyCount)
483public static ActivityScope StartResourceWaitForDependency(IConfiguration? configuration, IResource resource, IResource dependency, WaitType waitType, WaitBehavior? waitBehavior)
993public void SetDependencyWait(IResource resource, IResource dependency, WaitType waitType, WaitBehavior? waitBehavior)
1017public void SetResource(IResource resource)
1033public void SetResourceLifecycle(IResource resource, string resourceId, CustomResourceSnapshot snapshot)
Orchestrator\ApplicationOrchestrator.cs (16)
25private readonly ILookup<IResource, IResource> _parentChildLookup;
208private async Task PublishResourceEndpointUrls(IResource resource, CancellationToken cancellationToken)
218private static IEnumerable<UrlSnapshot> GetResourceUrls(IResource resource)
285static Task PublishUpdateAsync(ResourceNotificationService notificationService, IResource resource, string? resourceId, Func<CustomResourceSnapshot, CustomResourceSnapshot> stateFactory)
303private async Task ProcessResourceUrlCallbacks(IResource resource, CancellationToken cancellationToken)
689private async Task SetChildResourceAsync(IResource resource, string? state, DateTime? startTimeStamp, DateTime? stopTimeStamp)
691foreach (var child in _parentChildLookup[resource].Where(c => c is IResourceWithParent))
718foreach (var resource in _model.Resources)
722var parent = resource is IResourceWithParent hasParent
744private static ImmutableArray<HealthReportSnapshot> GetInitialHealthReports(IResource resource)
755private async Task PublishConnectionStringAvailableEvent(IResource resource, CancellationToken cancellationToken)
781private async Task PublishEventToHierarchy<TEvent>(Func<IResource, TEvent> createEvent, IResource resource, CancellationToken cancellationToken)
790foreach (var child in children.Where(c => c is IResourceWithParent))
805private 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)
143Task BuildImageAsync(IResource resource, CancellationToken cancellationToken = default);
151Task BuildImagesAsync(IEnumerable<IResource> resources, CancellationToken cancellationToken = default);
158Task PushImageAsync(IResource resource, CancellationToken cancellationToken);
184IResource resource,
209public async Task BuildImagesAsync(IEnumerable<IResource> resources, CancellationToken cancellationToken = default)
230foreach (var resource in resources)
239public async Task BuildImageAsync(IResource resource, CancellationToken cancellationToken = default)
300private async Task BuildProjectContainerImageAsync(IResource resource, ResolvedContainerBuildOptions options, CancellationToken cancellationToken)
327private async Task ExecuteDotnetPublishAsync(IResource resource, ResolvedContainerBuildOptions options, CancellationToken cancellationToken)
451private async Task BuildContainerImageFromDockerfileAsync(IResource resource, DockerfileBuildAnnotation dockerfileBuildAnnotation, string imageName, ResolvedContainerBuildOptions options, CancellationToken cancellationToken)
542public async Task PushImageAsync(IResource resource, CancellationToken cancellationToken)
549private async Task<bool> ResourcesRequireContainerRuntimeAsync(IEnumerable<IResource> resources, CancellationToken cancellationToken)
551foreach (var resource in resources)
ResourceBuilderExtensions.cs (87)
62where T : IResource
94where T : IResource
118where T : IResource
119where TSource : IResource
167where T : IResource
190where T : IResource
211where T : IResource
758public static IResourceBuilder<T> WithManifestPublishingCallback<T>(this IResourceBuilder<T> builder, Action<ManifestPublishingContext> callback) where T : IResource
776public static IResourceBuilder<T> WithManifestPublishingCallback<T>(this IResourceBuilder<T> builder, Func<ManifestPublishingContext, Task> callback) where T : IResource
913[AspireUnion(typeof(IResourceBuilder<IResource>), typeof(EndpointReference), typeof(string), typeof(Uri))] object source,
924IResourceBuilder<IResource> resourceBuilder => WithReferenceResource(builder, resourceBuilder, connectionName, optional, name),
938IResourceBuilder<IResource> source,
952IResourceBuilder<IResource> source,
1033IResourceBuilder<IResource> source,
1050IResourceBuilder<IResource> source,
1076IResourceBuilder<IResource> source,
1081where TCustom : class, IResource, IResourceWithCustomWithReference<TCustom>
1979where T : IResource
2003where T : IResource
2041where T : IResource
2075where T : IResource
2103where T : IResource
2126where T : IResource
2184where T : IResource
2329public static IResourceBuilder<T> ExcludeFromManifest<T>(this IResourceBuilder<T> builder) where T : IResource
2347/// resources, calling <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource})"/> also results
2364public static IResourceBuilder<T> WaitFor<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency) where T : IResourceWithWaitSupport
2378IResourceBuilder<IResource> dependency,
2401/// resources, calling <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource}, WaitBehavior)"/> also results
2409/// behavior with the <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource})"/> overload.</para>
2424public static IResourceBuilder<T> WaitFor<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, WaitBehavior waitBehavior) where T : IResourceWithWaitSupport
2432private static IResourceBuilder<T> WaitForCore<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, WaitBehavior? waitBehavior, bool addRelationship) where T : IResourceWithWaitSupport
2434if (builder.Resource as IResource == dependency.Resource)
2474/// <para>Unlike <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource})"/>, this method
2489public static IResourceBuilder<T> WaitForStart<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency) where T : IResourceWithWaitSupport
2503IResourceBuilder<IResource> dependency,
2526/// <para>Unlike <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource}, WaitBehavior)"/>, this method
2532/// behavior with the <see cref="WaitForStart{T}(IResourceBuilder{T}, IResourceBuilder{IResource})"/> overload.</para>
2547public static IResourceBuilder<T> WaitForStart<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, WaitBehavior waitBehavior) where T : IResourceWithWaitSupport
2555private static IResourceBuilder<T> WaitForStartCore<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, WaitBehavior? waitBehavior, bool addRelationship) where T : IResourceWithWaitSupport
2557if (builder.Resource as IResource == dependency.Resource)
2582foreach (var referencedResource in cs.ConnectionStringExpression.ValueProviders.OfType<IResource>())
2621public static IResourceBuilder<T> WithExplicitStart<T>(this IResourceBuilder<T> builder) where T : IResource
2655public static IResourceBuilder<T> WaitForCompletion<T>(this IResourceBuilder<T> builder, IResourceBuilder<IResource> dependency, int exitCode = 0) where T : IResourceWithWaitSupport
2660if (builder.Resource as IResource == dependency.Resource)
2687/// the <see cref="WaitFor{T}(IResourceBuilder{T}, IResourceBuilder{IResource})"/> to associate a resource
2715public static IResourceBuilder<T> WithHealthCheck<T>(this IResourceBuilder<T> builder, string key) where T : IResource
2917CommandOptions? commandOptions = null) where T : IResource
2987bool isHighlighted = false) where T : IResource
3062where TResource : IResource
3125where TResource : IResource
3183where TResource : IResource
3228where TResource : IResource
3266where TResource : IResource
4320where TResource : IResource
4440IResource resource,
4441string type) where T : IResource
4461IResourceBuilder<IResource> resourceBuilder,
4462string type) where T : IResource
4481IResource resource) where T : IResource
4500ReferenceExpression expression) where T : IResource
4511where T : IResource
4515void AddReference(IResource resource)
4527if (value is IResource resource)
4531else if (value is IResourceBuilder<IResource> resourceBuilder)
4561IResourceBuilder<IResource> resourceBuilder) where T : IResource
4597IResourceBuilder<IResource> parent) where T : IResource
4629IResource parent) where T : IResource
4663IResourceBuilder<IResource> child) where T : IResource
4697IResource child) where T : IResource
4734public static IResourceBuilder<T> WithIconName<T>(this IResourceBuilder<T> builder, string iconName, IconVariant iconVariant = IconVariant.Filled) where T : IResource
4861where T : IResource
4901where T : IResource
4958where T : IResource
5119public static IResourceBuilder<T> ExcludeFromMcp<T>(this IResourceBuilder<T> builder) where T : IResource
5139public static IResourceBuilder<T> WithHidden<T>(this IResourceBuilder<T> builder) where T : IResource
5159public static IResourceBuilder<T> WithHiddenOnCompletion<T>(this IResourceBuilder<T> builder, int exitCode) where T : IResource
5182internal static IResourceBuilder<T> WithHiddenOnCompletionExport<T>(this IResourceBuilder<T> builder, int? exitCode = null, int[]? exitCodes = null) where T : IResource
5204public static IResourceBuilder<T> WithHiddenOnCompletion<T>(this IResourceBuilder<T> builder, params int[] exitCodes) where T : IResource
5212private static IResourceBuilder<T> WithHiddenOnCompletionCore<T>(IResourceBuilder<T> builder, IReadOnlyList<int> exitCodes) where T : IResource
Aspire.Hosting.Azure (74)
AzureProvisioningController.cs (48)
1026IReadOnlyList<(IResource Resource, IAzureResource AzureResource)> azureResources,
1092private static bool HasMissingAzureContextFailure(IReadOnlyList<(IResource Resource, IAzureResource AzureResource)> azureResources)
1096private static ImmutableArray<ResourcePropertySnapshot> CreateAzureEnvironmentFailureProperties(IReadOnlyList<(IResource Resource, IAzureResource AzureResource)> azureResources)
1110private static Exception? GetProvisioningFailureException(IReadOnlyList<(IResource Resource, IAzureResource AzureResource)> azureResources)
1115private static string CreateProvisioningFailureMessage(IReadOnlyList<(IResource Resource, IAzureResource AzureResource)> azureResources)
1129IReadOnlyList<(IResource Resource, IAzureResource AzureResource)> azureResources,
1146IReadOnlyCollection<(IResource Resource, IAzureResource AzureResource)> azureResources,
1220private static List<(IResource Resource, IAzureResource AzureResource)> GetProvisionableAzureResources(DistributedApplicationModel model)
1231private static List<(IResource Resource, IAzureResource AzureResource)> GetTargetAzureResources(
1248var queue = new Queue<(IResource Resource, IAzureResource AzureResource)>();
1249var targetResources = new List<(IResource Resource, IAzureResource AzureResource)>();
1261foreach (var child in parentChildLookup[current.Resource])
1271foreach (var child in parentChildLookup[current.AzureResource])
1294void Enqueue((IResource Resource, IAzureResource AzureResource) resource)
1303private static ILookup<IResource, IResource> GetTargetParentChildLookup(DistributedApplicationModel model, bool includeAnnotationParentRelationships)
1313private static IEnumerable<IResource> GetResourceParents(IResource resource, bool includeAnnotationParentRelationships)
1339private static void ThrowIfKeyVaultLocationChangeTarget(IReadOnlyList<(IResource Resource, IAzureResource AzureResource)> targetResources)
1360IReadOnlyList<(IResource Resource, IAzureResource AzureResource)> azureResources,
1361IResource target,
1362out (IResource Resource, IAzureResource AzureResource) azureResource)
1377private static List<(IResource Resource, IAzureResource AzureResource)> GetActiveOperationTargetAzureResources(DistributedApplicationModel model, ActiveAzureOperation activeOperation)
2784private static string GetDeploymentStateResourceName((IResource Resource, IAzureResource AzureResource) resource)
2788IReadOnlyCollection<(IResource Resource, IAzureResource AzureResource)> targetResources,
2889IReadOnlyCollection<(IResource Resource, IAzureResource AzureResource)> targetResources,
3378private bool ShouldCheckForDrift(IResource resource)
3605private CustomResourceSnapshot ApplyActiveOperationProperties(IResource resource, CustomResourceSnapshot state)
3636foreach (var resource in GetResourcesForCommandStateRefresh(model))
3644private static IEnumerable<IResource> GetResourcesForCommandStateRefresh(DistributedApplicationModel model)
3647var resources = new List<IResource>();
3664void Add(IResource resource)
3674(IResource Resource, IAzureResource AzureResource) resource,
3675ILookup<IResource, IResourceWithParent> parentChildLookup,
3678async Task PublishAsync(IResource targetResource)
3714(IResource Resource, IAzureResource AzureResource) resource,
3715ILookup<IResource, IResourceWithParent> parentChildLookup)
3767IReadOnlyList<(IResource Resource, IAzureResource AzureResource)> targetResources,
3785(IResource Resource, IAzureResource AzureResource) resource,
3786ILookup<IResource, IResourceWithParent> parentChildLookup)
3854(IResource Resource, IAzureResource AzureResource) resource,
3855ILookup<IResource, IResourceWithParent> parentChildLookup)
3884IReadOnlyList<(IResource Resource, IAzureResource AzureResource)> azureResources,
3885ILookup<IResource, IResourceWithParent> parentChildLookup,
3907(IResource Resource, IAzureResource AzureResource) resource,
3908ILookup<IResource, IResourceWithParent> parentChildLookup,
4096IResource targetResource,
4097ILookup<IResource, IResourceWithParent> parentChildLookup,
AzureResourcePreparer.cs (15)
63private static void AddPerResourceCommands(List<(IResource Resource, IAzureResource AzureResource)> azureResources)
98private static string GetDeploymentStateResourceName((IResource Resource, IAzureResource AzureResource) resource)
102IResource resource,
128internal static List<(IResource Resource, IAzureResource AzureResource)> GetAzureResourcesFromAppModel(DistributedApplicationModel appModel)
135var azureResources = new List<(IResource, IAzureResource)>();
136foreach (var resource in appModel.Resources)
167foreach (var resource in appModel.Resources)
181private async Task BuildRoleAssignmentAnnotations(DistributedApplicationModel appModel, List<(IResource Resource, IAzureResource AzureResource)> azureResources, CancellationToken cancellationToken)
211foreach (var resource in resourceSnapshot)
273foreach (var dependency in directDependencies)
361private static Dictionary<AzureProvisioningResource, IEnumerable<RoleDefinition>> GetAllRoleAssignments(IResource resource)
380IResource resource,
410IResource resource,
510if (!appModel.Resources.TryGetByName(roleAssignmentResource.Name, out var existingResource))
528private static void AddDeploymentPrerequisitesAnnotation(IResource resource, HashSet<AzureBicepResource> prerequisiteResources)
Aspire.Hosting.Azure.AppConfiguration (4)
Aspire.Hosting.Azure.AppContainers (28)
Aspire.Hosting.Azure.AppService (25)
Aspire.Hosting.Azure.CognitiveServices (4)
Aspire.Hosting.Azure.ContainerRegistry (7)
Aspire.Hosting.Azure.EventHubs (4)
Aspire.Hosting.Azure.FrontDoor (2)
Aspire.Hosting.Azure.Functions (12)
Aspire.Hosting.Azure.KeyVault (6)
Aspire.Hosting.Azure.Kubernetes (2)
Aspire.Hosting.Azure.Kusto (3)
Aspire.Hosting.Azure.Network (2)
Aspire.Hosting.Azure.Search (4)
Aspire.Hosting.Azure.ServiceBus (4)
Aspire.Hosting.Azure.SignalR (4)
Aspire.Hosting.Azure.Sql (4)
Aspire.Hosting.Azure.Storage (4)
Aspire.Hosting.Azure.Tests (86)
AzureRunAsEmulatorModeTests.cs (5)
11public static TheoryData<string, Func<IDistributedApplicationBuilder, Action, IResource>> RunAsEmulatorResources => new()
25public void RunAsEmulator_InRunMode_ConfiguresLocalContainer(string resourceType, Func<IDistributedApplicationBuilder, Action, IResource> addResource)
30var resource = addResource(builder, () => callbackInvoked = true);
39public void RunAsEmulator_InPublishMode_DoesNotConfigureLocalContainer(string resourceType, Func<IDistributedApplicationBuilder, Action, IResource> addResource)
44var resource = addResource(builder, () => callbackInvoked = true);
Aspire.Hosting.Azure.WebPubSub (4)
Aspire.Hosting.Blazor (17)
Aspire.Hosting.Blazor.Tests (16)
Aspire.Hosting.CodeGeneration.Go.Tests (24)
Aspire.Hosting.CodeGeneration.Java.Tests (24)
Aspire.Hosting.CodeGeneration.Python.Tests (24)
Aspire.Hosting.CodeGeneration.Rust.Tests (24)
Aspire.Hosting.CodeGeneration.TypeScript.Tests (26)
Aspire.Hosting.Containers.Tests (14)
Aspire.Hosting.DevTunnels (7)
Aspire.Hosting.DevTunnels.Tests (1)
Aspire.Hosting.Docker (28)
Aspire.Hosting.Docker.Tests (14)
Aspire.Hosting.Dotnet (9)
Aspire.Hosting.EntityFrameworkCore (4)
Aspire.Hosting.EntityFrameworkCore.Tests (2)
Aspire.Hosting.Foundry (12)
Aspire.Hosting.Foundry.Tests (4)
Aspire.Hosting.Go (3)
Aspire.Hosting.Go.Tests (7)
Aspire.Hosting.Java (1)
Aspire.Hosting.Java.Tests (6)
Aspire.Hosting.JavaScript (2)
Aspire.Hosting.JavaScript.Tests (9)
Aspire.Hosting.Kafka.Tests (1)
Aspire.Hosting.Keycloak.Tests (2)
Aspire.Hosting.Kubernetes (46)
KubernetesEnvironmentResource.cs (16)
184internal sealed record CapturedHelmImageReference(string Section, string ResourceKey, string ValueKey, IResource Resource);
206internal sealed record TlsSecretRequest(ReferenceExpression SecretName, ReferenceExpression Hostname, IResource Owner);
333foreach (var computeResource in resources)
336var deploymentTarget = computeResource.GetDeploymentTargetAnnotation(targetEnv)?.DeploymentTarget;
370foreach (var computeResource in resources)
373var deploymentTarget = computeResource.GetDeploymentTargetAnnotation(targetEnv)?.DeploymentTarget;
459var deploymentTargets = new Dictionary<IResource, KubernetesResource>(new ResourceNameComparer());
461foreach (var r in appModel.GetComputeResources())
570private static void ConfigureOtlp(IResource resource, EndpointReference otlpEndpoint)
715private async Task ProcessIngressResources(DistributedApplicationModel model, Dictionary<IResource, KubernetesResource> deploymentTargets, ILogger logger, CancellationToken cancellationToken)
755Dictionary<IResource, KubernetesResource> deploymentTargets,
920Dictionary<IResource, KubernetesResource> deploymentTargets,
956private async Task ProcessGatewayResources(DistributedApplicationModel model, Dictionary<IResource, KubernetesResource> deploymentTargets, ILogger logger, CancellationToken cancellationToken)
1053Dictionary<IResource, KubernetesResource> deploymentTargets,
1229Dictionary<IResource, KubernetesResource> deploymentTargets,
1314internal static bool OwnerWasMaterialized(IResource owner) => owner switch
Aspire.Hosting.Kubernetes.Tests (7)
Aspire.Hosting.Maui (10)
Aspire.Hosting.Maui.Tests (22)
MauiBuildQueueTests.cs (10)
741private static void AddOriginalStopCommand(IResource resource, Action? onExecute = null)
786private static async Task WaitForStateAsync(BuildQueueTestEnvironment env, IResource resource, string state)
820public Task WaitForBuildStartedAsync(IResource resource, TimeSpan? timeout = null)
826public void CompleteBuild(IResource resource)
832public void CompleteBuildImmediately(IResource resource)
838public void FailBuild(IResource resource, string message)
845public void FailBuildWith(IResource resource, Exception exception)
851internal override async Task RunBuildAsync(IResource resource, ILogger logger, CancellationToken cancellationToken)
886internal override Task ReleaseSemaphoreAfterLaunchAsync(IResource resource, SemaphoreSlim semaphore, string? stateAtCallTime, ILogger logger, CancellationToken cancellationToken)
912internal override Task ReleaseSemaphoreAfterLaunchAsync(IResource resource, SemaphoreSlim semaphore, string? stateAtCallTime, ILogger logger, CancellationToken cancellationToken)
Aspire.Hosting.Milvus.Tests (2)
Aspire.Hosting.MySql (1)
Aspire.Hosting.MySql.Tests (4)
Aspire.Hosting.Oracle.Tests (3)
Aspire.Hosting.Orleans.Tests (1)
Aspire.Hosting.PostgreSQL (3)
Aspire.Hosting.PostgreSQL.Tests (9)
Aspire.Hosting.Python.Tests (1)
Aspire.Hosting.Qdrant (1)
Aspire.Hosting.Qdrant.Tests (6)
Aspire.Hosting.Radius (33)
Publishing\RadiusInfrastructureBuilder.cs (23)
141foreach (var resource in radiusResources)
248foreach (var resource in radiusResources)
277foreach (var resource in computeResources)
628private (string ResourceType, string ApiVersion) ResolveResourceType(IResource resource)
633private (List<IResource> radiusResources, List<IResource> computeResources, Dictionary<IResource, (string ResourceType, string ApiVersion)> resolvedTypes) ClassifyResources()
635var radiusTypes = new List<IResource>();
636var compute = new List<IResource>();
637var resolved = new Dictionary<IResource, (string ResourceType, string ApiVersion)>();
640foreach (var resource in _model.Resources)
656var resolvedResource = ResolveToParent(resource);
693private bool IsTargetedToThisEnvironment(IResource resource)
712private static IResource ResolveToParent(IResource resource)
945private static string GetContainerImage(IResource resource)
989IResource resource,
990List<IResource> radiusResources,
1002var referencedResource = reference.Resource;
1063private static Dictionary<string, ContainerPortConstruct> ResolvePorts(IResource resource)
1114private async Task<Dictionary<string, ContainerEnvVarConstruct>> ResolveEnvironmentAsync(IResource resource)
1187private async Task ResolveEnvPartsAsync(object? value, IResource owner, List<EnvPart> parts)
1244private async Task ResolveReferenceExpressionPartsAsync(ReferenceExpression expression, IResource owner, List<EnvPart> parts)
Aspire.Hosting.Radius.Tests (13)
Aspire.Hosting.Redis (2)
Aspire.Hosting.Redis.Tests (4)
Aspire.Hosting.RemoteHost.Tests (6)
Aspire.Hosting.Rust.Tests (1)
Aspire.Hosting.SqlServer (1)
Aspire.Hosting.Testing (11)
Aspire.Hosting.Testing.Tests (3)
Aspire.Hosting.Tests (125)
ApplicationModel\ResourceCollectionTests.cs (13)
17var found = collection.TryGetByName("myResource", out var result);
30var found = collection.TryGetByName("MYRESOURCE", out var result);
42var found = collection.TryGetByName("missing", out var result);
53var found = collection.TryGetByName("anything", out var result);
122Assert.True(collection.TryGetByName("res2", out var result));
136Assert.True(collection.TryGetByName("new", out var result));
190Assert.True(collection.TryGetByName("res", out var result));
197var resources = new IResource[]
209var resources = new IResource[]
216Assert.True(collection.TryGetByName("res1", out var r1));
219Assert.True(collection.TryGetByName("res2", out var r2));
232Assert.True(collection.TryGetByName("test", out var result));
248private sealed class SimpleResourceCollection : Collection<IResource>, IResourceCollection
Dashboard\DashboardEventHandlersTests.cs (9)
53var dashboardResource = model.Resources.Single(r => string.Equals(r.Name, KnownResourceNames.AspireDashboard, StringComparisons.ResourceName));
102var dashboardResource = model.Resources.Single(r => string.Equals(r.Name, KnownResourceNames.AspireDashboard, StringComparisons.ResourceName));
194var dashboardResource = model.Resources.Single(r => string.Equals(r.Name, KnownResourceNames.AspireDashboard, StringComparisons.ResourceName));
451var dashboardResource = model.Resources.Single(r => string.Equals(r.Name, KnownResourceNames.AspireDashboard, StringComparisons.ResourceName));
534var dashboardResource = model.Resources.Single(r => string.Equals(r.Name, KnownResourceNames.AspireDashboard, StringComparisons.ResourceName));
608var dashboardResource = Assert.Single(model.Resources);
691var dashboardResource = Assert.Single(model.Resources);
760var dashboardResource = Assert.Single(model.Resources);
827var dashboardResource = Assert.Single(model.Resources);
Dashboard\DashboardResourceTests.cs (16)
113var dashboard = Assert.Single(model.Resources);
209var dashboard = Assert.Single(model.Resources);
243var dashboard = Assert.Single(model.Resources);
286var dashboard = Assert.Single(model.Resources);
314var dashboard = Assert.Single(model.Resources);
383var dashboard = Assert.Single(model.Resources);
423var dashboard = Assert.Single(model.Resources);
459var dashboard = Assert.Single(model.Resources);
498var container = Assert.Single(model.Resources, r => r.Name == "my-container");
502var dashboard = Assert.Single(model.Resources, r => r.Name == "aspire-dashboard");
544var container = Assert.Single(model.Resources, r => r.Name == "my-container");
548var dashboard = Assert.Single(model.Resources, r => r.Name == "aspire-dashboard");
592var dashboard = Assert.Single(model.Resources, r => r.Name == "aspire-dashboard");
624var dashboard = Assert.Single(model.Resources, r => r.Name == "aspire-dashboard");
826var dashboard = Assert.Single(model.Resources);
858static void SetDashboardAllocatedEndpoints(IResource dashboard, int otlpGrpcPort, int otlpHttpPort, int httpPort, int httpsPort)
Aspire.Hosting.TestUtilities (20)
Aspire.Hosting.Yarp (1)
Aspire.Playground.Tests (3)
Pipelines.Library (1)
Stress.AppHost (13)
TestResource.cs (9)
33public static IResourceBuilder<TestNestedResource> AddNestedResource(this IDistributedApplicationBuilder builder, string name, IResource parent)
52public static IResourceBuilder<CommandGroupResource> AddCommandGroup(this IDistributedApplicationBuilder builder, string name, IResource parent)
69public static IResourceBuilder<HttpCommandGroupResource> AddHttpCommandGroup(this IDistributedApplicationBuilder builder, string name, IResource parent)
211sealed class TestNestedResource(string name, IResource parent) : Resource(name), IResourceWithParent
213public IResource Parent { get; } = parent;
216sealed class CommandGroupResource(string name, IResource parent) : Resource(name), IResourceWithParent
218public IResource Parent { get; } = parent;
221sealed class HttpCommandGroupResource(string name, IResource parent) : Resource(name), IResourceWithParent, IResourceWithEndpoints
223public IResource Parent { get; } = parent;