requests Table Azure Application Insights which operation belongs to which resource? - azure

I am using Workbook in Azure Monitor and trying to create a dashboard.
My All resources data goes into 1 Application Insights resource.
I have resources like storage, Azure Functions, VPN, Web App etc created in this azure account.
One subscription i am using.
I am trying to run query on requests table
I want to create dashboard for a particular WebApp say namely "ABC"
OR
I want to create 1 dashboard for resources WebApp, Azure Function, Storage say of name containing "XYZ"
requests table does not contain resourceid column. Which other Table i should use to get resource type and resource id, name

I had like the same question while logging into a common app insights resource.
From what I saw, there was no common property across all the different logging applications, I could have been using to determine the telemetry-source.
What I ended up with was to add a custom property to all telemetry using a telemetry initializer (which can be added during the startup e.g. within Azure Functions, as well as AppService). For the Storage, I don't know whether this can be also done.
// C# sample for the initializer
public class ComponentNameTelemetryInitializer : ITelemetryInitializer
{
private readonly string _ComponentName;
public ComponentNameTelemetryInitializer(string assemblyName)
{
_ComponentName = assemblyName;
}
public void Initialize(ITelemetry telemetry)
{
if (telemetry is ISupportProperties propTelemetry)
{
propTelemetry.Properties["ComponentName"] = _ComponentName;
}
}
}
That way I can just filter the log for the custom dimension ComponentName and I get all entries from a specific application.

Related

How do I query Azure resources for a list of ADF pipelines?

I'm documenting an Azure Data Factory with hundreds of pipelines. I would like to automate the process, perhaps with KQL, so I do not have to write down each item by hand. How do I query Azure resources for a list of ADF pipelines?
You can use the API given below to get Lists of Pipelines.
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/pipelines?api-version=2018-06-01
Below is the list of URI Parameters:
factoryName
resourceGroupName
subscriptionId
api-version
Sample Java Code
import com.azure.core.util.Context;
public final class Main {
public static void pipelinesListByFactory(com.azure.resourcemanager.datafactory.DataFactoryManager manager) {
manager.pipelines().listByFactory("exampleResourceGroup", "exampleFactoryName", Context.NONE);
}
}
Reference - Official Documentation

What's the difference between ListByResourceGroup() and GetByResourceGroup() in azure sdk?

When working with azure sdk I see ListByResourceGroup(), GetByResourceGroup() return the same value. What is the difference between them? If I want to get all information of vm in my subcriptions, what function should I use?
T GetByResourceGroup(string resourceGroupName, string name)
IEnumerable<T> ListByResourceGroup(string resourceGroupName)
So, if you use GetByResourceGroup, you need to provide 2 parameters. One is the resource group name, the other is the name for the VM. And you will only get the target VM.
However, ListByResourceGroup only reqiure for the resource group name. And you will be able to get all the VMs in the resource group.
If you want to get all the VMs, you can use the following as a sample:
static void Main(string[] args)
{
IAzure azure = Azure.Authenticate("path_to_auth_file").WithDefaultSubscription();
var vms = azure.VirtualMachines.List();
foreach( var vm in vms)
{
Console.WriteLine(vm.Name);
}
}
I just simply output the VM's name, you can do what you want in the foreach.
Just to add to existing answer, in Azure SDK LIST always gets all resources from subscription or resource group (usually all resources of the same type), whereas GET is used to retrieve a specific resource (if it exists), hence you need to specify the resourceGroup AND the resource name.
I'd be inclined to think this is universal. If you think about it for a second those verbs in english are meant exactly for that.

Custom properties in azure function application insights

I am monitoring a lot of applications in Azure Application Insights.
In all of them I add some custom properties to events, traces etc so I can filter/group in the portal.
Is it possible to add the same custom properties to the built in application insight integration with Azure Functions?
Have read the documentation but can't find anything about it.
Edit:
I maintain a large number of applications hosted in various environments. About 15 of these are Azure Functions.
From all my applications I send telemetry to the same application insights instance via a log handler. To filter/group the information I add "CustomerName" and "CustomerInstance" properties to all events automatically via my log handler.
When I get the standard events from an Azure Function it is difficult to present information in a useful way and correlate it with other events.
With some clever naming of the function apps I can parse the request url in analytics but not in the portal.
You can add these custom properties explicitly using telemetry.Context.Properties.Add() method.
I did a demo with function v2 as below:
1.Create a function v2 in visual studio
2.Then in the visual studio, add Microsoft.ApplicationInsights 2.8.1(latest version) via nuget package manager
3.In your Function.cs, write the following code:
using Microsoft.ApplicationInsights;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
using System;
namespace FunctionApp17
{
public static class Function1
{
private static string key = System.Environment.GetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY",EnvironmentVariableTarget.Process);
private static TelemetryClient telemetry = new TelemetryClient() { InstrumentationKey= key };
[FunctionName("Function1")]
public static void Run([TimerTrigger("*/10 * * * * *")]TimerInfo myTimer, ILogger log)
{
if (!telemetry.Context.Properties.ContainsKey("Function_appName"))
{
telemetry.Context.Properties.Add("Function_appName", "myfuncapp111");
}
else
{
telemetry.Context.Properties["Function_appName"] = "myfuncapp111";
}
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
telemetry.TrackEvent("event111");
telemetry.TrackTrace("trace111");
}
}
}
4.Publish to azure, and in your function app -> Application settings, add the instrumentation key:
5.After the function app is running, nav to your application insights -> search, you can add your filters which defined in your code.
Then you can see the filtered message:

How to Get Service Fabric Project Settings.xml Values

I have 5 service fabric stateless services. I have to get these service fabric settings.xml values in a class library based on Section Name of each file. I am going to create a common class which will take SectionName as a parameter and have to get all configuration values.
you can use this as a starting point:
internal sealed class YourService: StatelessService
{
public YourService(StatelessServiceContext context)
: base(context)
{
var configurationPackage = Context.CodePackageActivationContext.GetConfigurationPackageObject("Config");
var sectionParams = configurationPackage.Settings.Sections["sectionname"].Parameters;
// You can now iterate through these parameters (e.g. get count and access by index)
//sectionParams.Count;
//sectionParams[0].Name;
//sectionParams[0].Value;
I am not sure if there is a way for a library to find the ServiceContext of other Services. Please also be aware that not all services might be deployed to the same nodes. This might affect configuration availability.
You might need to create a central service or actor that collects the configuration values of all other services.

What should I use for Azure Mobile Service - TableController or API Controller?

I am working on a new application with Azure mobile app service and developing backend with .NET and choose Azure Tables as backend store. In all examples I found so far, are using TableController as base of any API controller and models must be derived from EntityData. This entity data does not contain Partition and Row Key, but we require these keys for Azure Table storage.
Other way to access Table storage is via Microsoft.WindowsAzure.Storage and models will be inherited from TableEntity.
Kindly suggest what is the appropriate way to develop backend service with azure mobile app.
We can use Azure table Storage as a backing data provider for your TableControllers through the new Microsoft.Azure.Mobile.Server.Storage package. See detailed information from Azure Mobile Apps September 2015 Update. Detailed steps are shown in this article. You need pay more attention to the following:
1) Different with Azure SQL Database, Azure Table Storage is a non-relational store.
2) The data type to derive from StorageData instead of EntityData, Id in StorageData must format as "<partitionID>,<rowValue>"
public class TodoItem : StorageData
{
public TodoItem(): base("partition", System.Guid.NewGuid().ToString())
{
}
public string Text { get; set; }
public bool Complete { get; set; }
}
3) Unlike a SQL Database, table storage as backend data doesn't return IQueryable.

Resources