I have been following this article for adding cloud_RoleName to my web-app (https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/azure-monitor/app/app-map.md#net), I just tried this with a very simple ASP.net web-app. I created a class library for telemetry and referenced it with my Web-App and made sure Instrumentation Key is used. Now when I initialize the custom TELEMETRY class programmatically i.e. (Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.TelemetryInitializers.Add(new ExtendedIDTelemetryInitializer())) .. It works very well and no issues at all. Telemetry gets sent to my Azure App Insights Resource with my custom CLOUD_ROLENAME but samething if I try to add it declaratively i.e. adding the INITIALIZE code to ApplicationInsights.config file, it DOESNT WORK :( nothing is reported with my CUSTOM cloud_RoleName to Azure App insights, any help with this? I want to go the DECLARATIVE route instead of programmatic as I need to send this code to a third party product and they cant make changes to the STARTUP event to add it. Not sure why DECLRATIVE is Not working any help? my ApplicationInsights.config file looks like this . Any help?<Add Type="KSTelemetry.Telemetry.MyTelemetryInitializer,KSTelemetry"/>
if you were using asp.net core application, then declarative config via ApplicationInsights.config is not supported. Adding TelemetryInitializers must be done by adding it to the DI container as shown in below link
https://learn.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core#adding-telemetryinitializers
Related
I have a task to add a new custom culture (en-cn). There isn't a problem from coding side and I used CultureAndRegionInfoBuilder for this but I can't create this culture on the Azure AppService, Register method throws an exception and requires extra-permissions.
Have you met something similar?
According to your description, I think you want to make your app globalization and localization via CultureAndRegionInfoBuilder Class in .NET Framework. However, as the figure below, it requires sysglobl.dll which is a system call that can not be used in Azure App Service (WebApp).
The reason is Win32k.sys (User32/GDI32) Restrictions said in Azure Web App sandbox, as below.
To fix it, you can consider to use other solution to support internationalization (i18n) in your ASP.NET website. Please refer to the blog Understanding Globalization and Localization in .NET to realize it.
I would like to customize the application insight configuration for an azure function by creating telemetry initializer. My current scope of work is to identify a way to correlate messages sent from an HTTP triggered azure function to another HTTP triggered azure function and for that was trying to follow the help at dzimchuk.net. However I do not see an ApplicationInsights.config in my azure function project. I found the GitHub project that includes an app insight configuration file, and hence not sure how that project was created. Any help would be much appreciated.
Functions v2 has the capability to do this, but it isn't directly supported.
Warning
Do not add AddApplicationInsightsTelemetry() to the services collection as it registers services that conflict with services provided by the environment.
Do not register your own TelemetryConfiguration or TelemetryClient if you are using the built-in Application Insights functionality.
Closest I've gotten is this comment on a github issue which tries to preserve the existing functionality.
There are a few others I've seen around but many of them break integrations with Azure Portal such as the Quick Pulse (Live metrics feed) and performance metrics.
I have an Azure Website. For the sake of this question, the production version of the website runs on example.com, and a test version of the website runs on sandbox.example.com.
The only difference between the two is that they have different configuration.
At present, they are running under different websites, and I deploy the same website to each azure website via git.
I'd like to separate out the Application Insights data. Is there a technique or process that anyone uses - apart from editing the ApplicationInsights.config file in the sandbox environment post deploy?
Or would using a deployment slot handle this in some way?
There was a new blog post about exactly this today: Application Insights Support for Multiple Environments, Stamps and App Versions.
The destination of the telemetry is determined by the instrumentation
key (iKey), which is sent along with every telemetry message. In the
Application Insights portal, similar events and metrics with the same
iKey are aggregated to give you charts of average durations, event
counts, the sum of users, and so on. The iKey appears in two places in
your project. One is in ApplicationInsights.config:
<InstrumentationKey>94843456-2345-3456-4567-324562759284</InstrumentationKey>
If your application has web pages, the iKey also appears in a script
in the head of every web page. Usually, it’s only coded once in a
master page such as Views\Shared\_Layout.cshtml.
To direct telemetry to different application resources, we can create
several resources with different iKeys. Then we only have to change
the iKeys in the application at each transition in its lifecycle –
along with other configuration data such as connection strings,
certificates, and subscriptions.
The article then goes on how to do this in code, confg, etc:
1) Add iKey as a property in Web.config:
2) Instead of using the iKey from ApplicationInsights.config, we’ll
set it in the code. In global.asax.cs.
To avoid confusion, remove the <InstrumentationKey> node from
ApplicationInsights.config.
3) Configure the web pages to pick up instrumentationKey: "#Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey". This is
the script usually found in View\Shared\_Layout.cshtml.
4) Don’t forget to update your Web.config with appropriate iKey
configuration during the deployment process. You might devise a way of
setting it appropriately as part of your build, but I’ll leave that to
you.
Found this semi-related question: How to support multiple Azure subscriptions for a single application with application insights this is for using by cloud services, and it works!
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey = ConfigurationManager.AppSettings["appInsightsKey"];
I have done this in my unity registertypes method, it works there.
In the Azure portal for websites, on the config tab there is a section called App Settings. You can put your different configuration settings here. When publishing, azure will inject those settings into web.config.
Then just use WebConfigurationManager.AppSettings as you would normally and it will pull the injected values.
I am trying to configure some key/value pairs for my Azure web application using app settings section on Windows Azure preview portal.
According to the documentation, Azure should inject configured key/value pairs into the .Net configuration AppSettings at runtime.
Do anybody know, how to read this values inside the RegisterServices method of the NinjectWebCommon class? I tried a common way
ConfigurationManager.AppSettings["MyWebApp.DbConnectionString"];
but it returns empty or null values. Reading app settings later in my web application works fine.
I do not know how exactly this works but the RegisterServices method is probably called earlier than Azure injects app settings into configuration. Fortunately, there is an alternative way to install Ninject for MVC3 that works (see Using Binaries from Github).
I'm using Facebook C# SDK for an ASP.NET MVC Facebook Canvas application that I'm hosting in Windows Azure.
I currently have the Facebook C# SDK specific configuration settings (appSecret, appId, etc.) in web.config, but I would like to move them to the service configuration file instead so that I can alter the settings when moving from Staging to Production in Azure.
(How) can this be done? Right now I'm using the CanvasAuthorize attribute that automatically reads from web.config.
[CanvasAuthorize(Permissions = FacebookPermissions.ReadStreamPermission)]
public ActionResult Login()
{
return RedirectToAction("Authenticate"); // Logged in, proceed with authentication
}
By default, Facebook C# SDK looks up at the configuration sections in web.config.
You will need to override the default Facebook application using code similar to this.
FacebookApplication.SetApplication(new DefaultFacebookApplication { AppId = "..", AppSecret = ".." });
The best place to set the application is at Application_Start.
You can checkout the sample at https://gist.github.com/820881
This means you are not tied to web.config. You can use database, azure service configuration or anything depending on your logic from where the settings can be retrieved.
I'm not sure about the reasoning of putting application specific configuration information in the Azure ServiceConfiguration.csfg file. Furthermore, I would say that this will be a problem rather than helpful to switch VIP's in the Azure control panel.
They way I do it is to have multiple web deployment configurations in my (ASP.NET MVC canvas page) Visual Studio project. One for Staging and one for Production.
I use the web.config transformation functionality in the Web Deployment to have different web.config settings for Staging/Production.
It works very well and smoothly, just right-click on the project, select Deploy and choose if you want to deploy to staging or production. You can also handle a specific testing AppID for Staging this way.
EDIT: I haven't looked in the source code for the Facebook C# SDK, but I would guess that the web.config read methods are, in fact, hard coded to use the web.config. That would also be a reason to keep it there.