Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Azure Function Middleware does not assign Service.Environment #2246

Closed
mmodolo opened this issue Dec 20, 2023 · 2 comments
Closed

[BUG] Azure Function Middleware does not assign Service.Environment #2246

mmodolo opened this issue Dec 20, 2023 · 2 comments

Comments

@mmodolo
Copy link

mmodolo commented Dec 20, 2023

Currently it has no way to pass the service environment to apm. It could be easily added somewhere around the line below reading from "DOTNET_ENVIRONMENT" environment variable for example.

Does it have any appetite on adding it? Thanks!

service.Framework = new() { Name = "Azure Functions", Version = MetaData.FunctionsExtensionVersion };

@rfavreau
Copy link

rfavreau commented Apr 1, 2024

Hello @mmodolo,

To pass the environment to apm, add the environment variable "ELASTIC_APM_ENVIRONMENT". This variable can be set by the application settings in the Azure Portal.

You can also set this setting during the startup of the Azure Function:

new HostBuilder()
        .ConfigureFunctionsWorkerDefaults((context, builder) =>
        {
            Environment.SetEnvironmentVariable("ELASTIC_APM_ENVIRONMENT", context.HostingEnvironment.EnvironmentName);
            builder.UseMiddleware<ApmMiddleware>();
        })
        .Build()
        .Run();

With Azure Function, you must use AZURE_FUNCTIONS_ENVIRONMENT to set the environment and not DOTNET_ENVIRONMENT or ASPNETCORE_ENVIRONMENT.

@stevejgordon
Copy link
Contributor

I'm going to close this as answered. I've opened #2507 to include more details in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants