Skip to content

Commit

Permalink
Update Azure.Provisioning to latest
Browse files Browse the repository at this point in the history
Respond to latest renames getting the API ready for GA release.

Fix #6376
  • Loading branch information
eerhardt authored and github-actions committed Oct 25, 2024
1 parent 4febb16 commit 1254985
Show file tree
Hide file tree
Showing 27 changed files with 95 additions and 91 deletions.
8 changes: 4 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
<TestcontainersPackageVersion>3.10.0</TestcontainersPackageVersion>
<AzureProvisiongVersion>1.0.0-beta.1</AzureProvisiongVersion>
<AzureProvisiongVersion>1.0.0-alpha.20241018.6</AzureProvisiongVersion>
</PropertyGroup>
<ItemGroup>
<!-- AWS SDK for .NET dependencies -->
Expand Down Expand Up @@ -41,13 +41,13 @@
<!-- Azure Management SDK for .NET dependencies -->
<PackageVersion Include="Azure.Provisioning" Version="$(AzureProvisiongVersion)" />
<PackageVersion Include="Azure.Provisioning.AppConfiguration" Version="$(AzureProvisiongVersion)" />
<PackageVersion Include="Azure.Provisioning.AppContainers" Version="$(AzureProvisiongVersion)" />
<PackageVersion Include="Azure.Provisioning.ApplicationInsights" Version="$(AzureProvisiongVersion)" />
<PackageVersion Include="Azure.Provisioning.AppContainers" Version="1.0.0-alpha.20241018.5" />
<PackageVersion Include="Azure.Provisioning.ApplicationInsights" Version="1.0.0-alpha.20241018.5" />
<PackageVersion Include="Azure.Provisioning.CognitiveServices" Version="$(AzureProvisiongVersion)" />
<PackageVersion Include="Azure.Provisioning.CosmosDB" Version="$(AzureProvisiongVersion)" />
<PackageVersion Include="Azure.Provisioning.EventHubs" Version="$(AzureProvisiongVersion)" />
<PackageVersion Include="Azure.Provisioning.KeyVault" Version="$(AzureProvisiongVersion)" />
<PackageVersion Include="Azure.Provisioning.OperationalInsights" Version="$(AzureProvisiongVersion)" />
<PackageVersion Include="Azure.Provisioning.OperationalInsights" Version="1.0.0-alpha.20241018.5" />
<PackageVersion Include="Azure.Provisioning.PostgreSql" Version="$(AzureProvisiongVersion)" />
<PackageVersion Include="Azure.Provisioning.Redis" Version="$(AzureProvisiongVersion)" />
<PackageVersion Include="Azure.Provisioning.Search" Version="$(AzureProvisiongVersion)" />
Expand Down
4 changes: 4 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<add key="dotnet9" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json" />
<add key="dotnet-libraries" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-libraries/nuget/v3/index.json" />
<add key="dotnet9-transport" value="https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet9-transport/nuget/v3/index.json" />
<add key="azure-sdk-devfeed" value="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json" />
</packageSources>
<packageSourceMapping>
<packageSource key="dotnet9-transport">
Expand All @@ -35,6 +36,9 @@
<packageSource key="dotnet-eng">
<package pattern="*" />
</packageSource>
<packageSource key="azure-sdk-devfeed">
<package pattern="Azure.*" />
</packageSource>
</packageSourceMapping>
<disabledPackageSources>
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
Expand Down
18 changes: 9 additions & 9 deletions playground/cdk/CdkSample.AppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
var storage = builder.AddAzureStorage("storage")
.ConfigureInfrastructure(infrastructure =>
{
var account = infrastructure.GetResources().OfType<StorageAccount>().Single();
var account = infrastructure.GetProvisionableResources().OfType<StorageAccount>().Single();
account.Sku = new StorageSku() { Name = sku.AsProvisioningParameter(infrastructure) };
account.Location = locationOverride.AsProvisioningParameter(infrastructure);
});
Expand All @@ -30,7 +30,7 @@
var keyvault = builder.AddAzureKeyVault("mykv")
.ConfigureInfrastructure(infrastructure =>
{
var keyVault = infrastructure.GetResources().OfType<KeyVaultService>().Single();
var keyVault = infrastructure.GetProvisionableResources().OfType<KeyVaultService>().Single();
var secret = new KeyVaultSecret("mysecret")
{
Parent = keyVault,
Expand All @@ -55,24 +55,24 @@
.AddQueue("queue1")
.ConfigureInfrastructure(infrastructure =>
{
var queue = infrastructure.GetResources().OfType<ServiceBusQueue>().Single(q => q.IdentifierName == "queue1");
var queue = infrastructure.GetProvisionableResources().OfType<ServiceBusQueue>().Single(q => q.BicepIdentifier == "queue1");
queue.MaxDeliveryCount = 5;
queue.LockDuration = new StringLiteral("PT5M");
queue.LockDuration = new StringLiteralExpression("PT5M");
// TODO: this should be
// queue.LockDuration = TimeSpan.FromMinutes(5);
})
.AddTopic("topic1")
.ConfigureInfrastructure(infrastructure =>
{
var topic = infrastructure.GetResources().OfType<ServiceBusTopic>().Single(q => q.IdentifierName == "topic1");
var topic = infrastructure.GetProvisionableResources().OfType<ServiceBusTopic>().Single(q => q.BicepIdentifier == "topic1");
topic.EnablePartitioning = true;
})
.AddTopic("topic2")
.AddSubscription("topic1", "subscription1")
.ConfigureInfrastructure(infrastructure =>
{
var subscription = infrastructure.GetResources().OfType<ServiceBusSubscription>().Single(q => q.IdentifierName == "subscription1");
subscription.LockDuration = new StringLiteral("PT5M");
var subscription = infrastructure.GetProvisionableResources().OfType<ServiceBusSubscription>().Single(q => q.BicepIdentifier == "subscription1");
subscription.LockDuration = new StringLiteralExpression("PT5M");
// TODO: this should be
//subscription.LockDuration = TimeSpan.FromMinutes(5);
subscription.RequiresSession = true;
Expand All @@ -89,7 +89,7 @@
var logAnalyticsWorkspace = builder.AddAzureLogAnalyticsWorkspace("logAnalyticsWorkspace")
.ConfigureInfrastructure(infrastructure =>
{
var logAnalyticsWorkspace = infrastructure.GetResources().OfType<OperationalInsightsWorkspace>().Single();
var logAnalyticsWorkspace = infrastructure.GetProvisionableResources().OfType<OperationalInsightsWorkspace>().Single();
logAnalyticsWorkspace.Sku = new OperationalInsightsWorkspaceSku()
{
Name = OperationalInsightsWorkspaceSkuName.PerNode
Expand All @@ -99,7 +99,7 @@
var appInsights = builder.AddAzureApplicationInsights("appInsights", logAnalyticsWorkspace)
.ConfigureInfrastructure(infrastructure =>
{
var appInsights = infrastructure.GetResources().OfType<ApplicationInsightsComponent>().Single();
var appInsights = infrastructure.GetProvisionableResources().OfType<ApplicationInsightsComponent>().Single();
appInsights.IngestionMode = ComponentIngestionMode.LogAnalytics;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void BuildContainerApp(AzureResourceInfrastructure c)
containerImageParam = AllocateContainerImageParameter();
}

var containerAppResource = new ContainerApp(Infrastructure.NormalizeIdentifierName(resource.Name))
var containerAppResource = new ContainerApp(Infrastructure.NormalizeBicepIdentifier(resource.Name))
{
Name = resource.Name.ToLowerInvariant()
};
Expand Down Expand Up @@ -714,7 +714,7 @@ private BicepValue<string> AllocateKeyVaultSecretUriReference(BicepSecretOutputR
{
// We resolve the keyvault that represents the storage for secret outputs
var parameter = AllocateParameter(SecretOutputExpression.GetSecretOutputKeyVault(secretOutputReference.Resource));
kv = KeyVaultService.FromExisting($"{parameter.IdentifierName}_kv");
kv = KeyVaultService.FromExisting($"{parameter.BicepIdentifier}_kv");
kv.Name = parameter;

KeyVaultRefs[secretOutputReference.Resource.Name] = kv;
Expand All @@ -723,8 +723,8 @@ private BicepValue<string> AllocateKeyVaultSecretUriReference(BicepSecretOutputR
if (!KeyVaultSecretRefs.TryGetValue(secretOutputReference.ValueExpression, out var secret))
{
// Now we resolve the secret
var secretIdentifierName = Infrastructure.NormalizeIdentifierName($"{kv.IdentifierName}_{secretOutputReference.Name}");
secret = KeyVaultSecret.FromExisting(secretIdentifierName);
var secretBicepIdentifier = Infrastructure.NormalizeBicepIdentifier($"{kv.BicepIdentifier}_{secretOutputReference.Name}");
secret = KeyVaultSecret.FromExisting(secretBicepIdentifier);
secret.Name = secretOutputReference.Name;
secret.Parent = kv;

Expand All @@ -734,7 +734,7 @@ private BicepValue<string> AllocateKeyVaultSecretUriReference(BicepSecretOutputR
// TODO: There should be a better way to do this?
return new MemberExpression(
new MemberExpression(
new IdentifierExpression(secret.IdentifierName), "properties"),
new IdentifierExpression(secret.BicepIdentifier), "properties"),
"secretUri");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ public static IResourceBuilder<AzureApplicationInsightsResource> AddAzureApplica
{
var appTypeParameter = new ProvisioningParameter("applicationType", typeof(string))
{
Value = new StringLiteral("web")
Value = new StringLiteralExpression("web")
};
infrastructure.Add(appTypeParameter);

var kindParameter = new ProvisioningParameter("kind", typeof(string))
{
Value = new StringLiteral("web")
Value = new StringLiteralExpression("web")
};
infrastructure.Add(kindParameter);

Expand All @@ -67,7 +67,7 @@ public static IResourceBuilder<AzureApplicationInsightsResource> AddAzureApplica
else if (builder.ExecutionContext.IsRunMode)
{
// ... otherwise if we are in run mode, the provisioner expects us to create one ourselves.
var autoInjectedLogAnalyticsWorkspaceName = $"law_{appInsights.IdentifierName}";
var autoInjectedLogAnalyticsWorkspaceName = $"law_{appInsights.BicepIdentifier}";
var autoInjectedLogAnalyticsWorkspace = new OperationalInsightsWorkspace(autoInjectedLogAnalyticsWorkspaceName)
{
Sku = new OperationalInsightsWorkspaceSku()
Expand All @@ -89,7 +89,7 @@ public static IResourceBuilder<AzureApplicationInsightsResource> AddAzureApplica
infrastructure.AspireResource.Parameters.TryAdd(AzureBicepResource.KnownParameters.LogAnalyticsWorkspaceId, null);
var logAnalyticsWorkspaceParameter = new ProvisioningParameter(AzureBicepResource.KnownParameters.LogAnalyticsWorkspaceId, typeof(string))
{
Value = new StringLiteral("web")
Value = new StringLiteralExpression("web")
};
infrastructure.Add(kindParameter);
appInsights.WorkspaceResourceId = logAnalyticsWorkspaceParameter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ public static IResourceBuilder<AzureOpenAIResource> AddAzureOpenAI(this IDistrib

infrastructure.Add(new ProvisioningOutput("connectionString", typeof(string))
{
Value = new InterpolatedString(
Value = new InterpolatedStringExpression(
"Endpoint={0}",
[
new MemberExpression(
new MemberExpression(
new IdentifierExpression(cogServicesAccount.IdentifierName),
new IdentifierExpression(cogServicesAccount.BicepIdentifier),
"properties"),
"endpoint")
])
Expand All @@ -71,7 +71,7 @@ public static IResourceBuilder<AzureOpenAIResource> AddAzureOpenAI(this IDistrib
var cdkDeployments = new List<CognitiveServicesAccountDeployment>();
foreach (var deployment in resource.Deployments)
{
var cdkDeployment = new CognitiveServicesAccountDeployment(Infrastructure.NormalizeIdentifierName(deployment.Name))
var cdkDeployment = new CognitiveServicesAccountDeployment(Infrastructure.NormalizeBicepIdentifier(deployment.Name))
{
Name = deployment.Name,
Parent = cogServicesAccount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static IResourceBuilder<AzureCosmosDBResource> AddAzureCosmosDB(this IDis
List<CosmosDBSqlDatabase> cosmosSqlDatabases = new List<CosmosDBSqlDatabase>();
foreach (var databaseName in azureResource.Databases)
{
var cosmosSqlDatabase = new CosmosDBSqlDatabase(Infrastructure.NormalizeIdentifierName(databaseName))
var cosmosSqlDatabase = new CosmosDBSqlDatabase(Infrastructure.NormalizeBicepIdentifier(databaseName))
{
Parent = cosmosAccount,
Name = databaseName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static IResourceBuilder<AzureEventHubsResource> AddAzureEventHubs(
{
var skuParameter = new ProvisioningParameter("sku", typeof(string))
{
Value = new StringLiteral("Standard")
Value = new StringLiteralExpression("Standard")
};
infrastructure.Add(skuParameter);

Expand All @@ -58,7 +58,7 @@ public static IResourceBuilder<AzureEventHubsResource> AddAzureEventHubs(

foreach (var hub in azureResource.Hubs)
{
var hubResource = new EventHub(Infrastructure.NormalizeIdentifierName(hub))
var hubResource = new EventHub(Infrastructure.NormalizeBicepIdentifier(hub))
{
Parent = eventHubsNamespace,
Name = hub
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static class AzureFunctionsProjectResourceExtensions
var principalTypeParameter = new ProvisioningParameter(AzureBicepResource.KnownParameters.PrincipalType, typeof(string));
var principalIdParameter = new ProvisioningParameter(AzureBicepResource.KnownParameters.PrincipalId, typeof(string));

var storageAccount = infrastructure.GetResources().OfType<StorageAccount>().FirstOrDefault(r => r.IdentifierName == storageResourceName)
var storageAccount = infrastructure.GetProvisionableResources().OfType<StorageAccount>().FirstOrDefault(r => r.BicepIdentifier == storageResourceName)
?? throw new InvalidOperationException($"Could not find storage account with '{storageResourceName}' name.");
infrastructure.Add(storageAccount.CreateRoleAssignment(StorageBuiltInRole.StorageAccountContributor, principalTypeParameter, principalIdParameter));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static IResourceBuilder<AzureKeyVaultResource> AddAzureKeyVault(this IDis
Value =
new MemberExpression(
new MemberExpression(
new IdentifierExpression(keyVault.IdentifierName),
new IdentifierExpression(keyVault.BicepIdentifier),
"properties"),
"vaultUri")
// TODO: this should be
Expand Down
18 changes: 9 additions & 9 deletions src/Aspire.Hosting.Azure.PostgreSQL/AzurePostgresExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static IResourceBuilder<AzurePostgresFlexibleServerResource> AddAzurePost
var principalTypeParameter = new ProvisioningParameter(AzureBicepResource.KnownParameters.PrincipalType, typeof(string));
var principalNameParameter = new ProvisioningParameter(AzureBicepResource.KnownParameters.PrincipalName, typeof(string));

var admin = new PostgreSqlFlexibleServerActiveDirectoryAdministrator($"{postgres.IdentifierName}_admin")
var admin = new PostgreSqlFlexibleServerActiveDirectoryAdministrator($"{postgres.BicepIdentifier}_admin")
{
Parent = postgres,
Name = principalIdParameter,
Expand All @@ -167,7 +167,7 @@ public static IResourceBuilder<AzurePostgresFlexibleServerResource> AddAzurePost

// This is a workaround for a bug in the API that requires the parent to be fully resolved
admin.DependsOn.Add(postgres);
foreach (var firewall in infrastructure.GetResources().OfType<PostgreSqlFlexibleServerFirewallRule>())
foreach (var firewall in infrastructure.GetProvisionableResources().OfType<PostgreSqlFlexibleServerFirewallRule>())
{
admin.DependsOn.Add(firewall);
}
Expand Down Expand Up @@ -355,7 +355,7 @@ public static IResourceBuilder<AzurePostgresFlexibleServerResource> WithPassword

RemoveActiveDirectoryAuthResources(infrastructure);

var postgres = infrastructure.GetResources().OfType<PostgreSqlFlexibleServer>().FirstOrDefault(r => r.IdentifierName == azureResource.GetBicepIdentifier())
var postgres = infrastructure.GetProvisionableResources().OfType<PostgreSqlFlexibleServer>().FirstOrDefault(r => r.BicepIdentifier == azureResource.GetBicepIdentifier())
?? throw new InvalidOperationException($"Could not find a PostgreSqlFlexibleServer with name {azureResource.Name}.");

var administratorLogin = new ProvisioningParameter("administratorLogin", typeof(string));
Expand Down Expand Up @@ -393,7 +393,7 @@ public static IResourceBuilder<AzurePostgresFlexibleServerResource> WithPassword

foreach (var database in azureResource.Databases)
{
var dbSecret = new KeyVaultSecret(Infrastructure.NormalizeIdentifierName(database.Key + "_connectionString"))
var dbSecret = new KeyVaultSecret(Infrastructure.NormalizeBicepIdentifier(database.Key + "_connectionString"))
{
Parent = keyVault,
Name = AzurePostgresFlexibleServerResource.GetDatabaseKeyVaultSecretName(database.Key),
Expand All @@ -417,7 +417,7 @@ private static PostgreSqlFlexibleServer CreatePostgreSqlFlexibleServer(AzureReso
Name = "Standard_B1ms",
Tier = PostgreSqlFlexibleServerSkuTier.Burstable
},
Version = new StringLiteral("16"),
Version = new StringLiteralExpression("16"),
HighAvailability = new PostgreSqlFlexibleServerHighAvailability()
{
Mode = PostgreSqlFlexibleServerHighAvailabilityMode.Disabled
Expand Down Expand Up @@ -455,9 +455,9 @@ private static PostgreSqlFlexibleServer CreatePostgreSqlFlexibleServer(AzureReso

foreach (var databaseNames in databases)
{
var identifierName = Infrastructure.NormalizeIdentifierName(databaseNames.Key);
var BicepIdentifier = Infrastructure.NormalizeBicepIdentifier(databaseNames.Key);
var databaseName = databaseNames.Value;
var pgsqlDatabase = new PostgreSqlFlexibleServerDatabase(identifierName)
var pgsqlDatabase = new PostgreSqlFlexibleServerDatabase(BicepIdentifier)
{
Parent = postgres,
Name = databaseName
Expand All @@ -480,13 +480,13 @@ private static IResourceBuilder<AzurePostgresFlexibleServerResource> RemoveActiv
private static void RemoveActiveDirectoryAuthResources(AzureResourceInfrastructure infrastructure)
{
var resourcesToRemove = new List<Provisionable>();
foreach (var resource in infrastructure.GetResources())
foreach (var resource in infrastructure.GetProvisionableResources())
{
if (resource is PostgreSqlFlexibleServerActiveDirectoryAdministrator)
{
resourcesToRemove.Add(resource);
}
else if (resource is ProvisioningOutput output && output.IdentifierName == "connectionString")
else if (resource is ProvisioningOutput output && output.BicepIdentifier == "connectionString")
{
resourcesToRemove.Add(resource);
}
Expand Down
Loading

0 comments on commit 1254985

Please sign in to comment.