How to ingest new relic APM service in azure function in process model?

Vijay Pratap Singh 0 Reputation points
2024-11-19T06:40:18.7066667+00:00

I have azure function in process model. I want to use new relic APM service.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,194 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Khadeer Ali 1,215 Reputation points Microsoft Vendor
    2024-11-19T08:39:18.3833333+00:00

    Hi Vijay Pratap Singh,
    Welcome to the Microsoft Q&A Platform! Thank you for reaching out regarding your query on ingesting new relic APM service in azure function in process model.

    To ingest New Relic APM service in an Azure Function in process model, you can follow these steps:

    1. First, you need to create a New Relic account and obtain an API key.
    2. Next, you need to install the New Relic .NET agent in your Azure Function. You can do this by adding the following NuGet package to your project: NewRelic.Agent.Api.
    3. Once you have installed the New Relic .NET agent, you need to configure it to work with your Azure Function. You can do this by adding the following code to your Startup.cs file:
    public class Startup : FunctionsStartup
    {
        public override void Configure(IFunctionsHostBuilder builder)
        {
            NewRelic.Api.Agent.NewRelic.SetApplicationName("Your Application Name");
            NewRelic.Api.Agent.NewRelic.SetLicenseKey("Your License Key");
        }
    }
    

    Replace "Your Application Name" and "Your License Key" with the appropriate values for your New Relic account.

    1. Finally, you need to instrument your Azure Function code to capture data for New Relic. You can do this by adding the following code to your function:
    using NewRelic.Agent.Api;
    public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
    {
        using (NewRelic.Api.Agent.NewRelic.StartTransaction("Transaction Name"))
        {
            // Your function code here
        }
    }
    

    Replace "Transaction Name" with a descriptive name for your transaction.

    With these steps, you should be able to ingest New Relic APM service in your Azure Function in process model.
    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.