1066 references to Resource
Aspire.Hosting (72)
ContainerResourceBuilderExtensions.cs (13)
115builder.Resource.Entrypoint = entrypoint; 131if (builder.Resource.Annotations.OfType<ContainerImageAnnotation>().LastOrDefault() is { } existingImageAnnotation) 151if (builder.Resource.Annotations.OfType<ContainerImageAnnotation>().LastOrDefault() is { } existingImageAnnotation) 174if (builder.Resource.Annotations.OfType<ContainerImageAnnotation>().LastOrDefault() is { } existingImageAnnotation) 183builder.Resource.Annotations.Add(containerImageAnnotation); 199if (builder.Resource.Annotations.OfType<ContainerImageAnnotation>().LastOrDefault() is { } existingImageAnnotation) 293throw new InvalidOperationException($"The resource '{builder.Resource.Name}' does not have a container image specified. Use WithImage to specify the container image and tag."); 305return builder.WithManifestPublishingCallback(context => context.WriteContainerAsync(builder.Resource)); 473var annotation = builder.Resource.Annotations.OfType<DockerfileBuildAnnotation>().SingleOrDefault(); 524if (value.Resource.Secret) 529return builder.WithBuildArg(name, value.Resource); 571var annotation = builder.Resource.Annotations.OfType<DockerfileBuildAnnotation>().SingleOrDefault(); 578annotation.BuildSecrets[name] = value.Resource;
ExecutableResourceBuilderExtensions.cs (1)
76return builder.WithManifestPublishingCallback(context => WriteExecutableAsDockerfileResourceAsync(context, builder.Resource, buildArgs));
OtlpConfigurationExtensions.cs (1)
121AddOtlpEnvironment(builder.Resource, builder.ApplicationBuilder.Configuration, builder.ApplicationBuilder.Environment);
ParameterResourceBuilderExtensions.cs (2)
229var surrogate = new ResourceWithConnectionStringSurrogate(parameterBuilder.Resource, environmentVariableName); 257var parameter = new ParameterResource(builder.Resource.Name, _ => "", secret: true);
ProjectResourceBuilderExtensions.cs (14)
309var projectResource = builder.Resource; 401builder.Resource.KestrelEndpointAnnotationHosts[e] = endpoint.BindingAddress.Host; 514builder.Resource.DefaultHttpsEndpoint = e; 618builder.Resource.Annotations.Add(new EndpointEnvironmentInjectionFilterAnnotation(filter)); 660foreach (var e in builder.Resource.GetEndpoints().Where(builder.Resource.ShouldInjectEndpointEnvironment)) 712foreach (var e in builder.Resource.GetEndpoints().Where(builder.Resource.ShouldInjectEndpointEnvironment)) 715if (e.EndpointAnnotation.UriScheme == scheme && e.EndpointAnnotation != builder.Resource.DefaultHttpsEndpoint) 741if (builder.Resource.HasKestrelEndpoints) 743foreach (var e in builder.Resource.GetEndpoints().Where(builder.Resource.ShouldInjectEndpointEnvironment)) 746if (e.EndpointAnnotation == builder.Resource.DefaultHttpsEndpoint) 754builder.Resource.KestrelEndpointAnnotationHosts.TryGetValue(e.EndpointAnnotation, out var kestrelHost) ? kestrelHost : "*";
ResourceBuilderExtensions.cs (39)
164context.EnvironmentVariables[name] = parameter.Resource; 188context.EnvironmentVariables[envVarName] = new ConnectionStringReference(resource.Resource, optional: false); 350var resource = source.Resource; 377ApplyEndpoints(builder, source.Resource); 435var endpointReferenceAnnotation = builder.Resource.Annotations 477var endpoint = builder.Resource.Annotations 491builder.Resource.Annotations.Add(endpoint); 530if (builder.Resource.Annotations.OfType<EndpointAnnotation>().Any(sb => string.Equals(sb.Name, annotation.Name, StringComparisons.EndpointAnnotationName))) 536if (env is not null && builder.Resource is IResourceWithEndpoints resourceWithEndpoints and IResourceWithEnvironment) 601if (!builder.Resource.TryGetAnnotationsOfType<EndpointAnnotation>(out var endpoints)) 629return builder.Resource.GetEndpoint(name); 690if (builder.Resource as IResource == dependency.Resource) 692throw new DistributedApplicationException($"The '{builder.Resource.Name}' resource cannot wait for itself."); 695if (builder.Resource is IResourceWithParent resourceWithParent && resourceWithParent.Parent == dependency.Resource) 697throw new DistributedApplicationException($"The '{builder.Resource.Name}' resource cannot wait for its parent '{dependency.Resource.Name}'."); 700if (dependency.Resource is IResourceWithParent dependencyResourceWithParent) 709builder.WithRelationship(dependency.Resource, KnownRelationshipTypes.WaitFor); 711return builder.WithAnnotation(new WaitAnnotation(dependency.Resource, WaitType.WaitUntilHealthy)); 745if (builder.Resource as IResource == dependency.Resource) 747throw new DistributedApplicationException($"The '{builder.Resource.Name}' resource cannot wait for itself."); 750if (builder.Resource is IResourceWithParent resourceWithParent && resourceWithParent.Parent == dependency.Resource) 752throw new DistributedApplicationException($"The '{builder.Resource.Name}' resource cannot wait for its parent '{dependency.Resource.Name}'."); 755builder.WithRelationship(dependency.Resource, KnownRelationshipTypes.WaitFor); 757return builder.WithAnnotation(new WaitAnnotation(dependency.Resource, WaitType.WaitForCompletion, exitCode)); 801if (builder.Resource.TryGetAnnotationsOfType<HealthCheckAnnotation>(out var annotations) && annotations.Any(a => a.Key == key)) 803throw new DistributedApplicationException($"Resource '{builder.Resource.Name}' already has a health check with key '{key}'."); 858var endpoint = builder.Resource.GetEndpoint(endpointName); 864throw new DistributedApplicationException($"The endpoint '{endpointName}' does not exist on the resource '{builder.Resource.Name}'."); 869throw new DistributedApplicationException($"The endpoint '{endpointName}' on resource '{builder.Resource.Name}' was not using the '{desiredScheme}' scheme."); 876builder.ApplicationBuilder.Eventing.Subscribe<BeforeResourceStartedEvent>(builder.Resource, (@event, ct) => 883var healthCheckKey = $"{builder.Resource.Name}_{endpointName}_{path}_{statusCode}_check"; 1002var existingAnnotation = builder.Resource.Annotations.OfType<ResourceCommandAnnotation>().SingleOrDefault(a => a.Name == name); 1005builder.Resource.Annotations.Remove(existingAnnotation);
Utils\ImageNameGenerator.cs (1)
17return $"{builder.Resource.Name}-image-{hex}";
Utils\VolumeNameGenerator.cs (1)
33var resourceName = builder.Resource.Name;
Aspire.Hosting.Azure (18)
AzureBicepResourceExtensions.cs (14)
57return new BicepOutputReference(name, builder.Resource); 68return new BicepSecretOutputReference(name, builder.Resource); 116builder.Resource.Parameters[name] = null; 132builder.Resource.Parameters[name] = value; 148builder.Resource.Parameters[name] = value; 164builder.Resource.Parameters[name] = value; 180builder.Resource.Parameters[name] = valueCallback; 195return builder.WithParameter(name, value.Resource); 210builder.Resource.Parameters[name] = value; 226builder.Resource.Parameters[name] = value.Resource; 242builder.Resource.Parameters[name] = value; 258builder.Resource.Parameters[name] = value; 274builder.Resource.Parameters[name] = value;
AzureProvisioningResourceExtensions.cs (4)
45builder.Resource.ConfigureInfrastructure += configure; 72parameterName ??= Infrastructure.NormalizeBicepIdentifier(parameterResourceBuilder.Resource.Name); 74infrastructure.AspireResource.Parameters[parameterName] = parameterResourceBuilder.Resource; 76return GetOrAddParameter(infrastructure, parameterName, parameterResourceBuilder.Resource.Secret);
Aspire.Hosting.Azure.ApplicationInsights (1)
AzureApplicationInsightsExtensions.cs (1)
64appInsights.WorkspaceResourceId = logAnalyticsWorkspace.Resource.WorkspaceId.AsProvisioningParameter(infrastructure, AzureBicepResource.KnownParameters.LogAnalyticsWorkspaceId);
Aspire.Hosting.Azure.CognitiveServices (1)
AzureOpenAIExtensions.cs (1)
114builder.Resource.AddDeployment(deployment);
Aspire.Hosting.Azure.CosmosDB (6)
AzureCosmosDBExtensions.cs (6)
127builder.ApplicationBuilder.Eventing.Subscribe<ConnectionStringAvailableEvent>(builder.Resource, async (@event, ct) => 129var connectionString = await builder.Resource.ConnectionStringExpression.GetValueAsync(ct).ConfigureAwait(false); 133throw new DistributedApplicationException($"ConnectionStringAvailableEvent was published for the '{builder.Resource.Name}' resource but the connection string was null."); 139var healthCheckKey = $"{builder.Resource.Name}_check"; 149var surrogate = new AzureCosmosDBEmulatorResource(builder.Resource); 229builder.Resource.Databases.Add(databaseName);
Aspire.Hosting.Azure.EventHubs (12)
AzureEventHubsExtensions.cs (12)
87builder.Resource.Hubs.Add(name); 146.AddAzureStorage($"{builder.Resource.Name}-storage") 149var storage = storageResource.Resource; 163builder.ApplicationBuilder.Eventing.Subscribe<ConnectionStringAvailableEvent>(builder.Resource, async (@event, ct) => 165var connectionString = await builder.Resource.ConnectionStringExpression.GetValueAsync(ct).ConfigureAwait(false) 166?? throw new DistributedApplicationException($"ConnectionStringAvailableEvent was published for the '{builder.Resource.Name}' resource but the connection string was null."); 171if (builder.Resource.Hubs is { Count: > 0 } && builder.Resource.Hubs[0] is string hub) 178throw new DistributedApplicationException($"The '{builder.Resource.Name}' resource does not have any Event Hubs."); 182var healthCheckKey = $"{builder.Resource.Name}_check"; 192var surrogate = new AzureEventHubsEmulatorResource(builder.Resource); 262=> builder.WithBindMount(path ?? $".eventhubs/{builder.Resource.Name}", "/data", isReadOnly: false);
Aspire.Hosting.Azure.Functions (7)
AzureFunctionsProjectResourceExtensions.cs (7)
63.RunAsEmulator().Resource; 67storage = builder.AddAzureStorage(storageResourceName).RunAsEmulator().Resource; 163var launchProfile = builder.Resource.GetEffectiveLaunchProfile(); 192builder.Resource.HostStorage = storage.Resource; 209connectionName ??= source.Resource.Name; 210source.Resource.ApplyAzureFunctionsConfiguration(context.EnvironmentVariables, connectionName);
Aspire.Hosting.Azure.PostgreSQL (14)
AzurePostgresExtensions.cs (14)
52var postgres = CreatePostgreSqlFlexibleServer(infrastructure, builder.ApplicationBuilder, builder.Resource.Databases); 68var resource = new AzurePostgresResource(builder.Resource, configureInfrastructure); 71.WithLoginAndPassword(builder.Resource); 80if (builder.Resource.Annotations.OfType<ContainerImageAnnotation>().SingleOrDefault() is { } containerAnnotation) 82builder.Resource.Annotations.Remove(containerAnnotation); 163var azureResource = builder.Resource; 166builder.Resource.AddDatabase(name, databaseName); 212var azureResource = builder.Resource; 232azureResource.SetInnerResource(postgresContainer.Resource); 287var azureResource = builder.Resource; 289azureResource.UserNameParameter = userName?.Resource ?? 293azureResource.PasswordParameter = password?.Resource ?? 294ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder.ApplicationBuilder, $"{builder.Resource.Name}-password"); 474builder.ApplicationBuilder, $"{builder.Resource.Name}-username", secret: false, generatedUserName);
Aspire.Hosting.Azure.Redis (6)
AzureRedisExtensions.cs (6)
59var resource = new AzureRedisResource(builder.Resource, configureInfrastructure); 70if (builder.Resource.Annotations.OfType<ContainerImageAnnotation>().SingleOrDefault() is { } containerAnnotation) 72builder.Resource.Annotations.Remove(containerAnnotation); 157var azureResource = builder.Resource; 162azureResource.SetInnerResource(redisContainer.Resource); 193var azureResource = builder.Resource;
Aspire.Hosting.Azure.ServiceBus (5)
AzureServiceBusExtensions.cs (5)
101builder.Resource.Topics.Add(name); 104builder.Resource.Subscriptions.Add((name, subscription)); 116builder.Resource.Queues.Add(name); 127builder.Resource.Topics.Add(name); 139builder.Resource.Subscriptions.Add((topicName, subscriptionName));
Aspire.Hosting.Azure.Sql (10)
AzureSqlExtensions.cs (10)
24CreateSqlServer(infrastructure, builder.ApplicationBuilder, builder.Resource.Databases); 27var resource = new AzureSqlServerResource(builder.Resource, configureInfrastructure); 38if (builder.Resource.Annotations.OfType<ContainerImageAnnotation>().SingleOrDefault() is { } containerAnnotation) 40builder.Resource.Annotations.Remove(containerAnnotation); 107var azureResource = builder.Resource; 110builder.Resource.AddDatabase(name, databaseName); 121azureSqlDatabase.SetInnerResource(innerDb.Resource); 156var azureResource = builder.Resource; 166azureResource.SetInnerResource(sqlContainer.Resource); 176existingDb.SetInnerResource(innerDb.Resource);
Aspire.Hosting.Azure.Storage (9)
AzureStorageExtensions.cs (9)
108builder.ApplicationBuilder.Eventing.Subscribe<BeforeResourceStartedEvent>(builder.Resource, async (@event, ct) => 110var connectionString = await builder.Resource.GetBlobConnectionString().GetValueAsync(ct).ConfigureAwait(false); 114throw new DistributedApplicationException($"ConnectionStringAvailableEvent was published for the '{builder.Resource.Name}' resource but the connection string was null."); 120var healthCheckKey = $"{builder.Resource.Name}_check"; 131var surrogate = new AzureStorageEmulatorResource(builder.Resource); 159=> builder.WithBindMount(path ?? $".azurite/{builder.Resource.Name}", "/data", isReadOnly); 221var resource = new AzureBlobStorageResource(name, builder.Resource); 233var resource = new AzureTableStorageResource(name, builder.Resource); 245var resource = new AzureQueueStorageResource(name, builder.Resource);
Aspire.Hosting.Azure.Tests (218)
AzureBicepProvisionerTests.cs (5)
24await BicepProvisioner.SetParametersAsync(parameters, bicep0.Resource); 56.WithParameter("expr", ReferenceExpression.Create($"{param.Resource}/1")) 176await BicepProvisioner.SetParametersAsync(parameters0, bicep0.Resource); 177var checkSum0 = BicepProvisioner.GetChecksum(bicep0.Resource, parameters0); 183var checkSum1 = await BicepProvisioner.GetCurrentChecksumAsync(bicep1.Resource, config);
AzureBicepResourceTests.cs (142)
35Assert.Equal("content", bicepResource.Resource.TemplateString); 36Assert.Equal("value1", bicepResource.Resource.Parameters["param1"]); 37Assert.Equal("value2", bicepResource.Resource.Parameters["param2"]); 99if (azureResourceBuilder.Resource is not AzureProvisioningResource bicepResource) 120if (azureResourceBuilder.Resource is not AzureProvisioningResource bicepResource) 138bicepResource.Resource.Outputs["resourceEndpoint"] = "https://myendpoint"; 150bicepResource.Resource.SecretOutputs["connectionString"] = "https://myendpoint;Key=43"; 229Assert.True(cosmos.Resource.IsContainer()); 231var csExpr = cosmos.Resource.ConnectionStringExpression; 237Assert.Equal(cs, await ((IResourceWithConnectionString)cosmos.Resource).GetConnectionStringAsync()); 253cosmos.Resource.SecretOutputs["connectionString"] = "mycosmosconnectionstring"; 255var manifest = await ManifestUtils.GetManifestWithBicep(cosmos.Resource); 328var connectionStringResource = (IResourceWithConnectionString)cosmos.Resource; 330Assert.Equal("cosmos", cosmos.Resource.Name); 347cosmos.Resource.SecretOutputs["connectionString"] = "mycosmosconnectionstring"; 349var manifest = await ManifestUtils.GetManifestWithBicep(cosmos.Resource); 422var connectionStringResource = (IResourceWithConnectionString)cosmos.Resource; 424Assert.Equal("cosmos", cosmos.Resource.Name); 434appConfig.Resource.Outputs["appConfigEndpoint"] = "https://myendpoint"; 435Assert.Equal("https://myendpoint", await appConfig.Resource.ConnectionStringExpression.GetValueAsync(default)); 437var manifest = await ManifestUtils.GetManifestWithBicep(appConfig.Resource); 439var connectionStringResource = (IResourceWithConnectionString)appConfig.Resource; 501appInsights.Resource.Outputs["appInsightsConnectionString"] = "myinstrumentationkey"; 503var connectionStringResource = (IResourceWithConnectionString)appInsights.Resource; 505Assert.Equal("appInsights", appInsights.Resource.Name); 507Assert.Equal("{appInsights.outputs.appInsightsConnectionString}", appInsights.Resource.ConnectionStringExpression.ValueExpression); 509var appInsightsManifest = await ManifestUtils.GetManifestWithBicep(appInsights.Resource); 558appInsights.Resource.Outputs["appInsightsConnectionString"] = "myinstrumentationkey"; 560var connectionStringResource = (IResourceWithConnectionString)appInsights.Resource; 562Assert.Equal("appInsights", appInsights.Resource.Name); 564Assert.Equal("{appInsights.outputs.appInsightsConnectionString}", appInsights.Resource.ConnectionStringExpression.ValueExpression); 566var appInsightsManifest = await ManifestUtils.GetManifestWithBicep(appInsights.Resource); 624appInsights.Resource.Outputs["appInsightsConnectionString"] = "myinstrumentationkey"; 626var connectionStringResource = (IResourceWithConnectionString)appInsights.Resource; 628Assert.Equal("appInsights", appInsights.Resource.Name); 630Assert.Equal("{appInsights.outputs.appInsightsConnectionString}", appInsights.Resource.ConnectionStringExpression.ValueExpression); 632var appInsightsManifest = await ManifestUtils.GetManifestWithBicep(appInsights.Resource); 681Assert.Equal("logAnalyticsWorkspace", logAnalyticsWorkspace.Resource.Name); 682Assert.Equal("{logAnalyticsWorkspace.outputs.logAnalyticsWorkspaceId}", logAnalyticsWorkspace.Resource.WorkspaceId.ValueExpression); 684var appInsightsManifest = await ManifestUtils.GetManifestWithBicep(logAnalyticsWorkspace.Resource); 723appInsights.Resource.Outputs["appInsightsConnectionString"] = "myinstrumentationkey"; 728var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(serviceA.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance); 749var manifest = await ManifestUtils.GetManifest(infrastructure1.Resource); 774var manifest = await ManifestUtils.GetManifest(infrastructure1.Resource); 813var manifest = await ManifestUtils.GetManifest(infrastructure1.Resource); 843Assert.True(redis.Resource.IsContainer()); 845Assert.Equal("localhost:12455", await redis.Resource.GetConnectionStringAsync()); 847var manifest = await ManifestUtils.GetManifestWithBicep(redis.Resource); 907var manifest = await ManifestUtils.GetManifestWithBicep(mykv.Resource); 969var manifest = await ManifestUtils.GetManifestWithBicep(mykv.Resource); 1031var manifest = await ManifestUtils.GetManifestWithBicep(signalr.Resource); 1106var manifest = await ManifestUtils.GetManifestWithBicep(sql.Resource); 1108Assert.True(sql.Resource.TryGetLastAnnotation<ConnectionStringRedirectAnnotation>(out var connectionStringAnnotation)); 1112Assert.Equal("Server=tcp:myserver,1433;Encrypt=True;Authentication=\"Active Directory Default\"", await sql.Resource.GetConnectionStringAsync(default)); 1113Assert.Equal("Server=tcp:{sql.outputs.sqlServerFqdn},1433;Encrypt=True;Authentication=\"Active Directory Default\"", sql.Resource.ConnectionStringExpression.ValueExpression); 1200var manifest = await ManifestUtils.GetManifestWithBicep(sql.Resource); 1202Assert.True(sql.Resource.TryGetLastAnnotation<ConnectionStringRedirectAnnotation>(out var connectionStringAnnotation)); 1206Assert.Equal("Server=tcp:myserver,1433;Encrypt=True;Authentication=\"Active Directory Default\"", await sql.Resource.GetConnectionStringAsync(default)); 1207Assert.Equal("Server=tcp:{sql.outputs.sqlServerFqdn},1433;Encrypt=True;Authentication=\"Active Directory Default\"", sql.Resource.ConnectionStringExpression.ValueExpression); 1286Assert.True(postgres.Resource.TryGetLastAnnotation<ConnectionStringRedirectAnnotation>(out var connectionStringAnnotation)); 1290var manifest = await ManifestUtils.GetManifestWithBicep(postgres.Resource); 1295Assert.Equal("myconnectionstring", await postgres.Resource.GetConnectionStringAsync(default)); 1404Assert.True(postgres.Resource.TryGetLastAnnotation<ConnectionStringRedirectAnnotation>(out var connectionStringAnnotation)); 1408var manifest = await ManifestUtils.GetManifestWithBicep(postgres.Resource); 1413Assert.Equal("myconnectionstring", await postgres.Resource.GetConnectionStringAsync(default)); 1514var manifest = await ManifestUtils.GetManifestWithBicep(postgres.Resource); 1520Assert.Equal(expectedConnectionString, await postgres.Resource.GetConnectionStringAsync()); 1546var manifest = await ManifestUtils.GetManifest(postgres.Resource); 1566manifest = await ManifestUtils.GetManifest(postgres.Resource); 1585manifest = await ManifestUtils.GetManifest(postgres.Resource); 1614serviceBus.Resource.Outputs["serviceBusEndpoint"] = "mynamespaceEndpoint"; 1616var connectionStringResource = (IResourceWithConnectionString)serviceBus.Resource; 1618Assert.Equal("sb", serviceBus.Resource.Name); 1622var manifest = await ManifestUtils.GetManifestWithBicep(serviceBus.Resource); 1707wps.Resource.Outputs["endpoint"] = "https://mywebpubsubendpoint"; 1721var connectionStringResource = (IResourceWithConnectionString)wps.Resource; 1724var manifest = await ManifestUtils.GetManifestWithBicep(wps.Resource); 1727Assert.Equal("wps1", wps.Resource.Name); 1776wps.Resource.Outputs["endpoint"] = "https://mywebpubsubendpoint"; 1791var manifest = await ManifestUtils.GetManifestWithBicep(wps.Resource); 1794Assert.Equal("wps1", wps.Resource.Name); 1847Assert.True(storage.Resource.IsContainer()); 1854=> new(storage.Resource, new EndpointAnnotation(ProtocolType.Tcp, name: name, targetPort: port)); 1860Assert.Equal(blobqs, blob.Resource.ConnectionStringExpression.ValueExpression); 1861Assert.Equal(queueqs, queue.Resource.ConnectionStringExpression.ValueExpression); 1862Assert.Equal(tableqs, table.Resource.ConnectionStringExpression.ValueExpression); 1868Assert.Equal(Resolve(blobqs, "blob", 10000), await ((IResourceWithConnectionString)blob.Resource).GetConnectionStringAsync()); 1869Assert.Equal(Resolve(queueqs, "queue", 10001), await ((IResourceWithConnectionString)queue.Resource).GetConnectionStringAsync()); 1870Assert.Equal(Resolve(tableqs, "table", 10002), await ((IResourceWithConnectionString)table.Resource).GetConnectionStringAsync()); 1889storage.Resource.Outputs["blobEndpoint"] = "https://myblob"; 1890storage.Resource.Outputs["queueEndpoint"] = "https://myqueue"; 1891storage.Resource.Outputs["tableEndpoint"] = "https://mytable"; 1894Assert.Equal("storage", storage.Resource.Name); 1896var storageManifest = await ManifestUtils.GetManifestWithBicep(storage.Resource); 1988var connectionStringBlobResource = (IResourceWithConnectionString)blob.Resource; 1997var blobManifest = await ManifestUtils.GetManifest(blob.Resource); 2003var connectionStringQueueResource = (IResourceWithConnectionString)queue.Resource; 2012var queueManifest = await ManifestUtils.GetManifest(queue.Resource); 2018var connectionStringTableResource = (IResourceWithConnectionString)table.Resource; 2027var tableManifest = await ManifestUtils.GetManifest(table.Resource); 2048storage.Resource.Outputs["blobEndpoint"] = "https://myblob"; 2049storage.Resource.Outputs["queueEndpoint"] = "https://myqueue"; 2050storage.Resource.Outputs["tableEndpoint"] = "https://mytable"; 2053Assert.Equal("storage", storage.Resource.Name); 2055var storageManifest = await ManifestUtils.GetManifestWithBicep(storage.Resource); 2147var connectionStringBlobResource = (IResourceWithConnectionString)blob.Resource; 2156var blobManifest = await ManifestUtils.GetManifest(blob.Resource); 2162var connectionStringQueueResource = (IResourceWithConnectionString)queue.Resource; 2171var queueManifest = await ManifestUtils.GetManifest(queue.Resource); 2177var connectionStringTableResource = (IResourceWithConnectionString)table.Resource; 2186var tableManifest = await ManifestUtils.GetManifest(table.Resource); 2206storage.Resource.Outputs["blobEndpoint"] = "https://myblob"; 2207storage.Resource.Outputs["queueEndpoint"] = "https://myqueue"; 2208storage.Resource.Outputs["tableEndpoint"] = "https://mytable"; 2211Assert.Equal("storage", storage.Resource.Name); 2213var storageManifest = await ManifestUtils.GetManifestWithBicep(storage.Resource); 2305var connectionStringBlobResource = (IResourceWithConnectionString)blob.Resource; 2314var blobManifest = await ManifestUtils.GetManifest(blob.Resource); 2320var connectionStringQueueResource = (IResourceWithConnectionString)queue.Resource; 2329var queueManifest = await ManifestUtils.GetManifest(queue.Resource); 2335var connectionStringTableResource = (IResourceWithConnectionString)table.Resource; 2344var tableManifest = await ManifestUtils.GetManifest(table.Resource); 2365storage.Resource.Outputs["blobEndpoint"] = "https://myblob"; 2366storage.Resource.Outputs["queueEndpoint"] = "https://myqueue"; 2367storage.Resource.Outputs["tableEndpoint"] = "https://mytable"; 2370Assert.Equal("storage", storage.Resource.Name); 2372var storageManifest = await ManifestUtils.GetManifestWithBicep(storage.Resource); 2464var connectionStringBlobResource = (IResourceWithConnectionString)blob.Resource; 2473var blobManifest = await ManifestUtils.GetManifest(blob.Resource); 2479var connectionStringQueueResource = (IResourceWithConnectionString)queue.Resource; 2488var queueManifest = await ManifestUtils.GetManifest(queue.Resource); 2494var connectionStringTableResource = (IResourceWithConnectionString)table.Resource; 2503var tableManifest = await ManifestUtils.GetManifest(table.Resource); 2523search.Resource.Outputs["connectionString"] = fakeConnectionString; 2525var connectionStringResource = (IResourceWithConnectionString)search.Resource; 2528Assert.Equal("search", search.Resource.Name); 2532var manifest = await ManifestUtils.GetManifestWithBicep(search.Resource); 2615var aiManifest = await ManifestUtils.GetManifest(ai.Resource); 2619var serviceBusManifest = await ManifestUtils.GetManifest(serviceBus.Resource); 2623var serviceManifest = await ManifestUtils.GetManifest(serviceA.Resource); 2650var manifest = await ManifestUtils.GetManifestWithBicep(openai.Resource); 2805var (manifest, bicep) = await ManifestUtils.GetManifestWithBicep(provisioningResource.Resource);
AzureCosmosDBEmulatorFunctionalTests.cs (8)
48await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 50await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 54await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 56await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 93hb.Configuration[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default); 94hb.AddAzureCosmosClient(db.Resource.Name); 95hb.AddCosmosDbContext<EFCoreCosmosDbContext>(db.Resource.Name, databaseName);
AzureEventHubsExtensionsTests.cs (11)
49await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 51await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 55await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 57await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 78hb.Configuration["ConnectionStrings:eventhubns"] = await eventHub.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None); 109var volumeAnnotation = eventHubs.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(a => !a.Target.Contains("Config.json")); 126var volumeAnnotation = eventHubs.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(a => !a.Target.Contains("Config.json")); 143var volumeAnnotation = eventHubs.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(a => !a.Target.Contains("Config.json")); 160var volumeAnnotation = eventHubs.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(a => !a.Target.Contains("Config.json")); 180eventHubs.Resource.Annotations.OfType<EndpointAnnotation>(), 202var containerImageAnnotation = eventHubs.Resource.Annotations.OfType<ContainerImageAnnotation>().FirstOrDefault();
AzurePostgresExtensionsTests.cs (11)
22var manifest = await ManifestUtils.GetManifestWithBicep(postgres.Resource); 146var manifest = await ManifestUtils.GetManifestWithBicep(postgres.Resource); 154"administratorLogin": "{{{userName?.Resource.Name ?? "postgres-data-username"}}.value}", 155"administratorLoginPassword": "{{{password?.Resource.Name ?? "postgres-data-password"}}.value}", 280Assert.True(postgres.Resource.IsContainer(), "The resource should now be a container resource."); 281Assert.StartsWith("Host=localhost;Port=12455;Username=postgres;Password=", await postgres.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None)); 283var db1ConnectionString = await db1.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None); 287var db2ConnectionString = await db2.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None); 322Assert.Equal("Host=localhost;Port=12455;Username=user;Password=p@ssw0rd1", await postgres.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None)); 323Assert.Equal("Host=localhost;Port=12455;Username=user;Password=p@ssw0rd1;Database=db1", await db1.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None)); 324Assert.Equal("Host=localhost;Port=12455;Username=user;Password=p@ssw0rd1;Database=db2Name", await db2.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None));
AzureProvisioningResourceExtensionsTests.cs (1)
50var manifest = await ManifestUtils.GetManifestWithBicep(resource1.Resource);
AzureRedisExtensionsTests.cs (4)
20var manifest = await ManifestUtils.GetManifestWithBicep(redis.Resource); 88var manifest = await ManifestUtils.GetManifestWithBicep(redis.Resource); 152Assert.True(redis.Resource.IsContainer(), "The resource should now be a container resource."); 154Assert.Equal("localhost:12455", await redis.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None));
AzureResourceExtensionsTests.cs (8)
33var volumeAnnotation = storage.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 59var volumeAnnotation = storage.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 85var volumeAnnotation = storage.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 111var volumeAnnotation = storage.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 130storage.Resource.Annotations.OfType<EndpointAnnotation>(), 151var endpointAnnotation = cosmos.Resource.Annotations.OfType<EndpointAnnotation>().FirstOrDefault(); 172var containerImageAnnotation = cosmos.Resource.Annotations.OfType<ContainerImageAnnotation>().FirstOrDefault(); 189var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(cosmos.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance);
AzureServiceBusExtensionsTests.cs (1)
20var manifest = await ManifestUtils.GetManifestWithBicep(serviceBus.Resource);
AzureSqlExtensionsTests.cs (5)
25var manifest = await ManifestUtils.GetManifestWithBicep(sql.Resource); 161Assert.True(sql.Resource.IsContainer(), "The resource should now be a container resource."); 162var serverConnectionString = await sql.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None); 166var db1ConnectionString = await db1.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None); 170var db2ConnectionString = await db2.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None);
AzureStorageEmulatorFunctionalTests.cs (7)
50await rns.WaitForResourceAsync(storage.Resource.Name, KnownResourceStates.Running, cts.Token); 52await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 56await rns.WaitForResourceHealthyAsync(blobs.Resource.Name, cts.Token); 57await rns.WaitForResourceHealthyAsync(queues.Resource.Name, cts.Token); 58await rns.WaitForResourceHealthyAsync(tables.Resource.Name, cts.Token); 60await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 78hb.Configuration["ConnectionStrings:BlobConnection"] = await storage.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None);
AzureWebPubSubExtensionsTests.cs (15)
37Assert.Equal(hubName, hub.Resource.Name); 38var manifest = await ManifestUtils.GetManifestWithBicep(wps.Resource); 63var manifest = await ManifestUtils.GetManifestWithBicep(wps.Resource); 69Assert.Equal("wps1", wps.Resource.Name); 138var manifest = await ManifestUtils.GetManifestWithBicep(wps.Resource); 144Assert.Equal("wps1", wps.Resource.Name); 213var manifest = await ManifestUtils.GetManifestWithBicep(wps.Resource); 219Assert.Equal("wps1", wps.Resource.Name); 289wps.Resource.Outputs["endpoint"] = "https://mywebpubsubendpoint"; 290var manifest = await ManifestUtils.GetManifestWithBicep(wps.Resource); 295Assert.Equal("wps1", wps.Resource.Name); 375wps.Resource.Outputs["endpoint"] = "https://mywebpubsubendpoint"; 392var connectionStringResource = (IResourceWithConnectionString)wps.Resource; 395var manifest = await ManifestUtils.GetManifestWithBicep(wps.Resource); 402Assert.Equal("wps1", wps.Resource.Name);
Aspire.Hosting.Azure.WebPubSub (4)
AzureWebPubSubExtensions.cs (4)
126if (!builder.Resource.Hubs.TryGetValue(hubName, out hubResource)) 128hubResource = new AzureWebPubSubHubResource(hubName, builder.Resource); 129builder.Resource.Hubs[hubName] = hubResource; 168builder.Resource.EventHandlers.Add((urlExpression, userEventPattern, systemEvents, authSettings));
Aspire.Hosting.Containers.Tests (26)
ContainerResourceBuilderTests.cs (12)
17Assert.Equal("redis-stack", redis.Resource.Annotations.OfType<ContainerImageAnnotation>().Single().Image); 25Assert.Equal("redis-stack", redis.Resource.Annotations.OfType<ContainerImageAnnotation>().Single().Image); 26Assert.Equal("1.0.0", redis.Resource.Annotations.OfType<ContainerImageAnnotation>().Single().Tag); 34container.Resource.Annotations.RemoveAt(0); 37Assert.Equal("new-image", container.Resource.Annotations.OfType<ContainerImageAnnotation>().Single().Image); 38Assert.Equal("latest", container.Resource.Annotations.OfType<ContainerImageAnnotation>().Single().Tag); 46container.Resource.Annotations.Add(new ContainerImageAnnotation { Image = "another-image" }); 49Assert.Equal("new-image", container.Resource.Annotations.OfType<ContainerImageAnnotation>().Last().Image); 50Assert.Equal("latest", container.Resource.Annotations.OfType<ContainerImageAnnotation>().Last().Tag); 58Assert.Equal("7.1", redis.Resource.Annotations.OfType<ContainerImageAnnotation>().Single().Tag); 66Assert.Equal("myregistry.azurecr.io", redis.Resource.Annotations.OfType<ContainerImageAnnotation>().Single().Registry); 74Assert.Equal("42b5c726e719639fcc1e9dbc13dd843f567dcd37911d0e1abb9f47f2cc1c95cd", redis.Resource.Annotations.OfType<ContainerImageAnnotation>().Single().SHA256);
ContainerResourceTests.cs (2)
76var args = await ArgumentEvaluator.GetArgumentListAsync(c2.Resource); 83var manifest = await ManifestUtils.GetManifest(c2.Resource);
WithDockerfileTests.cs (12)
174var manifest = await ManifestUtils.GetManifest(container.Resource, manifestDirectory: tempContextPath); 221var manifest = await ManifestUtils.GetManifest(container.Resource, manifestDirectory: tempContextPath); 267var manifest = await ManifestUtils.GetManifest(container.Resource, manifestDirectory: tempContextPath); 312var manifest = await ManifestUtils.GetManifest(container.Resource, manifestDirectory: tempContextPath); 620var annotation = Assert.Single(container.Resource.Annotations.OfType<DockerfileBuildAnnotation>()); 635var annotation = Assert.Single(container.Resource.Annotations.OfType<DockerfileBuildAnnotation>()); 651var annotation = Assert.Single(container.Resource.Annotations.OfType<DockerfileBuildAnnotation>()); 666var annotation = Assert.Single(container.Resource.Annotations.OfType<DockerfileBuildAnnotation>()); 682var annotation = Assert.Single(container.Resource.Annotations.OfType<DockerfileBuildAnnotation>()); 697var annotation = Assert.Single(container.Resource.Annotations.OfType<DockerfileBuildAnnotation>()); 713var annotation = Assert.Single(container.Resource.Annotations.OfType<DockerfileBuildAnnotation>()); 728var annotation = Assert.Single(container.Resource.Annotations.OfType<DockerfileBuildAnnotation>());
Aspire.Hosting.Dapr (3)
IDistributedApplicationComponentBuilderExtensions.cs (3)
57var sidecarBuilder = builder.ApplicationBuilder.AddResource(new DaprSidecarResource($"{builder.Resource.Name}-dapr")) 67return builder.WithAnnotation(new DaprSidecarAnnotation(sidecarBuilder.Resource)); 89return builder.WithAnnotation(new DaprComponentReferenceAnnotation(component.Resource));
Aspire.Hosting.Elasticsearch (1)
ElasticsearchBuilderExtensions.cs (1)
54var passwordParameter = password?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password");
Aspire.Hosting.Elasticsearch.Tests (18)
AddElasticsearchTests.cs (3)
152Assert.Equal($"http://elastic:{elasticsearch.Resource.PasswordParameter.Value}@localhost:27020", connectionString); 163var manifest = await ManifestUtils.GetManifest(elasticsearch.Resource); 202var manifest = await ManifestUtils.GetManifest(elasticsearch.Resource);
ElasticsearchFunctionalTests.cs (14)
47hb.Configuration[$"ConnectionStrings:{elasticsearch.Resource.Name}"] = await elasticsearch.Resource.ConnectionStringExpression.GetValueAsync(default); 49hb.AddElasticsearchClient(elasticsearch.Resource.Name); 85var password = elasticsearch1.Resource.PasswordParameter.Value; 110hb.Configuration[$"ConnectionStrings:{elasticsearch1.Resource.Name}"] = await elasticsearch1.Resource.ConnectionStringExpression.GetValueAsync(default); 112hb.AddElasticsearchClient(elasticsearch1.Resource.Name); 155hb.Configuration[$"ConnectionStrings:{elasticsearch2.Resource.Name}"] = await elasticsearch2.Resource.ConnectionStringExpression.GetValueAsync(default); 157hb.AddElasticsearchClient(elasticsearch2.Resource.Name); 231await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 233await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 237await rns.WaitForResourceAsync(resource.Resource.Name, (re => re.Snapshot.HealthStatus == Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy), cts.Token); 239await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token);
ElasticsearchPublicApiTests.cs (1)
81var action = () => new ElasticsearchResource(name, password.Resource);
Aspire.Hosting.Garnet.Tests (20)
AddGarnetTests.cs (9)
93var manifest = await ManifestUtils.GetManifest(garnet.Resource); 130var volumeAnnotation = garnet.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 155var volumeAnnotation = garnet.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 170Assert.True(garnet.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsCallbacks)); 189var persistenceAnnotation = garnet.Resource.Annotations.OfType<CommandLineArgsCallbackAnnotation>().SingleOrDefault(); 201Assert.True(garnet.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsCallbacks)); 220var persistenceAnnotation = garnet.Resource.Annotations.OfType<CommandLineArgsCallbackAnnotation>().SingleOrDefault(); 233Assert.True(garnet.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsCallbacks)); 252Assert.True(garnet.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsAnnotations));
GarnetFunctionalTests.cs (11)
44await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 46await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 50await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 52await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 78hb.Configuration[$"ConnectionStrings:{garnet.Resource.Name}"] = await garnet.Resource.ConnectionStringExpression.GetValueAsync(default); 80hb.AddRedisClient(garnet.Resource.Name); 157hb.Configuration[$"ConnectionStrings:{garnet1.Resource.Name}"] = $"{await garnet1.Resource.ConnectionStringExpression.GetValueAsync(default)}"; 208hb.Configuration[$"ConnectionStrings:{garnet2.Resource.Name}"] = $"{await garnet2.Resource.ConnectionStringExpression.GetValueAsync(default)}";
Aspire.Hosting.Kafka (1)
KafkaBuilderExtensions.cs (1)
104containerName ??= $"{builder.Resource.Name}-kafka-ui";
Aspire.Hosting.Kafka.Tests (15)
AddKafkaTests.cs (5)
81var manifest = await ManifestUtils.GetManifest(kafka.Resource); 121var config = await kafka.Resource.GetEnvironmentVariableValuesAsync(); 123var volumeAnnotation = kafka.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 139var config = await kafka.Resource.GetEnvironmentVariableValuesAsync(); 141var volumeAnnotation = kafka.Resource.Annotations.OfType<ContainerMountAnnotation>().Single();
KafkaFunctionalTests.cs (10)
45await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 47await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 51await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 53await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 76hb.Configuration[$"ConnectionStrings:{kafka.Resource.Name}"] = await kafka.Resource.ConnectionStringExpression.GetValueAsync(default); 169hb.Configuration[$"ConnectionStrings:{kafka1.Resource.Name}"] = await kafka1.Resource.ConnectionStringExpression.GetValueAsync(default); 221hb.Configuration[$"ConnectionStrings:{kafka2.Resource.Name}"] = await kafka2.Resource.ConnectionStringExpression.GetValueAsync(default);
Aspire.Hosting.Keycloak (2)
KeycloakResourceBuilderExtensions.cs (2)
52var passwordParameter = adminPassword?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password"); 54var resource = new KeycloakResource(name, adminUsername?.Resource, passwordParameter);
Aspire.Hosting.Keycloak.Tests (7)
KeycloakPublicApiTests.cs (1)
19var action = () => new KeycloakResource(name, default(ParameterResource?), adminPassword.Resource);
KeycloakResourceBuilderTests.cs (6)
53var volumeAnnotation = keycloak.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 68var volumeAnnotation = keycloak.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 99var containerAnnotation = keycloak.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 114Assert.Equal("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", rmq.Resource.AdminPasswordParameter.Default?.GetType().FullName); 124Assert.NotEqual("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", rmq.Resource.AdminPasswordParameter.Default?.GetType().FullName); 133var manifest = await ManifestUtils.GetManifest(keycloak.Resource);
Aspire.Hosting.Milvus (5)
MilvusBuilderExtensions.cs (5)
49var apiKeyParameter = apiKey?.Resource ?? 102builder.Resource.AddDatabase(name, databaseName); 103var milvusDatabaseResource = new MilvusDatabaseResource(name, databaseName, builder.Resource); 134containerName ??= $"{builder.Resource.Name}-attu"; 141.WithEnvironment(context => ConfigureAttuContainer(context, builder.Resource))
Aspire.Hosting.Milvus.Tests (18)
AddMilvusTests.cs (5)
89var connectionStringResource = milvus.Resource as IResourceWithConnectionString; 110var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectA.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance); 121var containerConfig = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(container1.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance); 138var serverManifest = await ManifestUtils.GetManifest(milvus.Resource); // using this method does not get any ExecutionContext.IsPublishMode changes 139var dbManifest = await ManifestUtils.GetManifest(db1.Resource);
MilvusFunctionalTests.cs (13)
32await app.WaitForTextAsync("Milvus Proxy successfully initialized and ready to serve", milvus.Resource.Name); 36hb.Configuration[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default); 38hb.AddMilvusClient(db.Resource.Name); 81var password = milvus1.Resource.ApiKeyParameter.Value; 104await app.WaitForTextAsync("Milvus Proxy successfully initialized and ready to serve", milvus1.Resource.Name); 110hb.Configuration[$"ConnectionStrings:{db1.Resource.Name}"] = await db1.Resource.ConnectionStringExpression.GetValueAsync(default); 112hb.AddMilvusClient(db1.Resource.Name); 152await app.WaitForTextAsync("Milvus Proxy successfully initialized and ready to serve", milvus2.Resource.Name); 158hb.Configuration[$"ConnectionStrings:{db2.Resource.Name}"] = await db2.Resource.ConnectionStringExpression.GetValueAsync(default); 160hb.AddMilvusClient(db2.Resource.Name);
Aspire.Hosting.MongoDB (6)
MongoDBBuilderExtensions.cs (6)
57var passwordParameter = password?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password", special: false); 59var mongoDBContainer = new MongoDBServerResource(name, userName?.Resource, passwordParameter); 104builder.Resource.AddDatabase(name, databaseName); 105var mongoDBDatabase = new MongoDBDatabaseResource(name, databaseName, builder.Resource); 140containerName ??= $"{builder.Resource.Name}-mongoexpress"; 146.WithEnvironment(context => ConfigureMongoExpressContainer(context, builder.Resource))
Aspire.Hosting.MongoDB.Tests (27)
AddMongoDBTests.cs (10)
196var mongoManifest = await ManifestUtils.GetManifest(mongo.Resource); 197var dbManifest = await ManifestUtils.GetManifest(db.Resource); 262Assert.Equal("customers1", db1.Resource.DatabaseName); 263Assert.Equal("customers2", db2.Resource.DatabaseName); 265Assert.Equal("mongodb://admin:{mongo1-password.value}@{mongo1.bindings.tcp.host}:{mongo1.bindings.tcp.port}/customers1?authSource=admin&authMechanism=SCRAM-SHA-256", db1.Resource.ConnectionStringExpression.ValueExpression); 266Assert.Equal("mongodb://admin:{mongo1-password.value}@{mongo1.bindings.tcp.host}:{mongo1.bindings.tcp.port}/customers2?authSource=admin&authMechanism=SCRAM-SHA-256", db2.Resource.ConnectionStringExpression.ValueExpression); 280Assert.Equal("imports", db1.Resource.DatabaseName); 281Assert.Equal("imports", db2.Resource.DatabaseName); 283Assert.Equal("mongodb://admin:{mongo1-password.value}@{mongo1.bindings.tcp.host}:{mongo1.bindings.tcp.port}/imports?authSource=admin&authMechanism=SCRAM-SHA-256", db1.Resource.ConnectionStringExpression.ValueExpression); 284Assert.Equal("mongodb://admin:{mongo2-password.value}@{mongo2.bindings.tcp.host}:{mongo2.bindings.tcp.port}/imports?authSource=admin&authMechanism=SCRAM-SHA-256", db2.Resource.ConnectionStringExpression.ValueExpression);
MongoDbFunctionalTests.cs (17)
56await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 58await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 62await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 64await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 89hb.Configuration[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default); 91hb.AddMongoDBClient(db.Resource.Name); 124var password = mongodb1.Resource.PasswordParameter!.Value; 149hb.Configuration[$"ConnectionStrings:{db1.Resource.Name}"] = await db1.Resource.ConnectionStringExpression.GetValueAsync(default); 151hb.AddMongoDBClient(db1.Resource.Name); 196hb.Configuration[$"ConnectionStrings:{db2.Resource.Name}"] = await db2.Resource.ConnectionStringExpression.GetValueAsync(default); 198hb.AddMongoDBClient(db2.Resource.Name); 317hb.Configuration[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default); 319hb.AddMongoDBClient(db.Resource.Name);
Aspire.Hosting.MySql (4)
MySqlBuilderExtensions.cs (4)
34var passwordParameter = password?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password"); 79builder.Resource.AddDatabase(name, databaseName); 80var mySqlDatabase = new MySqlDatabaseResource(name, databaseName, builder.Resource); 103containerName ??= $"{builder.Resource.Name}-phpmyadmin";
Aspire.Hosting.MySql.Tests (41)
AddMySqlTests.cs (21)
23Assert.Equal("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", mysql.Resource.PasswordParameter.Default?.GetType().FullName); 33Assert.NotEqual("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", mysql.Resource.PasswordParameter.Default?.GetType().FullName); 161var mySqlManifest = await ManifestUtils.GetManifest(mysql.Resource); 162var dbManifest = await ManifestUtils.GetManifest(db.Resource); 200var serverManifest = await ManifestUtils.GetManifest(mysql.Resource); 249Assert.Equal($"{mysql.Resource.Name}:{mysql.Resource.PrimaryEndpoint.TargetPort}", config["PMA_HOST"]); 290string pattern1 = $@"\$cfg\['Servers'\]\[\$i\]\['host'\] = '{mysql1.Resource.Name}:{mysql1.Resource.PrimaryEndpoint.TargetPort}';"; 291string pattern2 = $@"\$cfg\['Servers'\]\[\$i\]\['host'\] = '{mysql2.Resource.Name}:{mysql2.Resource.PrimaryEndpoint.TargetPort}';"; 331Assert.Equal(["db1", "db2"], mysql1.Resource.Databases.Keys); 332Assert.Equal(["customers1", "customers2"], mysql1.Resource.Databases.Values); 334Assert.Equal("customers1", db1.Resource.DatabaseName); 335Assert.Equal("customers2", db2.Resource.DatabaseName); 337Assert.Equal("{mysql1.connectionString};Database=customers1", db1.Resource.ConnectionStringExpression.ValueExpression); 338Assert.Equal("{mysql1.connectionString};Database=customers2", db2.Resource.ConnectionStringExpression.ValueExpression); 352Assert.Equal("imports", db1.Resource.DatabaseName); 353Assert.Equal("imports", db2.Resource.DatabaseName); 355Assert.Equal("{mysql1.connectionString};Database=imports", db1.Resource.ConnectionStringExpression.ValueExpression); 356Assert.Equal("{mysql2.connectionString};Database=imports", db2.Resource.ConnectionStringExpression.ValueExpression);
MySqlFunctionalTests.cs (20)
52await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 54await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 58await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 60await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 93[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default) 96hb.AddMySqlDataSource(db.Resource.Name); 135var password = mysql1.Resource.PasswordParameter.Value; 166[$"ConnectionStrings:{db1.Resource.Name}"] = await db1.Resource.ConnectionStringExpression.GetValueAsync(default) 169hb.AddMySqlDataSource(db1.Resource.Name); 236[$"ConnectionStrings:{db2.Resource.Name}"] = await db2.Resource.ConnectionStringExpression.GetValueAsync(default) 239hb.AddMySqlDataSource(db2.Resource.Name); 342[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default) 345hb.AddMySqlDataSource(db.Resource.Name); 412[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default) 415hb.AddMySqlDbContext<TestDbContext>(db.Resource.Name);
Aspire.Hosting.Nats (2)
NatsBuilderExtensions.cs (2)
52var passwordParameter = password?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password", special: false); 54var nats = new NatsServerResource(name, userName?.Resource, passwordParameter);
Aspire.Hosting.Nats.Tests (33)
AddNatsTests.cs (12)
21Assert.Equal("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", nats.Resource.PasswordParameter!.Default?.GetType().FullName); 31Assert.NotEqual("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", nats.Resource.PasswordParameter!.Default?.GetType().FullName); 42Assert.NotNull(nats.Resource.PasswordParameter); 43Assert.False(string.IsNullOrEmpty(nats.Resource.PasswordParameter!.Value)); 68Assert.NotNull(nats.Resource.UserNameParameter); 69Assert.NotNull(nats.Resource.PasswordParameter); 71Assert.Equal("usr", nats.Resource.UserNameParameter!.Value); 72Assert.Equal("password", nats.Resource.PasswordParameter!.Value); 188var manifest = await ManifestUtils.GetManifest(nats.Resource); 225var manifest = await ManifestUtils.GetManifest(nats.Resource); 253manifest = await ManifestUtils.GetManifest(nats.Resource); 280manifest = await ManifestUtils.GetManifest(nats.Resource);
NatsFunctionalTests.cs (19)
37await app.WaitForTextAsync("Listening for client connections", nats.Resource.Name); 41hb.Configuration[$"ConnectionStrings:{nats.Resource.Name}"] = await nats.Resource.ConnectionStringExpression.GetValueAsync(default); 82await app.WaitForTextAsync("Listening for client connections", nats.Resource.Name); 86var connectionString = await nats.Resource.ConnectionStringExpression.GetValueAsync(default); 87hb.Configuration[$"ConnectionStrings:{nats.Resource.Name}"] = connectionString; 126await app.WaitForTextAsync("Listening for client connections", nats.Resource.Name); 130var connectionString = await nats.Resource.ConnectionStringExpression.GetValueAsync(default); 135hb.Configuration[$"ConnectionStrings:{nats.Resource.Name}"] = modifiedConnectionString; 187await app.WaitForTextAsync("Listening for client connections", nats1.Resource.Name); 192hb.Configuration[$"ConnectionStrings:{nats1.Resource.Name}"] = await nats1.Resource.ConnectionStringExpression.GetValueAsync(default); 235await app.WaitForTextAsync("Listening for client connections", nats2.Resource.Name); 240hb.Configuration[$"ConnectionStrings:{nats2.Resource.Name}"] = await nats2.Resource.ConnectionStringExpression.GetValueAsync(default); 347await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 349await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 353await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 355await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token);
NatsPublicApiTests.cs (2)
106var action = () => new NatsServerResource(name, user.Resource, password.Resource);
Aspire.Hosting.NodeJs.Tests (2)
AddNodeAppTests.cs (2)
19var manifest = await ManifestUtils.GetManifest(nodeApp.Resource); 48manifest = await ManifestUtils.GetManifest(npmApp.Resource);
Aspire.Hosting.Oracle (3)
OracleDatabaseBuilderExtensions.cs (3)
30var passwordParameter = password?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password"); 73builder.Resource.AddDatabase(name, databaseName); 74var oracleDatabase = new OracleDatabaseResource(name, databaseName, builder.Resource);
Aspire.Hosting.Oracle.Tests (30)
AddOracleTests.cs (13)
22Assert.Equal("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", orcl.Resource.PasswordParameter.Default?.GetType().FullName); 32Assert.NotEqual("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", orcl.Resource.PasswordParameter.Default?.GetType().FullName); 202var serverManifest = await ManifestUtils.GetManifest(oracleServer.Resource); 203var dbManifest = await ManifestUtils.GetManifest(db.Resource); 241var serverManifest = await ManifestUtils.GetManifest(oracleServer.Resource); 297Assert.Equal("customers1", db1.Resource.DatabaseName); 298Assert.Equal("customers2", db2.Resource.DatabaseName); 300Assert.Equal("{oracle1.connectionString}/customers1", db1.Resource.ConnectionStringExpression.ValueExpression); 301Assert.Equal("{oracle1.connectionString}/customers2", db2.Resource.ConnectionStringExpression.ValueExpression); 315Assert.Equal("imports", db1.Resource.DatabaseName); 316Assert.Equal("imports", db2.Resource.DatabaseName); 318Assert.Equal("{oracle1.connectionString}/imports", db1.Resource.ConnectionStringExpression.ValueExpression); 319Assert.Equal("{oracle2.connectionString}/imports", db2.Resource.ConnectionStringExpression.ValueExpression);
OracleFunctionalTests.cs (17)
52hb.Configuration[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default); 54hb.AddOracleDatabaseDbContext<TestDbContext>(db.Resource.Name); 99var password = oracle1.Resource.PasswordParameter.Value; 135hb.Configuration[$"ConnectionStrings:{db1.Resource.Name}"] = await db1.Resource.ConnectionStringExpression.GetValueAsync(default); 137hb.AddOracleDatabaseDbContext<TestDbContext>(db1.Resource.Name); 196hb.Configuration[$"ConnectionStrings:{db2.Resource.Name}"] = await db2.Resource.ConnectionStringExpression.GetValueAsync(default); 198hb.AddOracleDatabaseDbContext<TestDbContext>(db2.Resource.Name); 310hb.Configuration[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default); 312hb.AddOracleDatabaseDbContext<TestDbContext>(db.Resource.Name); 375await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 377await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 381await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 383await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token);
Aspire.Hosting.Orleans (7)
OrleansServiceExtensions.cs (5)
55orleansServiceBuilder.ClusterId = clusterId.Resource; 83orleansServiceBuilder.ServiceId = serviceId.Resource; 131=> WithGrainStorage(orleansServiceBuilder, provider.Resource.Name, provider); 183=> WithStreaming(orleansServiceBuilder, provider.Resource.Name, provider); 299=> WithGrainDirectory(orleansServiceBuilder, provider.Resource.Name, provider);
ProviderConfiguration.cs (2)
21var serviceKey = resourceBuilder.Resource.Name; 22var resourceType = resourceBuilder.Resource.GetType().Name;
Aspire.Hosting.PostgreSQL (8)
PostgresBuilderExtensions.cs (8)
49var passwordParameter = password?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password"); 51var postgresServer = new PostgresServerResource(name, userName?.Resource, passwordParameter); 119builder.Resource.AddDatabase(name, databaseName); 120var postgresDatabase = new PostgresDatabaseResource(name, databaseName, builder.Resource); 146containerName ??= $"{builder.Resource.Name}-pgadmin"; 209pgAdminContainerBuilder.WithRelationship(builder.Resource, "PgAdmin"); 280containerName ??= $"{builder.Resource.Name}-pgweb"; 294pgwebContainerBuilder.WithRelationship(builder.Resource, "PgWeb");
Aspire.Hosting.PostgreSQL.Tests (47)
AddPostgresTests.cs (24)
22Assert.Single(redis.Resource.Annotations, a => a is HealthCheckAnnotation hca && hca.Key == "postgres_check"); 32Assert.Equal("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", pg.Resource.PasswordParameter.Default?.GetType().FullName); 42Assert.NotEqual("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", pg.Resource.PasswordParameter.Default?.GetType().FullName); 159var connectionStringResource = postgres.Resource as IResourceWithConnectionString; 163Assert.Equal($"Host=localhost;Port=2000;Username=postgres;Password={postgres.Resource.PasswordParameter.Value}", connectionString); 251var serverManifest = await ManifestUtils.GetManifest(pgServer.Resource); 252var dbManifest = await ManifestUtils.GetManifest(db.Resource); 295var serverManifest = await ManifestUtils.GetManifest(pgServer.Resource); 321serverManifest = await ManifestUtils.GetManifest(pgServer.Resource); 347serverManifest = await ManifestUtils.GetManifest(pgServer.Resource); 476Assert.Equal(pg1.Resource.Name, servers.GetProperty("1").GetProperty("Name").GetString()); 483Assert.Equal($"echo '{pg1.Resource.PasswordParameter.Value}'", servers.GetProperty("1").GetProperty("PasswordExecCommand").GetString()); 486Assert.Equal(pg2.Resource.Name, servers.GetProperty("2").GetProperty("Name").GetString()); 493Assert.Equal($"echo '{pg2.Resource.PasswordParameter.Value}'", servers.GetProperty("2").GetProperty("PasswordExecCommand").GetString()); 541Assert.Equal(CreatePgWebBookmarkfileContent(db1.Resource), content); 545Assert.Equal(CreatePgWebBookmarkfileContent(db2.Resource), content); 582Assert.Equal("customers1", db1.Resource.DatabaseName); 583Assert.Equal("customers2", db2.Resource.DatabaseName); 585Assert.Equal("{postgres1.connectionString};Database=customers1", db1.Resource.ConnectionStringExpression.ValueExpression); 586Assert.Equal("{postgres1.connectionString};Database=customers2", db2.Resource.ConnectionStringExpression.ValueExpression); 600Assert.Equal("imports", db1.Resource.DatabaseName); 601Assert.Equal("imports", db2.Resource.DatabaseName); 603Assert.Equal("{postgres1.connectionString};Database=imports", db1.Resource.ConnectionStringExpression.ValueExpression); 604Assert.Equal("{postgres2.connectionString};Database=imports", db2.Resource.ConnectionStringExpression.ValueExpression);
PostgrePublicApiTests.cs (3)
80var postgresParentResource = new PostgresServerResource("PostgresServer", default(ParameterResource?), parameterResource.Resource); 95var postgresParentResource = new PostgresServerResource("PostgresServer", default(ParameterResource?), parameterResource.Resource); 123var action = () => new PostgresServerResource(name, default(ParameterResource?), password.Resource);
PostgresFunctionalTests.cs (20)
56await rns.WaitForResourceAsync(postgres.Resource.Name, KnownResourceStates.Running, cts.Token); 59await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 65await rns.WaitForResourceHealthyAsync(postgres.Resource.Name, cts.Token); 68await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 90await app.WaitForTextAsync("Listening at", resourceName: adminBuilder.Resource.Name); 92var client = app.CreateHttpClient(adminBuilder.Resource.Name, "http"); 123[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default) 126hb.AddNpgsqlDataSource(db.Resource.Name); 167await app.WaitForTextAsync("Starting server...", resourceName: pgWebBuilder.Resource.Name); 169var client = app.CreateHttpClient(pgWebBuilder.Resource.Name, "http"); 239[$"ConnectionStrings:{db1.Resource.Name}"] = await db1.Resource.ConnectionStringExpression.GetValueAsync(default) 242hb.AddNpgsqlDataSource(db1.Resource.Name); 300[$"ConnectionStrings:{db2.Resource.Name}"] = await db2.Resource.ConnectionStringExpression.GetValueAsync(default) 303hb.AddNpgsqlDataSource(db2.Resource.Name); 392[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default) 395hb.AddNpgsqlDataSource(db.Resource.Name);
Aspire.Hosting.Python.Tests (3)
AddPythonAppTests.cs (3)
34var manifest = await ManifestUtils.GetManifest(pyproj.Resource, manifestDirectory: projectDirectory); 64var manifest = await ManifestUtils.GetManifest(pyproj.Resource, manifestDirectory: projectDirectory); 121var environmentVariables = await pyproj.Resource.GetEnvironmentVariableValuesAsync(DistributedApplicationOperation.Run);
Aspire.Hosting.Qdrant (5)
QdrantBuilderExtensions.cs (5)
47var apiKeyParameter = apiKey?.Resource ?? 138context.EnvironmentVariables[$"ConnectionStrings__{qdrantResource.Resource.Name}"] = qdrantResource.Resource.ConnectionStringExpression; 141context.EnvironmentVariables[$"ConnectionStrings__{qdrantResource.Resource.Name}_{QdrantServerResource.HttpEndpointName}"] = qdrantResource.Resource.HttpConnectionStringExpression;
Aspire.Hosting.Qdrant.Tests (20)
AddQdrantTests.cs (7)
25Assert.Equal("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", qd.Resource.ApiKeyParameter.Default?.GetType().FullName); 35Assert.NotEqual("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", qd.Resource.ApiKeyParameter.Default?.GetType().FullName); 161var connectionStringResource = qdrant.Resource as IResourceWithConnectionString; 183var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectA.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance); 195var containerConfig = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(container1.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance); 210var serverManifest = await ManifestUtils.GetManifest(qdrant.Resource); // using this method does not get any ExecutionContext.IsPublishMode changes 248var serverManifest = await ManifestUtils.GetManifest(qdrant.Resource); // using this method does not get any ExecutionContext.IsPublishMode changes
QdrantFunctionalTests.cs (13)
46[$"ConnectionStrings:{qdrant.Resource.Name}"] = await qdrant.Resource.ConnectionStringExpression.GetValueAsync(default) 49hb.AddQdrantClient(qdrant.Resource.Name); 130[$"ConnectionStrings:{qdrant1.Resource.Name}"] = await qdrant1.Resource.ConnectionStringExpression.GetValueAsync(default) 133hb.AddQdrantClient(qdrant1.Resource.Name); 175[$"ConnectionStrings:{qdrant2.Resource.Name}"] = await qdrant2.Resource.ConnectionStringExpression.GetValueAsync(default) 178hb.AddQdrantClient(qdrant2.Resource.Name); 247await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 249await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 253await rns.WaitForResourceAsync(resource.Resource.Name, (re => re.Snapshot.HealthStatus == HealthStatus.Healthy), cts.Token); 255await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token);
Aspire.Hosting.RabbitMQ (5)
RabbitMQBuilderExtensions.cs (5)
38var passwordParameter = password?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password", special: false); 40var rabbitMq = new RabbitMQServerResource(name, userName?.Resource, passwordParameter); 142var containerAnnotations = builder.Resource.Annotations.OfType<ContainerImageAnnotation>().ToList(); 191throw new DistributedApplicationException($"Cannot configure the RabbitMQ resource '{builder.Resource.Name}' to enable the management plugin as it uses an unrecognized container image registry, name, or tag."); 245var nodeName = $"{builder.Resource.Name}@localhost";
Aspire.Hosting.RabbitMQ.Tests (20)
AddRabbitMQTests.cs (6)
21Assert.Equal("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", rmq.Resource.PasswordParameter.Default?.GetType().FullName); 31Assert.NotEqual("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", rmq.Resource.PasswordParameter.Default?.GetType().FullName); 205var manifest = await ManifestUtils.GetManifest(rabbit.Resource); 251var manifest = await ManifestUtils.GetManifest(rabbit.Resource); 275manifest = await ManifestUtils.GetManifest(rabbit.Resource); 299manifest = await ManifestUtils.GetManifest(rabbit.Resource);
RabbitMQFunctionalTests.cs (14)
46await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 48await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 52await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 54await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 74hb.Configuration[$"ConnectionStrings:{rabbitMQ.Resource.Name}"] = await rabbitMQ.Resource.ConnectionStringExpression.GetValueAsync(default); 75hb.AddRabbitMQClient(rabbitMQ.Resource.Name); 111var password = rabbitMQ1.Resource.PasswordParameter.Value; 134hb.Configuration[$"ConnectionStrings:{rabbitMQ1.Resource.Name}"] = await rabbitMQ1.Resource.ConnectionStringExpression.GetValueAsync(default); 136hb.AddRabbitMQClient(rabbitMQ1.Resource.Name); 191hb.Configuration[$"ConnectionStrings:{rabbitMQ2.Resource.Name}"] = await rabbitMQ2.Resource.ConnectionStringExpression.GetValueAsync(default); 193hb.AddRabbitMQClient(rabbitMQ2.Resource.Name);
Aspire.Hosting.Redis (3)
RedisBuilderExtensions.cs (3)
89containerName ??= $"{builder.Resource.Name}-commander"; 128resourceBuilder.WithRelationship(builder.Resource, "RedisCommander"); 156containerName ??= $"{builder.Resource.Name}-insight";
Aspire.Hosting.Redis.Tests (59)
AddRedisTests.cs (12)
20Assert.Single(redis.Resource.Annotations, a => a is HealthCheckAnnotation hca && hca.Key == "redis_check"); 102var manifest = await ManifestUtils.GetManifest(redis.Resource); 225Assert.Equal($"myredis1:{redis.Resource.Name}:6379:0", config["REDIS_HOSTS"]); 249Assert.Equal($"myredis1:{redis1.Resource.Name}:6379:0,myredis2:myredis2:6379:0", config["REDIS_HOSTS"]); 269var volumeAnnotation = redis.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 294var volumeAnnotation = redis.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 309Assert.True(redis.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsCallbacks)); 328var persistenceAnnotation = redis.Resource.Annotations.OfType<CommandLineArgsCallbackAnnotation>().SingleOrDefault(); 340Assert.True(redis.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsCallbacks)); 359var persistenceAnnotation = redis.Resource.Annotations.OfType<CommandLineArgsCallbackAnnotation>().SingleOrDefault(); 372Assert.True(redis.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsCallbacks)); 391Assert.True(redis.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsAnnotations));
RedisFunctionalTests.cs (47)
50await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 52await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 56await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 58await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 79await app.WaitForTextAsync("Redis Connection", resourceName: commanderBuilder.Resource.Name); 81var client = app.CreateHttpClient(commanderBuilder.Resource.Name, "http"); 84var path = $"/apiv2/server/R:{redis.Resource.Name}:{endpoint.TargetPort}:0/info"; 105[$"ConnectionStrings:{redis.Resource.Name}"] = await redis.Resource.GetConnectionStringAsync() 108hb.AddRedisClient(redis.Resource.Name); 157builder1.Eventing.Subscribe<ResourceReadyEvent>(redisInsightBuilder.Resource, (evt, ct) => 169using var client1 = app1.CreateHttpClient($"{redis1.Resource.Name}-insight", "http"); 174Assert.Equal($"{redis1.Resource.Name}", firstRunDatabases[0].Name); 195builder2.Eventing.Subscribe<ResourceReadyEvent>(redisInsightBuilder.Resource, (evt, ct) => 206using var client2 = app2.CreateHttpClient($"{redisInsightBuilder.Resource.Name}", "http"); 211Assert.Equal($"{redis2.Resource.Name}", secondRunDatabases[0].Name); 223var latestEvent = await rns.WaitForResourceHealthyAsync(redisInsightBuilder.Resource.Name, cts.Token); 246builder.Eventing.Subscribe<ResourceReadyEvent>(redisInsightBuilder.Resource, (evt, ct) => 258var client = app.CreateHttpClient(redisInsightBuilder.Resource.Name, "http"); 269Assert.Equal(redis1.Resource.Name, db.Name); 270Assert.Equal(redis1.Resource.Name, db.Host); 271Assert.Equal(redis1.Resource.PrimaryEndpoint.TargetPort, db.Port); 277Assert.Equal(redis2.Resource.Name, db.Name); 278Assert.Equal(redis2.Resource.Name, db.Host); 279Assert.Equal(redis2.Resource.PrimaryEndpoint.TargetPort, db.Port); 316[$"ConnectionStrings:{redis1.Resource.Name}"] = $"{await redis1.Resource.GetConnectionStringAsync()},allowAdmin=true" 319hb.AddRedisClient(redis1.Resource.Name); 352[$"ConnectionStrings:{redis2.Resource.Name}"] = await redis2.Resource.GetConnectionStringAsync() 355hb.AddRedisClient(redis2.Resource.Name); 402[$"ConnectionStrings:{redis1.Resource.Name}"] = $"{await redis1.Resource.GetConnectionStringAsync()},allowAdmin=true" 405hb.AddRedisClient(redis1.Resource.Name); 437[$"ConnectionStrings:{redis2.Resource.Name}"] = await redis2.Resource.GetConnectionStringAsync() 440hb.AddRedisClient(redis2.Resource.Name); 486[$"ConnectionStrings:{redis1.Resource.Name}"] = $"{await redis1.Resource.GetConnectionStringAsync()},allowAdmin=true" 489hb.AddRedisClient(redis1.Resource.Name); 516[$"ConnectionStrings:{redis2.Resource.Name}"] = await redis2.Resource.GetConnectionStringAsync() 519hb.AddRedisClient(redis2.Resource.Name); 579builder1.Eventing.Subscribe<ResourceReadyEvent>(redisInsightBuilder1.Resource, (evt, ct) => 589var httpClient = app.CreateHttpClient(redisInsightBuilder1.Resource.Name, "http"); 622builder2.Eventing.Subscribe<ResourceReadyEvent>(redisInsightBuilder2.Resource, (evt, ct) => 632var httpClient = app.CreateHttpClient(redisInsightBuilder2.Resource.Name, "http");
Aspire.Hosting.SqlServer (3)
SqlServerBuilderExtensions.cs (3)
32var passwordParameter = password?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password", minLower: 1, minUpper: 1, minNumeric: 1); 78builder.Resource.AddDatabase(name, databaseName); 79var sqlServerDatabase = new SqlServerDatabaseResource(name, databaseName, builder.Resource);
Aspire.Hosting.SqlServer.Tests (28)
AddSqlServerTests.cs (13)
22Assert.Equal("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", sql.Resource.PasswordParameter.Default?.GetType().FullName); 32Assert.NotEqual("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", sql.Resource.PasswordParameter.Default?.GetType().FullName); 132var serverManifest = await ManifestUtils.GetManifest(sqlServer.Resource); 133var dbManifest = await ManifestUtils.GetManifest(db.Resource); 173var serverManifest = await ManifestUtils.GetManifest(sqlServer.Resource); 230Assert.Equal("customers1", db1.Resource.DatabaseName); 231Assert.Equal("customers2", db2.Resource.DatabaseName); 233Assert.Equal("{sqlserver1.connectionString};Database=customers1", db1.Resource.ConnectionStringExpression.ValueExpression); 234Assert.Equal("{sqlserver1.connectionString};Database=customers2", db2.Resource.ConnectionStringExpression.ValueExpression); 248Assert.Equal("imports", db1.Resource.DatabaseName); 249Assert.Equal("imports", db2.Resource.DatabaseName); 251Assert.Equal("{sqlserver1.connectionString};Database=imports", db1.Resource.ConnectionStringExpression.ValueExpression); 252Assert.Equal("{sqlserver2.connectionString};Database=imports", db2.Resource.ConnectionStringExpression.ValueExpression);
SqlServerFunctionalTests.cs (15)
46await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 48await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 52await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 54await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 81hb.Configuration[$"ConnectionStrings:{tempDb.Resource.Name}"] = await tempDb.Resource.ConnectionStringExpression.GetValueAsync(default); 83hb.AddSqlServerDbContext<TestDbContext>(tempDb.Resource.Name); 84hb.AddSqlServerClient(tempDb.Resource.Name); 140var password = sqlserver1.Resource.PasswordParameter.Value; 185[$"ConnectionStrings:{masterdb1.Resource.Name}"] = await masterdb1.Resource.ConnectionStringExpression.GetValueAsync(default), 188hb1.AddSqlServerClient(masterdb1.Resource.Name); 267[$"ConnectionStrings:{masterdb2.Resource.Name}"] = await masterdb2.Resource.ConnectionStringExpression.GetValueAsync(default), 270hb2.AddSqlServerClient(masterdb2.Resource.Name);
Aspire.Hosting.Testing.Tests (1)
tests\Aspire.Hosting.Tests\Utils\LoggerNotificationExtensions.cs (1)
36await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cancellationToken);
Aspire.Hosting.Tests (179)
AddParameterTests.cs (3)
106parameter.Resource.Default = new TestParameterDefault("DefaultValue"); 286Assert.IsType<UserSecretsParameterDefault>(parameter1.Resource.Default); 290Assert.IsType<GenerateParameterDefault>(parameter2.Resource.Default);
Codespaces\CodespacesUrlRewriterTests.cs (2)
77await rns.PublishUpdateAsync(resource.Resource, s => s with 85resource.Resource.Name,
Dashboard\DashboardResourceTests.cs (1)
105Assert.Same(container.Resource, dashboard);
Dcp\ApplicationExecutorTests.cs (7)
57.WithReplicas(2).Resource; 986HasKnownCommandAnnotations(exe.Resource); 987HasKnownCommandAnnotations(container.Resource); 988HasKnownCommandAnnotations(project.Resource); 997var childResource = builder.AddResource(new CustomChildResource("child", parentResource.Resource)); 1014if (item.Resource == parentResource.Resource) 1018else if (item.Resource == childResource.Resource)
DistributedApplicationTests.cs (6)
197using var clientA = app.CreateHttpClient(testProgram.ServiceABuilder.Resource.Name, "http"); 198using var clientC = app.CreateHttpClient(testProgram.ServiceCBuilder.Resource.Name, "http"); 205var uri = app.GetEndpoint(testProgram.ServiceBBuilder.Resource.Name, "http"); 747var httpEndPoint = app.GetEndpoint(testProgram.ServiceABuilder.Resource.Name, endpointName: "http"); 765var httpsEndpoint = app.GetEndpoint(testProgram.ServiceABuilder.Resource.Name, endpointName: "https"); 812using var clientA = app.CreateHttpClient(servicea.Resource.Name, "http");
Eventing\DistributedApplicationBuilderEventingTests.cs (1)
182builder.Eventing.Subscribe<BeforeResourceStartedEvent>(redis.Resource, (e, ct) =>
ExecutableResourceTests.cs (2)
39var args = await ArgumentEvaluator.GetArgumentListAsync(exe2.Resource).DefaultTimeout(); 51var manifest = await ManifestUtils.GetManifest(exe2.Resource).DefaultTimeout();
ExpressionResolverTests.cs (4)
53var csRef = new ConnectionStringReference(target.Resource, false); 65var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(source.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance, "ContainerHostName").DefaultTimeout(); 97var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(test.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance, "ContainerHostName").DefaultTimeout(); 116var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(test.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance, "ContainerHostName").DefaultTimeout();
Health\ResourceHealthCheckServiceTests.cs (23)
29await rns.PublishUpdateAsync(resource.Resource, s => s with 37await rns.PublishUpdateAsync(resource.Resource, s => s with 63await rns.PublishUpdateAsync(resource.Resource, s => s with 71await rns.PublishUpdateAsync(resource.Resource, s => s with 108await rns.PublishUpdateAsync(resource.Resource, s => s with 112await rns.WaitForResourceHealthyAsync(resource.Resource.Name, abortTokenSource.Token).DefaultTimeout(); 155await rns.PublishUpdateAsync(resource.Resource, s => s with 159await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, abortTokenSource.Token).DefaultTimeout(); 182builder.Eventing.Subscribe<ResourceReadyEvent>(resource.Resource, (@event, ct) => 192await rns.PublishUpdateAsync(resource.Resource, s => s with 198Assert.Equal(resource.Resource, @event.Resource); 224await rns.PublishUpdateAsync(resource.Resource, s => s with 262builder.Eventing.Subscribe<ResourceReadyEvent>(parent.Resource, (@event, ct) => 288await rns.PublishUpdateAsync(parent.Resource, s => s with 322builder.Eventing.Subscribe<ResourceReadyEvent>(parent.Resource, (@event, ct) => 333await rns.PublishUpdateAsync(parent.Resource, s => s with 366builder.Eventing.Subscribe<ResourceReadyEvent>(parent.Resource, (@event, ct) => 372var child = builder.AddResource(new ChildResource("child", parent.Resource)); 375builder.Eventing.Subscribe<ResourceReadyEvent>(child.Resource, (@event, ct) => 386await rns.PublishUpdateAsync(parent.Resource, s => s with 394await rns.PublishUpdateAsync(child.Resource, s => s with 400Assert.Equal(parentReadyEvent.Resource, parent.Resource); 403Assert.Equal(childReadyEvent.Resource, child.Resource);
HealthCheckTests.cs (4)
88await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running).DefaultTimeout(TestConstants.LongTimeoutDuration); 90await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting).DefaultTimeout(TestConstants.LongTimeoutDuration); 94await rns.WaitForResourceHealthyAsync(resource.Resource.Name).DefaultTimeout(TestConstants.LongTimeoutDuration); 96await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running).DefaultTimeout(TestConstants.LongTimeoutDuration);
ManifestGenerationTests.cs (3)
100var redisManifest = await ManifestUtils.GetManifest(redis.Resource).DefaultTimeout(); 499param.Resource.Default = new GenerateParameterDefault() 537var manifest = await ManifestUtils.GetManifest(param.Resource).DefaultTimeout();
ProjectResourceTests.cs (1)
587var args = await ArgumentEvaluator.GetArgumentListAsync(project.Resource).DefaultTimeout();
PublishAsConnectionStringTests.cs (2)
19Assert.True(redis.Resource.TryGetLastAnnotation<ManifestPublishingCallbackAnnotation>(out _)); 21var manifest = await ManifestUtils.GetManifest(redis.Resource).DefaultTimeout();
PublishAsDockerfileTests.cs (6)
20Assert.True(frontend.Resource.TryGetLastAnnotation<ManifestPublishingCallbackAnnotation>(out _)); 22var manifest = await ManifestUtils.GetManifest(frontend.Resource).DefaultTimeout(); 55Assert.True(frontend.Resource.TryGetLastAnnotation<ManifestPublishingCallbackAnnotation>(out _)); 57var manifest = await ManifestUtils.GetManifest(frontend.Resource).DefaultTimeout(); 93Assert.True(frontend.Resource.TryGetLastAnnotation<ManifestPublishingCallbackAnnotation>(out _)); 95var manifest = await ManifestUtils.GetManifest(frontend.Resource).DefaultTimeout();
ResourceCommandAnnotationTests.cs (2)
41resourceBuilder.Resource.AddLifeCycleCommands(); 43var startCommand = resourceBuilder.Resource.Annotations.OfType<ResourceCommandAnnotation>().Single(a => a.Name == commandName);
ResourceExtensionsTests.cs (30)
18Assert.False(parent.Resource.HasAnnotationOfType<DummyAnnotation>()); 19Assert.False(parent.Resource.TryGetAnnotationsOfType<DummyAnnotation>(out var annotations)); 30Assert.False(parent.Resource.HasAnnotationOfType<DummyAnnotation>()); 31Assert.False(parent.Resource.TryGetAnnotationsOfType<DummyAnnotation>(out var annotations)); 42Assert.True(parent.Resource.HasAnnotationOfType<DummyAnnotation>()); 43Assert.True(parent.Resource.TryGetAnnotationsOfType<DummyAnnotation>(out var annotations)); 54Assert.True(parent.Resource.HasAnnotationIncludingAncestorsOfType<DummyAnnotation>()); 55Assert.True(parent.Resource.TryGetAnnotationsIncludingAncestorsOfType<DummyAnnotation>(out var annotations)); 65Assert.False(parent.Resource.HasAnnotationIncludingAncestorsOfType<DummyAnnotation>()); 66Assert.False(parent.Resource.TryGetAnnotationsIncludingAncestorsOfType<DummyAnnotation>(out var annotations)); 77Assert.False(parent.Resource.HasAnnotationIncludingAncestorsOfType<DummyAnnotation>()); 78Assert.False(parent.Resource.TryGetAnnotationsIncludingAncestorsOfType<DummyAnnotation>(out var annotations)); 89var child = builder.AddResource(new ChildResource("child", parent.Resource)) 92Assert.False(parent.Resource.HasAnnotationIncludingAncestorsOfType<DummyAnnotation>()); 93Assert.False(child.Resource.TryGetAnnotationsIncludingAncestorsOfType<DummyAnnotation>(out var annotations)); 104var child = builder.AddResource(new ChildResource("child", parent.Resource)); 106Assert.True(parent.Resource.HasAnnotationIncludingAncestorsOfType<DummyAnnotation>()); 107Assert.True(child.Resource.TryGetAnnotationsIncludingAncestorsOfType<DummyAnnotation>(out var annotations)); 118var child = builder.AddResource(new ChildResource("child", parent.Resource)) 121Assert.True(parent.Resource.HasAnnotationIncludingAncestorsOfType<DummyAnnotation>()); 122Assert.True(child.Resource.TryGetAnnotationsIncludingAncestorsOfType<DummyAnnotation>(out var annotations)); 133var child = builder.AddResource(new ChildResource("child", parent: parent.Resource)) 136var grandchild = builder.AddResource(new ChildResource("grandchild", parent: child.Resource)) 139Assert.True(parent.Resource.HasAnnotationIncludingAncestorsOfType<DummyAnnotation>()); 140Assert.True(grandchild.Resource.TryGetAnnotationsIncludingAncestorsOfType<DummyAnnotation>(out var annotations)); 150Assert.True(container.Resource.TryGetContainerImageName(out var imageName)); 160Assert.True(container.Resource.TryGetContainerImageName(out var imageName)); 176var env = await container.Resource.GetEnvironmentVariableValuesAsync().DefaultTimeout(); 209var env = await container.Resource.GetEnvironmentVariableValuesAsync().DefaultTimeout(); 242var env = await container.Resource.GetEnvironmentVariableValuesAsync(DistributedApplicationOperation.Publish).DefaultTimeout();
ResourceNotificationTests.cs (1)
29var annotation = custom.Resource.Annotations.OfType<ResourceSnapshotAnnotation>().SingleOrDefault();
SlimTestProgramTests.cs (5)
34using var clientA = app.CreateHttpClient(testProgram.ServiceABuilder.Resource.Name, "http"); 37using var clientB = app.CreateHttpClient(testProgram.ServiceBBuilder.Resource.Name, "http"); 40using var clientC = app.CreateHttpClient(testProgram.ServiceCBuilder.Resource.Name, "http"); 56var endpoint = projectBuilders.Resource.Annotations.OfType<EndpointAnnotation>().Single(); 74var endpoint = projectBuilders.Resource.Annotations.OfType<EndpointAnnotation>().Single();
TestProgramFixture.cs (3)
69using var clientA = App.CreateHttpClient(TestProgram.ServiceABuilder.Resource.Name, "http"); 73using var clientB = App.CreateHttpClient(TestProgram.ServiceBBuilder.Resource.Name, "http"); 77using var clientC = App.CreateHttpClient(TestProgram.ServiceCBuilder.Resource.Name, "http");
Utils\LoggerNotificationExtensions.cs (1)
36await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cancellationToken);
Utils\VolumeNameGeneratorTests.cs (3)
23Assert.Equal($"{volumePrefix}-{resource.Resource.Name}-data", volumeName); 67Assert.Equal($"{runVolumePrefix}-{runResource.Resource.Name}-data", runVolumeName); 68Assert.Equal($"{publishVolumePrefix}-{publishResource.Resource.Name}-data", publishVolumeName);
Utils\WithAnnotationTests.cs (4)
18var dummyAnnotations = redis.Resource.Annotations.OfType<DummyAnnotation>(); 32var dummyAnnotations = redis.Resource.Annotations.OfType<DummyAnnotation>(); 44var firstAnnotation = redis.Resource.Annotations.OfType<DummyAnnotation>().Single(); 48var secondAnnotation = redis.Resource.Annotations.OfType<DummyAnnotation>().Single();
WaitForTests.cs (23)
32await rns.WaitForResourceAsync(throwingResource.Resource.Name, KnownResourceStates.FailedToStart, abortCts.Token); 33await rns.WaitForResourceAsync(dependingContainerResource.Resource.Name, KnownResourceStates.FailedToStart, abortCts.Token); 34await rns.WaitForResourceAsync(dependingExecutableResource.Resource.Name, KnownResourceStates.FailedToStart, abortCts.Token); 65var childResourceBuilder = builder.AddResource(new CustomChildResource("child", parentResourceBuilder.Resource)); 108await rns.WaitForResourceAsync(nginx.Resource.Name, "Waiting", waitingStateCts.Token); 113await rns.PublishUpdateAsync(dependency.Resource, s => s with 149await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.Waiting, waitingStateCts.Token); 154await rns.PublishUpdateAsync(dependency.Resource, s => s with 164await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.Running, runningStateCts.Token); 197await rns.WaitForResourceAsync(nginx.Resource.Name, "Waiting", waitingStateCts.Token); 202await rns.PublishUpdateAsync(dependency.Resource, s => s with 212await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.FailedToStart, runningStateCts.Token); 245await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.Waiting, waitingStateCts.Token); 250await rns.PublishUpdateAsync(dependency.Resource, s => s with 259await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.FailedToStart, runningStateCts.Token); 294await rns.WaitForResourceAsync(nginx.Resource.Name, "FailedToStart", waitingStateCts.Token); 328await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.Waiting, waitingStateCts.Token); 331await rns.PublishUpdateAsync(dependency.Resource, s => s with 336await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.Running, waitingStateCts.Token); 348var childResource = builder.AddResource(new CustomChildResource("child", parentResource.Resource)); 352Assert.True(containerResource.Resource.TryGetAnnotationsOfType<WaitAnnotation>(out var waitAnnotations)); 356a => Assert.Equal(a.Resource, parentResource.Resource), 357a => Assert.Equal(a.Resource, childResource.Resource)
WithEndpointTests.cs (17)
29var endpoint = projectA.Resource.Annotations.OfType<EndpointAnnotation>() 46var endpoint = projectA.Resource.Annotations.OfType<EndpointAnnotation>() 81var endpoint = projectA.Resource.Annotations.OfType<EndpointAnnotation>() 119Assert.False(projectA.Resource.TryGetAnnotationsOfType<EndpointAnnotation>(out var annotations)); 136Assert.True(projectA.Resource.TryGetAnnotationsOfType<EndpointAnnotation>(out _)); 153Assert.True(projectA.Resource.TryGetAnnotationsOfType<EndpointAnnotation>(out _)); 272var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 300var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 327var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 354var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 381var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 408var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 435var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 466var manifest = await ManifestUtils.GetManifest(project.Resource).DefaultTimeout(); 536var manifest = await ManifestUtils.GetManifest(project.Resource).DefaultTimeout(); 563var manifests = await ManifestUtils.GetManifests([container0.Resource, container1.Resource]).DefaultTimeout();
WithEnvironmentTests.cs (15)
31container.Resource, 53var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout(); 66var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(project.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout(); 82var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(project.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout(); 98var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectA.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout(); 115var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectA.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout(); 130var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectA.Resource, 147projectA.Resource, 170var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectA.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout(); 195.WithEnvironment("HOST", $"{test.Resource};name=1"); 197var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(containerB.Resource).DefaultTimeout(); 198var manifestConfig = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(containerB.Resource, DistributedApplicationOperation.Publish).DefaultTimeout(); 230var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(containerB.Resource).DefaultTimeout(); 254var runConfig = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(targetBuilder.Resource, DistributedApplicationOperation.Run).DefaultTimeout(); 260var publishConfig = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(targetBuilder.Resource, DistributedApplicationOperation.Publish).DefaultTimeout();
WithReferenceTests.cs (10)
29var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout(); 52var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout(); 77var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout(); 100var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout(); 121var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout(); 172var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance); 191var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout(); 207var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Publish).DefaultTimeout(); 223var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Publish).DefaultTimeout(); 296var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectA.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout();
Aspire.Hosting.Valkey.Tests (22)
AddValkeyTests.cs (9)
93var manifest = await ManifestUtils.GetManifest(valkey.Resource); 130var volumeAnnotation = valkey.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 155var volumeAnnotation = valkey.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 170Assert.True(valkey.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsCallbacks)); 189var persistenceAnnotation = valkey.Resource.Annotations.OfType<CommandLineArgsCallbackAnnotation>().SingleOrDefault(); 201Assert.True(valkey.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsCallbacks)); 220var persistenceAnnotation = valkey.Resource.Annotations.OfType<CommandLineArgsCallbackAnnotation>().SingleOrDefault(); 233Assert.True(valkey.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsCallbacks)); 252Assert.True(valkey.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsAnnotations));
ValkeyFunctionalTests.cs (13)
36[$"ConnectionStrings:{valkey.Resource.Name}"] = await valkey.Resource.ConnectionStringExpression.GetValueAsync(default) 39hb.AddRedisClient(valkey.Resource.Name); 97[$"ConnectionStrings:{valkey1.Resource.Name}"] = $"{await valkey1.Resource.ConnectionStringExpression.GetValueAsync(default)},allowAdmin=true" 100hb.AddRedisClient(valkey1.Resource.Name); 148[$"ConnectionStrings:{valkey2.Resource.Name}"] = await valkey2.Resource.ConnectionStringExpression.GetValueAsync(default) 151hb.AddRedisClient(valkey2.Resource.Name); 221await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 223await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 227await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 229await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token);
Aspire.Playground.Tests (1)
tests\Aspire.Hosting.Tests\Utils\LoggerNotificationExtensions.cs (1)
36await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cancellationToken);
BicepSample.AppHost (1)
Program.cs (1)
25temp00 = bicep0.Resource;
KafkaBasic.AppHost (2)
Program.cs (2)
11.WithArgs(kafka.Resource.Name); 15.WithArgs(kafka.Resource.Name);
Stress.AppHost (5)
Program.cs (2)
13IResource parent = rb.Resource; 19parent = nestedRb.Resource;
ResourceBuilderExtensions.cs (3)
43var endpoints = builder.Resource.GetEndpoints(); 45?? throw new DistributedApplicationException($"Could not create HTTP command for resource '{builder.Resource.Name}' as no endpoint named '{endpointName}' was found."); 58return new ExecuteCommandResult { Success = false, ErrorMessage = $"The endpoint named '{endpointName}' on resource '{builder.Resource.Name}' does not have the expected scheme of '{expectedScheme}'." };