Skip to content

Commit 76157a5

Browse files
Document both AddAzureFunctionsProject overloads in hosting integration (#151)
* Initial plan * Update Azure Functions hosting integration docs with generic and path-based overloads Co-authored-by: captainsafia <1857993+captainsafia@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: captainsafia <1857993+captainsafia@users.noreply.github.com>
1 parent 91f9dcd commit 76157a5

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

src/frontend/src/content/docs/integrations/cloud/azure/azure-functions.mdx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ The Aspire Azure Functions hosting integration models Azure Functions projects a
109109

110110
### Add Azure Functions resource
111111

112-
In your AppHost project, call `AddAzureFunctionsProject` on the `builder` instance to add an Azure Functions resource:
112+
In your AppHost project, call `AddAzureFunctionsProject` on the `builder` instance to add an Azure Functions resource. There are two ways to add an Azure Functions project, depending on whether the Functions project is referenced in your AppHost project.
113+
114+
#### Add a referenced Functions project
115+
116+
If the Azure Functions project is referenced in your AppHost project, use the generic overload of `AddAzureFunctionsProject`:
113117

114118
```csharp title="C# — AppHost.cs"
115119
var builder = DistributedApplication.CreateBuilder(args);
@@ -124,7 +128,28 @@ builder.AddProject<Projects.ExampleProject>()
124128
// After adding all resources, run the app...
125129
```
126130

127-
When Aspire adds an Azure Functions project resource the AppHost, as shown in the preceding example, the `functions` resource can be referenced by other project resources. The `WithReference` method configures a connection in the `ExampleProject` named `"functions"`. If the Azure Resource was deployed and it exposed an HTTP trigger, its endpoint would be external due to the call to `WithExternalHttpEndpoints`.
131+
#### Add a Functions project by file path
132+
133+
If the Azure Functions project is not referenced in your AppHost project, you can add it by specifying the path to the project file:
134+
135+
```csharp title="C# — AppHost.cs"
136+
var builder = DistributedApplication.CreateBuilder(args);
137+
138+
var functions = builder.AddAzureFunctionsProject("functions", "../MyFunctions/MyFunctions.csproj")
139+
.WithExternalHttpEndpoints();
140+
141+
builder.AddProject<Projects.ExampleProject>()
142+
.WithReference(functions)
143+
.WaitFor(functions);
144+
145+
// After adding all resources, run the app...
146+
```
147+
148+
In the preceding example, the path to the Functions project file is relative to the AppHost project directory. If the path is not absolute, it will be resolved relative to the AppHost directory.
149+
150+
---
151+
152+
When Aspire adds an Azure Functions project resource to the AppHost, as shown in the preceding examples, the `functions` resource can be referenced by other project resources. The `WithReference` method configures a connection in the `ExampleProject` named `"functions"`. If the Azure Resource was deployed and it exposed an HTTP trigger, its endpoint would be external due to the call to `WithExternalHttpEndpoints`.
128153

129154
### Add Azure Functions resource with host storage
130155

0 commit comments

Comments
 (0)