Skip to content

Commit 5b63592

Browse files
committed
Tested with managed identity and worked around issues
- Blob triggers require queues - There's a conflict with the connection string section
1 parent 01922e7 commit 5b63592

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/Aspire.Hosting.Azure.Functions/AzureFunctionsProjectResourceExtensions.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,31 @@ public static class AzureFunctionsProjectResourceExtensions
4444
item.Annotations.Add(new EnvironmentCallbackAnnotation(static context =>
4545
{
4646
var functionsConfigMapping = new Dictionary<string, IResourceWithAzureFunctionsConfig>();
47+
var valuesToRemove = new List<string>();
4748

48-
foreach (var (_, val) in context.EnvironmentVariables)
49+
foreach (var (envName, val) in context.EnvironmentVariables)
4950
{
5051
var (name, config) = val switch
5152
{
5253
IResourceWithAzureFunctionsConfig c => (c.Name, c),
5354
ConnectionStringReference conn when conn.Resource is IResourceWithAzureFunctionsConfig c => (conn.ConnectionName ?? c.Name, c),
54-
_ => ("", null)
55+
_ => ("", null)
5556
};
5657

5758
if (config is not null)
5859
{
60+
valuesToRemove.Add(envName);
5961
functionsConfigMapping[name] = config;
6062
}
6163
}
6264

65+
// REVIEW: We need to remove the existing values before adding the new ones as there's a conflict with the connection strings.
66+
// we don't want to do this because it'll stop the aspire components from working in functions projects.
67+
foreach (var envName in valuesToRemove)
68+
{
69+
context.EnvironmentVariables.Remove(envName);
70+
}
71+
6372
foreach (var (name, config) in functionsConfigMapping)
6473
{
6574
config.ApplyAzureFunctionsConfiguration(context.EnvironmentVariables, name);

src/Aspire.Hosting.Azure.Storage/AzureBlobStorageResource.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ void IResourceWithAzureFunctionsConfig.ApplyAzureFunctionsConfiguration(IDiction
3434
}
3535
else
3636
{
37+
// Blob and Queue services are required to make blob triggers work.
3738
target[$"{connectionName}__blobServiceUri"] = Parent.BlobEndpoint;
39+
target[$"{connectionName}__queueServiceUri"] = Parent.QueueEndpoint;
3840
}
3941
}
4042
}

0 commit comments

Comments
 (0)