question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Azure Extensions 1.6.0 and tracer 1.28.7 throws error at startup when settings environment variable

See original GitHub issue

We have .net5 web application and we are trying to set up Datadog version to envrionment variables at application startup. But its throwing exception

Code in startup:

// Add datadog version to environment variables
Environment.SetEnvironmentVariable("DD_VERSION", this.Configuration["DD_Version"], EnvironmentVariableTarget.Machine);

Application fails to startup:

image

In application event log there is error:

Application '/LM/W3SVC/1992865732/ROOT/name' with physical root 'D:\home\site\wwwroot\name\' hit unexpected managed exception, exception code = '0xe0434352'. First 30KB characters of captured stdout and stderr logs:
2021-09-17 09:48:07 GMT | DSD | ERROR | (pkg/metadata/gohai/gohai.go:63 in getGohaiInfo) | Failed to retrieve network metadata: fork/exec D:\Windows\system32\ipconfig.exe: Access is denied.
2021-09-17 09:48:07 GMT | DSD | WARN | (pkg/metadata/helper.go:94 in SetupMetadataCollection) | Metadata collection disabled, only do that if another agent/dogstatsd is running on this host
Unhandled exception. System.Security.SecurityException: Requested registry access is not allowed.
   at Internal.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
   at System.Environment.OpenEnvironmentKeyIfExists(Boolean fromMachine, Boolean writable)
   at System.Environment.SetEnvironmentVariableFromRegistry(String variable, String value, Boolean fromMachine)
   at System.Environment.SetEnvironmentVariable(String variable, String value, EnvironmentVariableTarget target)
   at Visma.Severa.Rest.Api.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env) in C:\git\Severa-Backend\Visma.Severa.Rest.API\Startup.cs:line 260
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass15_0.<UseStartup>b__1(IApplicationBuilder app)
   at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
   at Microsoft.Extensions.DependencyInjection.AutoRegisterMiddleware.<>c__DisplayClass4_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Server.IIS.Core.IISServerSetupFilter.<>c__DisplayClass2_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
   at Visma.Severa.Rest.Api.Program.Main(String[] args) in C:\git\Severa-Backend\Visma.Severa.Rest.API\Program.cs:line 14

Process Id: 13064.
File Version: 15.0.21196.9. Description: IIS ASP.NET Core Module V2 Request Handler. Commit: c663adee8e64ba5d379fa0edfb8201984a7df7d0

Also opened ticket here: https://github.com/DataDog/gohai/issues/81

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
andrewlockcommented, Sep 17, 2021

there is one issue at least that setting azure app service variable will reboot the service.

Presumably you essentially need to restart the service anyway if you’re deploying a new version (when you update the DD_VERSION value?)

Is there some guide how we could easily keep datadog version variable updated with continous deployment, if it cannot be set from the application itself?

If you can’t set environment variables (the preferred approach) could you use a datadog.json file as described in the docs?

1reaction
Havunencommented, Sep 17, 2021

You shouldn’t set environment variables required by the tracer from within the application, you need to set them within AAS itself

Okay. Do you have some examples how it could be done smoothly, there is one issue at least that setting azure app service variable will reboot the service.

Is there some guide how we could easily keep datadog version variable updated with continous deployment, if it cannot be set from the application itself?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Azure Windows VM extension failures
Trigger a new GoalState to the VM​​ You might notice that an extension hasn't been executed, or is failing to execute because of...
Read more >
Azure environment variable not working: "Factory method ...
So I keep getting the error that the URL must start with jdbc since its not using the env variable I set. The...
Read more >
What's New - Oracle Linux Yum Server
Oracle Linux with Oracle enterprise-class support is the best Linux operating system (OS) for your enterprise computing needs.
Read more >
Untitled
... crash-gcore-command.spec 0001-Makefile-set-DT_SONAME-to-trace.so.patch ... start-dconf-editor.sh dcraw-9.21-lcms2-error-reporting.patch ...
Read more >
Datadog.Trace 2.35.0
Configure the Datadog agent for APM as described in our documentation. ... Trace; // Create a settings object using the existing // environment...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found