diff --git a/playground/AzureFunctionsEndToEnd/AzureFunctionsEndToEnd.AppHost/aspire-manifest.json b/playground/AzureFunctionsEndToEnd/AzureFunctionsEndToEnd.AppHost/aspire-manifest.json index 8aff98a8469..4e2fb37ecef 100644 --- a/playground/AzureFunctionsEndToEnd/AzureFunctionsEndToEnd.AppHost/aspire-manifest.json +++ b/playground/AzureFunctionsEndToEnd/AzureFunctionsEndToEnd.AppHost/aspire-manifest.json @@ -81,8 +81,10 @@ "ASPNETCORE_URLS": "http://\u002B:{funcapp.bindings.http.targetPort}", "AzureWebJobsStorage__blobServiceUri": "{funcstorage67c6c.outputs.blobEndpoint}", "AzureWebJobsStorage__queueServiceUri": "{funcstorage67c6c.outputs.queueEndpoint}", + "AzureWebJobsStorage__tableServiceUri": "{funcstorage67c6c.outputs.tableEndpoint}", "Aspire__Azure__Storage__Blobs__AzureWebJobsStorage__ServiceUri": "{funcstorage67c6c.outputs.blobEndpoint}", "Aspire__Azure__Storage__Queues__AzureWebJobsStorage__ServiceUri": "{funcstorage67c6c.outputs.queueEndpoint}", + "Aspire__Azure__Storage__Tables__AzureWebJobsStorage__ServiceUri": "{funcstorage67c6c.outputs.tableEndpoint}", "myhub__fullyQualifiedNamespace": "{eventhubs.outputs.eventHubsEndpoint}", "Aspire__Azure__Messaging__EventHubs__EventHubProducerClient__myhub__FullyQualifiedNamespace": "{eventhubs.outputs.eventHubsEndpoint}", "Aspire__Azure__Messaging__EventHubs__EventHubConsumerClient__myhub__FullyQualifiedNamespace": "{eventhubs.outputs.eventHubsEndpoint}", diff --git a/src/Aspire.Hosting.Azure.Storage/AzureStorageResource.cs b/src/Aspire.Hosting.Azure.Storage/AzureStorageResource.cs index 5e32875ae3f..69f484af511 100644 --- a/src/Aspire.Hosting.Azure.Storage/AzureStorageResource.cs +++ b/src/Aspire.Hosting.Azure.Storage/AzureStorageResource.cs @@ -19,6 +19,7 @@ public class AzureStorageResource(string name, Action /// Gets the "blobEndpoint" output reference from the bicep template for the Azure Storage resource. @@ -70,15 +71,18 @@ void IResourceWithAzureFunctionsConfig.ApplyAzureFunctionsConfiguration(IDiction // Injected to support Aspire client integration for Azure Storage. target[$"{BlobsConnectionKeyPrefix}__{connectionName}__ConnectionString"] = connectionString; target[$"{QueuesConnectionKeyPrefix}__{connectionName}__ConnectionString"] = connectionString; + target[$"{TablesConnectionKeyPrefix}__{connectionName}__ConnectionString"] = connectionString; } else { // Injected to support Azure Functions listener initialization. target[$"{connectionName}__blobServiceUri"] = BlobEndpoint; target[$"{connectionName}__queueServiceUri"] = QueueEndpoint; + target[$"{connectionName}__tableServiceUri"] = TableEndpoint; // Injected to support Aspire client integration for Azure Storage. target[$"{BlobsConnectionKeyPrefix}__{connectionName}__ServiceUri"] = BlobEndpoint; target[$"{QueuesConnectionKeyPrefix}__{connectionName}__ServiceUri"] = QueueEndpoint; + target[$"{TablesConnectionKeyPrefix}__{connectionName}__ServiceUri"] = TableEndpoint; } } } diff --git a/src/Aspire.Hosting.Azure.Storage/AzureTableStorageResource.cs b/src/Aspire.Hosting.Azure.Storage/AzureTableStorageResource.cs index 5836cde4286..f3269cd10dc 100644 --- a/src/Aspire.Hosting.Azure.Storage/AzureTableStorageResource.cs +++ b/src/Aspire.Hosting.Azure.Storage/AzureTableStorageResource.cs @@ -11,7 +11,7 @@ namespace Aspire.Hosting.Azure; /// The name of the resource. /// The that the resource is stored in. public class AzureTableStorageResource(string name, AzureStorageResource storage) - : Resource(name), IResourceWithConnectionString, IResourceWithParent + : Resource(name), IResourceWithConnectionString, IResourceWithParent, IResourceWithAzureFunctionsConfig { /// /// Gets the parent AzureStorageResource of this AzureTableStorageResource. @@ -23,4 +23,21 @@ public class AzureTableStorageResource(string name, AzureStorageResource storage /// public ReferenceExpression ConnectionStringExpression => Parent.GetTableConnectionString(); + + void IResourceWithAzureFunctionsConfig.ApplyAzureFunctionsConfiguration(IDictionary target, string connectionName) + { + if (Parent.IsEmulator) + { + var connectionString = Parent.GetEmulatorConnectionString(); + target[connectionName] = connectionString; + target[$"{AzureStorageResource.TablesConnectionKeyPrefix}__{connectionName}__ConnectionString"] = connectionString; + } + else + { + // Injected to support Azure Functions listener. + target[$"{connectionName}__tableServiceUri"] = Parent.TableEndpoint; + // Injected to support Aspire client integration for Azure Storage Tables. + target[$"{AzureStorageResource.TablesConnectionKeyPrefix}__{connectionName}__ServiceUri"] = Parent.TableEndpoint; // Updated for consistency + } + } }