diff --git a/src/Aspire.Hosting.Azure.Sql/AzureSqlServerResource.cs b/src/Aspire.Hosting.Azure.Sql/AzureSqlServerResource.cs index 2349e17273b..e28137c91fe 100644 --- a/src/Aspire.Hosting.Azure.Sql/AzureSqlServerResource.cs +++ b/src/Aspire.Hosting.Azure.Sql/AzureSqlServerResource.cs @@ -156,9 +156,10 @@ public override void AddRoleAssignments(IAddRoleAssignmentsContext roleAssignmen foreach (var (resource, database) in Databases) { var uniqueScriptIdentifier = Infrastructure.NormalizeBicepIdentifier($"{this.GetBicepIdentifier()}_{resource}"); - var scriptResource = new SqlServerScriptProvisioningResource($"script_{uniqueScriptIdentifier}") + var scriptResource = new AzurePowerShellScript($"script_{uniqueScriptIdentifier}") { Name = BicepFunction.Take(BicepFunction.Interpolate($"script-{BicepFunction.GetUniqueString(this.GetBicepIdentifier(), roleAssignmentContext.PrincipalName, new StringLiteralExpression(resource), BicepFunction.GetResourceGroup().Id)}"), 24), + RetentionInterval = TimeSpan.FromHours(1), // List of supported versions: https://mcr.microsoft.com/v2/azuredeploymentscripts-powershell/tags/list AzPowerShellVersion = "10.0" }; diff --git a/src/Aspire.Hosting.Azure.Sql/SqlServerScriptProvisioningResource.cs b/src/Aspire.Hosting.Azure.Sql/SqlServerScriptProvisioningResource.cs deleted file mode 100644 index cfbc1b79f17..00000000000 --- a/src/Aspire.Hosting.Azure.Sql/SqlServerScriptProvisioningResource.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Azure.Provisioning; -using Azure.Provisioning.Resources; - -namespace Aspire.Hosting.Azure; - -// The AzurePowerShellScript class doesn't work correctly. -// See https://github.com/Azure/azure-sdk-for-net/issues/51135 -// Reference: https://learn.microsoft.com/azure/azure-resource-manager/templates/deployment-script-template -sealed class SqlServerScriptProvisioningResource : AzurePowerShellScript -{ - private BicepValue? _retentionIntervalOverride; - - public SqlServerScriptProvisioningResource(string bicepIdentifier) : base(bicepIdentifier) - { - RetentionInterval = TimeSpan.FromHours(1); - RetentionIntervalOverride = TimeSpan.FromHours(1); - } - - /// - /// Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. Duration is based on ISO 8601 pattern (for example P1D means one day). - /// - public BicepValue RetentionIntervalOverride - { - get { Initialize(); return _retentionIntervalOverride!; } - set { Initialize(); _retentionIntervalOverride!.Assign(value); } - } - - protected override void DefineProvisionableProperties() - { - base.DefineProvisionableProperties(); - - DefineProperty("Kind", ["kind"], defaultValue: "AzurePowerShell"); - _retentionIntervalOverride = DefineProperty(nameof(RetentionInterval), ["properties", "retentionInterval"], format: "P"); - } -}