Skip to content

Commit 29f19ac

Browse files
committed
Update Azure Functions documentation
1 parent 8edcb49 commit 29f19ac

File tree

2 files changed

+48
-22
lines changed

2 files changed

+48
-22
lines changed
-214 KB
Loading

docs/setup-azure-functions.asciidoc

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
[[setup-azure-functions]]
33
=== Azure Functions
44

5-
The .NET APM Agent can trace function invocations in an https://learn.microsoft.com/en-us/azure/azure-functions[Azure Functions] app.
5+
The .NET APM Agent can trace HTTP triggered function invocations in an
6+
https://learn.microsoft.com/en-us/azure/azure-functions[Azure Functions] app.
67

78
[float]
89
==== Prerequisites
@@ -17,18 +18,14 @@ existing one, you can follow https://learn.microsoft.com/en-us/azure/azure-funct
1718
to create one.
1819

1920
You can also take a look at and use this
20-
https://github.com/elastic/apm-agent-dotnet/tree/main/sample/Elastic.AzureFunctionApp.Isolated[Azure Functions example app with Elastic APM already integrated].
21+
https://github.com/elastic/apm-agent-dotnet/tree/main/test/azure/applications/Elastic.AzureFunctionApp.Isolated[Azure Functions example app with Elastic APM already integrated].
2122

22-
[IMPORTANT]
23-
====
24-
Currently, only .NET Azure Functions in an
25-
https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide[isolated worker process]
26-
can be traced.
27-
====
23+
[float]
24+
==== Azure Functions isolated worker model
2825

2926
[float]
3027
[[azure-functions-setup]]
31-
==== Step 1: Add the NuGet package
28+
===== Step 1: Add the NuGet package
3229

3330
Add the `Elastic.Apm.Azure.Functions` NuGet package to your Azure Functions project:
3431

@@ -38,7 +35,7 @@ dotnet add package Elastic.Apm.Azure.Functions
3835
----
3936

4037
[float]
41-
==== Step 2: Add the tracing Middleware
38+
===== Step 2: Add the tracing Middleware
4239

4340
For the APM agent to trace Azure Functions invocations, the `Elastic.Apm.Azure.Functions.ApmMiddleware`
4441
must be used in your Azure Functions app.
@@ -49,30 +46,59 @@ using Elastic.Apm.Azure.Functions;
4946
using Microsoft.Extensions.Hosting;
5047
5148
var host = new HostBuilder()
52-
.ConfigureFunctionsWorkerDefaults(builder =>
53-
{
54-
builder.UseMiddleware<ApmMiddleware>();
55-
})
56-
.Build();
49+
.ConfigureFunctionsWebApplication(builder =>
50+
{
51+
builder.UseMiddleware<ApmMiddleware>();
52+
})
53+
.Build();
5754
5855
host.Run();
5956
----
6057

6158
[float]
62-
==== Step 3: Configure the APM agent
63-
64-
The APM agent can be configured with environment variables. Using environment variables
65-
allows you to use https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-use-azure-function-app-settings?tabs=portal#settings[application settings in the Azure Portal], enabling you to hide values and update settings
66-
without needing to re-deploy code.
59+
===== Step 3: Configure the APM agent
6760

68-
Open _Configuration > Application settings_ for your Function App in the Azure Portal
69-
and set:
61+
The APM agent can be configured with environment variables.
7062

7163
[source,yaml]
7264
----
7365
ELASTIC_APM_SERVER_URL: <your APM server URL from the prerequisites step>
7466
ELASTIC_APM_SECRET_TOKEN: <your APM secret token from the prerequisites step>
67+
ELASTIC_APM_ENVIRONMENT: "<your environment>"
68+
ELASTIC_APM_SERVICE_NAME: "<your service name>" (optional)
69+
----
70+
71+
*Local development*
72+
73+
While developing your Function locally, you can configure the agent by providing the environment variables
74+
via the `local.settings.json` file.
75+
76+
For example:
77+
78+
[source,json]
7579
----
80+
{
81+
"IsEncrypted": false,
82+
"Values": {
83+
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
84+
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
85+
"ELASTIC_APM_ENVIRONMENT": "Development",
86+
"ELASTIC_APM_SERVICE_NAME": "MyServiceName",
87+
"ELASTIC_APM_SERVER_URL": "https://my-serverless-project.apm.eu-west-1.aws.elastic.cloud:443",
88+
"ELASTIC_APM_API_KEY": "MySecureApiKeyFromApmServer=="
89+
}
90+
}
91+
----
92+
93+
*Azure*
94+
95+
Using environment variables allows you to use
96+
https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-use-azure-function-app-settings?tabs=portal#settings[application settings in the Azure Portal],
97+
enabling you to update settings
98+
without needing to re-deploy code.
99+
100+
Open _Settings > Environment variables_ for your Function App in the Azure Portal
101+
and configure the ELASTIC_APM_* variables as required.
76102

77103
For example:
78104

0 commit comments

Comments
 (0)