Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Aspire.Hosting.Azure/AzureBicepResourceScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private AzureBicepResourceScope(object? resourceGroup, object? subscription, boo
/// </summary>
/// <param name="subscription">The subscription identifier for subscription-level resources.</param>
/// <returns>A new <see cref="AzureBicepResourceScope"/> scoped to the subscription.</returns>
public static AzureBicepResourceScope ForSubscription(object subscription)
public static AzureBicepResourceScope CreateForSubscription(object subscription)
{
ArgumentNullException.ThrowIfNull(subscription);

Expand All @@ -54,7 +54,7 @@ public static AzureBicepResourceScope ForSubscription(object subscription)
/// Creates a scope for tenant-level resources in the current tenant.
/// </summary>
/// <returns>A new <see cref="AzureBicepResourceScope"/> scoped to the current tenant.</returns>
public static AzureBicepResourceScope ForTenant()
public static AzureBicepResourceScope CreateForTenant()
{
return new AzureBicepResourceScope(resourceGroup: null, subscription: null, isTenantScope: true);
}
Expand All @@ -80,14 +80,14 @@ public static AzureBicepResourceScope ForTenant()

if (annotation.IsTenantScope)
{
return ForTenant();
return CreateForTenant();
}

return (annotation.ResourceGroup, annotation.Subscription) switch
{
({ } resourceGroup, { } subscription) => new AzureBicepResourceScope(resourceGroup, subscription),
({ } resourceGroup, null) => new AzureBicepResourceScope(resourceGroup),
(null, { } subscription) => ForSubscription(subscription),
(null, { } subscription) => CreateForSubscription(subscription),
_ => null
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public async Task GetOrCreateResourceAsync_WithSubscriptionScope_UsesSubscriptio
targetScope = 'subscription'
output result string = 'ok'
""");
resource.Scope = AzureBicepResourceScope.ForSubscription(subscription.Id.Name);
resource.Scope = AzureBicepResourceScope.CreateForSubscription(subscription.Id.Name);

var provisioner = CreateProvisioner(services);
var context = ProvisioningTestHelpers.CreateTestProvisioningContext(
Expand Down Expand Up @@ -195,7 +195,7 @@ public async Task GetOrCreateResourceAsync_WithTenantScope_UsesTenantDeploymentC
targetScope = 'tenant'
output result string = 'ok'
""");
resource.Scope = AzureBicepResourceScope.ForTenant();
resource.Scope = AzureBicepResourceScope.CreateForTenant();

var provisioner = CreateProvisioner(services);
var context = ProvisioningTestHelpers.CreateTestProvisioningContext(
Expand Down Expand Up @@ -293,7 +293,7 @@ public async Task GetOrCreateResourceAsync_WithSubscriptionScopeInRunMode_UsesSu
targetScope = 'subscription'
output result string = 'ok'
""");
resource.Scope = AzureBicepResourceScope.ForSubscription(subscription.Id.Name);
resource.Scope = AzureBicepResourceScope.CreateForSubscription(subscription.Id.Name);

var provisioner = CreateProvisioner(services, DistributedApplicationOperation.Run);
var context = ProvisioningTestHelpers.CreateTestProvisioningContext(
Expand Down Expand Up @@ -671,7 +671,7 @@ public async Task GetOrCreateResourceAsync_PublishesSubscriptionScopedPredictedD
var tenant = new TestTenantResource();
var resource = new AzureBicepResource("subscriptionDeployment", templateString: "output name string = 'subscriptionDeployment'")
{
Scope = AzureBicepResourceScope.ForSubscription(subscription.Id.Name)
Scope = AzureBicepResourceScope.CreateForSubscription(subscription.Id.Name)
};

var provisioner = new BicepProvisioner(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ param location string

output value string = 'subscription'
""");
subscriptionScoped.Resource.Scope = AzureBicepResourceScope.ForSubscription(subscription.Resource);
subscriptionScoped.Resource.Scope = AzureBicepResourceScope.CreateForSubscription(subscription.Resource);

var tenantScoped = builder.AddBicepTemplateString("tenantScoped",
"""
Expand All @@ -210,7 +210,7 @@ param location string

output value string = 'tenant'
""");
tenantScoped.Resource.Scope = AzureBicepResourceScope.ForTenant();
tenantScoped.Resource.Scope = AzureBicepResourceScope.CreateForTenant();

var app = builder.Build();
app.Run();
Expand Down
8 changes: 4 additions & 4 deletions tests/Aspire.Hosting.Azure.Tests/BicepUtilitiesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public async Task SetScopeAsync_SetsSubscriptionFromScope()
{
using var builder = TestDistributedApplicationBuilder.Create();
var bicep = builder.AddBicepTemplateString("test", "param name string").Resource;
bicep.Scope = AzureBicepResourceScope.ForSubscription("12345678-1234-1234-1234-123456789012");
bicep.Scope = AzureBicepResourceScope.CreateForSubscription("12345678-1234-1234-1234-123456789012");

var scope = new JsonObject();

Expand All @@ -379,7 +379,7 @@ public async Task SetScopeAsync_RemovesStaleScopeValues()
{
using var builder = TestDistributedApplicationBuilder.Create();
var bicep = builder.AddBicepTemplateString("test", "param name string").Resource;
bicep.Scope = AzureBicepResourceScope.ForSubscription("12345678-1234-1234-1234-123456789012");
bicep.Scope = AzureBicepResourceScope.CreateForSubscription("12345678-1234-1234-1234-123456789012");

var scope = new JsonObject
{
Expand All @@ -398,7 +398,7 @@ public async Task SetScopeAsync_SetsTenantFromScope()
{
using var builder = TestDistributedApplicationBuilder.Create();
var bicep = builder.AddBicepTemplateString("test", "param name string").Resource;
bicep.Scope = AzureBicepResourceScope.ForTenant();
bicep.Scope = AzureBicepResourceScope.CreateForTenant();

var scope = new JsonObject();

Expand Down Expand Up @@ -489,7 +489,7 @@ public async Task GetCurrentChecksumAsync_UsesCurrentScopeWhenSavedScopeIsMissin
await BicepUtilities.SetParametersAsync(legacyParameters, bicep);
var legacyChecksum = BicepUtilities.GetChecksum(bicep, legacyParameters, scope: null);

bicep.Scope = AzureBicepResourceScope.ForSubscription("12345678-1234-1234-1234-123456789012");
bicep.Scope = AzureBicepResourceScope.CreateForSubscription("12345678-1234-1234-1234-123456789012");

var configurationBuilder = new ConfigurationBuilder();
configurationBuilder.AddInMemoryCollection(new Dictionary<string, string?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ param value string
output id string = 'subscription'
""")
.WithParameter("value", "unused");
resource.Resource.Scope = AzureBicepResourceScope.ForSubscription(existingSubscriptionId.Resource);
resource.Resource.Scope = AzureBicepResourceScope.CreateForSubscription(existingSubscriptionId.Resource);

var (manifest, bicep) = await AzureManifestUtils.GetManifestWithBicep(resource.Resource, skipPreparer: true);

Expand All @@ -604,7 +604,7 @@ public async Task SupportsBicepTemplateWithTenantScopeInPublishMode()

output id string = 'tenant'
""");
resource.Resource.Scope = AzureBicepResourceScope.ForTenant();
resource.Resource.Scope = AzureBicepResourceScope.CreateForTenant();

var (manifest, bicep) = await AzureManifestUtils.GetManifestWithBicep(resource.Resource, skipPreparer: true);

Expand Down
Loading