@@ -12,7 +12,8 @@ namespace Aspire.Hosting.Azure;
1212/// <param name="configureConstruct">Callback to populate the construct with Azure resources.</param>
1313public class AzureStorageResource ( string name , Action < ResourceModuleConstruct > configureConstruct ) :
1414 AzureConstructResource ( name , configureConstruct ) ,
15- IResourceWithEndpoints
15+ IResourceWithEndpoints ,
16+ IResourceWithAzureFunctionsConfig
1617{
1718 private EndpointReference EmulatorBlobEndpoint => new ( this , "blob" ) ;
1819 private EndpointReference EmulatorQueueEndpoint => new ( this , "queue" ) ;
@@ -42,7 +43,7 @@ public class AzureStorageResource(string name, Action<ResourceModuleConstruct> c
4243 /// Gets the connection string for the Azure Storage emulator.
4344 /// </summary>
4445 /// <returns></returns>
45- public ReferenceExpression GetEmulatorConnectionString ( ) => IsEmulator
46+ internal ReferenceExpression GetEmulatorConnectionString ( ) => IsEmulator
4647 ? ReferenceExpression . Create ( $ "{ AzureStorageEmulatorConnectionString . Create ( blobPort : EmulatorBlobEndpoint . Port , queuePort : EmulatorQueueEndpoint . Port , tablePort : EmulatorTableEndpoint . Port ) } ")
4748 : throw new InvalidOperationException ( "The Azure Storage resource is not running in the local emulator." ) ;
4849
@@ -57,4 +58,17 @@ internal ReferenceExpression GetQueueConnectionString() => IsEmulator
5758 internal ReferenceExpression GetBlobConnectionString ( ) => IsEmulator
5859 ? ReferenceExpression . Create ( $ "{ AzureStorageEmulatorConnectionString . Create ( blobPort : EmulatorBlobEndpoint . Port ) } ")
5960 : ReferenceExpression . Create ( $ "{ BlobEndpoint } ") ;
61+
62+ void IResourceWithAzureFunctionsConfig . ApplyAzureFunctionsConfiguration ( IDictionary < string , object > target , string connectionName )
63+ {
64+ if ( IsEmulator )
65+ {
66+ target [ connectionName ] = GetEmulatorConnectionString ( ) ;
67+ }
68+ else
69+ {
70+ target [ $ "{ connectionName } __blobServiceUri"] = BlobEndpoint ;
71+ target [ $ "{ connectionName } __queueServiceUri"] = QueueEndpoint ;
72+ }
73+ }
6074}
0 commit comments