Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove ToProvisioningEntity on AzureTableStorageResource
This doesn't work because of Azure/azure-sdk-for-net#51210. Reverting back to the 9.3 behavior of not creating the bicep resource at all, which is fine for now since we don't have child table resources yet.
  • Loading branch information
eerhardt authored and github-actions committed Jul 11, 2025
commit 4ef72e4a901b22f1c411c45dd66fb1b5c9bf99a4
9 changes: 0 additions & 9 deletions src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,6 @@ public static IResourceBuilder<AzureStorageResource> AddAzureStorage(this IDistr
}
}

if (azureResource.TableStorageResource is not null)
{
var tableService = azureResource.TableStorageResource.ToProvisioningEntity();
tableService.Parent = storageAccount;
infrastructure.Add(tableService);
}

infrastructure.Add(new ProvisioningOutput("blobEndpoint", typeof(string)) { Value = storageAccount.PrimaryEndpoints.BlobUri });
infrastructure.Add(new ProvisioningOutput("queueEndpoint", typeof(string)) { Value = storageAccount.PrimaryEndpoints.QueueUri });
infrastructure.Add(new ProvisioningOutput("tableEndpoint", typeof(string)) { Value = storageAccount.PrimaryEndpoints.TableUri });
Expand Down Expand Up @@ -470,8 +463,6 @@ public static IResourceBuilder<AzureTableStorageResource> AddTableService(this I
name ??= builder.Resource.Name + "-tables";

var resource = new AzureTableStorageResource(name, builder.Resource);
builder.Resource.TableStorageResource = resource;

return builder.ApplicationBuilder.AddResource(resource);
}

Expand Down
1 change: 0 additions & 1 deletion src/Aspire.Hosting.Azure.Storage/AzureStorageResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class AzureStorageResource(string name, Action<AzureResourceInfrastructur

internal AzureBlobStorageResource? BlobStorageResource { get; set; }
internal AzureQueueStorageResource? QueueStorageResource { get; set; }
internal AzureTableStorageResource? TableStorageResource { get; set; }

internal List<AzureBlobStorageContainerResource> BlobContainers { get; } = [];

Expand Down
44 changes: 0 additions & 44 deletions src/Aspire.Hosting.Azure.Storage/AzureTableStorageResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.

using Aspire.Hosting.ApplicationModel;
using Azure.Provisioning;

namespace Aspire.Hosting.Azure;

Expand Down Expand Up @@ -41,47 +40,4 @@ void IResourceWithAzureFunctionsConfig.ApplyAzureFunctionsConfiguration(IDiction
target[$"{AzureStorageResource.TablesConnectionKeyPrefix}__{connectionName}__ServiceUri"] = Parent.TableEndpoint; // Updated for consistency
}
}

/// <summary>
/// Converts the current instance to a provisioning entity.
/// </summary>
/// <returns>A <see cref="global::Azure.Provisioning.Storage.TableService"/> instance.</returns>
internal global::Azure.Provisioning.Storage.TableService ToProvisioningEntity()
{
// Create the TableService with the correct name
global::Azure.Provisioning.Storage.TableService service = new(Infrastructure.NormalizeBicepIdentifier(Name));

// Set the name using internal infrastructure, similar to how it's done for other storage services
// TableService requires the name to be "default" like BlobService and QueueService
try
{
// Use reflection to access the internal _name property/field
var nameProperty = service.GetType().GetProperty("Name", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
if (nameProperty is not null && nameProperty.CanWrite)
{
nameProperty.SetValue(service, "default");
}
else
{
// Try to set via backing field if property is read-only
var fields = service.GetType().GetFields(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
foreach (var field in fields)
{
if (field.Name.EndsWith("name>k__BackingField", StringComparison.OrdinalIgnoreCase) ||
field.Name.Equals("_name", StringComparison.OrdinalIgnoreCase) ||
field.FieldType == typeof(string) && field.Name.Contains("name", StringComparison.OrdinalIgnoreCase))
{
field.SetValue(service, "default");
break;
}
}
}
}
catch (Exception)
{
// If reflection fails, the service will still work but may not have the name set
}

return service;
}
}