/// <summary> /// This will check the TelemetryChannel and attempt to set the endpoint. /// This only supports our first party providers <see cref="InMemoryChannel"/> and ServerTelemetryChannel. /// </summary> /// <param name="channel">TelemetryChannel to set.</param> /// <param name="endpoint">Endpoint value to set.</param> /// /// <param name="force">When the ConnectionString is set, Channel Endpoint should be forced to update. If the Channel has been set separately, we will only set endpoint if it is null.</param> private static void SetTelemetryChannelEndpoint(ITelemetryChannel channel, string endpoint, bool force = false) { if (channel != null) { if (channel is InMemoryChannel || channel.GetType().FullName == "Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel") { if (force || channel.EndpointAddress == null) { channel.EndpointAddress = endpoint; } } } }
public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request." + " "); try { throw new Exception("Exception"); } catch (Exception exc) { var exceptionTelemetry = new ExceptionTelemetry(exc); var itemProperty = telemetryClient.Context.GetType().GetMembers(BindingFlags.NonPublic).ToList(); log.LogInformation(channel.GetType().ToString()); foreach (var item in itemProperty) { log.LogInformation(item.Name); } telemetryClient.TrackException(exceptionTelemetry); } string name = req.Query["name"]; string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); dynamic data = JsonConvert.DeserializeObject(requestBody); name = name ?? data?.name; string responseMessage = string.IsNullOrEmpty(name) ? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response." : $"Hello, {name}. This HTTP triggered function executed successfully."; return(new OkObjectResult(responseMessage)); }