Application Insights Dependency types - c#

I just got started with Application Insights and wanted to highlight dependencies between different operations. Currently I am using this code:
using (var x = telemetry.StartOperation<DependencyTelemetry>("my TEst")) {
x.Telemetry.Type = "SQL";
}
setting the Telemetry.Type to "SQL" makes the dependency appear as SQL DB which is fine and exactly what I want.
But I could not find any information about what other "Types" are supported here and what their exact Type would be?
e.g Blob Stores? Web APIs?
thanks in advance,
-gerhard

There's no limitation that I'm aware of.
Some dependencies are reported automatically by the SDK (such as SQL, Ajax), so these will get a pretty name in Application Map, but you can put there whatever makes sense in your application's BL.
The list of out-of-the-box dependency types Application Insights collect right now can be found here, although the documentation does not contain the dependency type string that you're interested in.
Non definitive list from my own experience:
SQL
HTTP
Azure queue
Azure table
Azure blob
Azure DocumentDb
Ajax
Redis
Azure Service Bus
MySQL
Azure IoT Hub
Azure Event Hubs

The are dependency types getting custom icons in Application Map:
- SQL
- Custom HTTP types, based on the following criteria:
1. Azure blob: when host name ends with blob.core.windows.net
2. Azure table: when host name ends with table.core.windows.net
3. Azure queue: when host name ends with queue.core.windows.net
4. Web Service: when host name ends with .asmx or contains .asmx/
5. WCF Service: when host name ends with .svc or contains .svc/
- All other HTTP or AJAX
Going forward the list will be extended with other dependency types that will get custom item in ApplicationMap.

Related

How to get access to kubernetes cluster from containerized application running inside node hosted on same cluster?

I am using kubernetes client library for c#. This method should ideally provide me with k8s config of the cluster it is running inside
var k8sConfig = KubernetesClientConfiguration.InClusterConfig();
Inside docker container when this run it gives
k8s.Autorest.HttpOperationException: Operation returned an invalid status code 'Forbidden'
Expected behaviour is to get cluster inside application so as to use its configmaps and secrets.
Is there any other method to do this or are there any pre-requisites to use this method?
Please note: I am using token login from web UI for cluster dashboard
If you really want to use the configmap values you can mount it to your pod as shown here.(same for secret)
https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/
Then these would be available to your pod as env variables.
https://github.com/kubernetes-client/csharp/discussions/891
I asked over github too, which was answered by moderators. And this is what we need to do here. Keep "clusterrolbinding" concept in mind.

Service identification in a cloud docker system

I got a system in Azure cloud which has a docker and each pod in the docker is a different service implemented with c# .Net Core. One of these services is a gRPC service which is a file service and every other service who want to access a file are using an SDK which access that service directly and it allows to access the requested file. The SDK is a nuget which every service adds to its references.
A flow example: Service A => invoke a method from SDK => Calls file service which access a file => return a response to the SDK => return a response to service A.
My desired behavior: I want to identify in the SDK the service itself which invokes the SDK's method. I can't use a simple input like just passing a string parameter because it's important to know the true service and I can't risk someone sending wrong information.
this is a pseudo code of what I need:
//this is an SDK method
public string GetSomeValueFromFile(string fileName)
{
string invokingService = GetCurrentService();
...
...
}
And the question is how to implement this GetCurrentService() method since I have no idea where to start

C# application testing connection (ping, download, upload) to the web service

I have created a simple web service that receives data and saves it in a database. I need to create an application (or service) that will test the connection to this web service (from time to time, e.g. every 1 minute).
I need information like download, upload, ping and save them in the database. I tried NetworkInterface, but the web service is not an interface, so it cannot find it. I don't know how to test this connection and get information about it, so I need help.
Solution 1: fully custom
High level description:
Create a new endpoint , something like api/healthcheck
Either
a. do a mock action (save/delete false data
b. Maintain a table or any other persistence (even a singleton would do) with statistics from recent calls
Add them to a class response object and return it to the caller.
Solution 2: Use custom telemetry
High level description:
Pick a service like application insight: https://learn.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview
Configure the telemetry if the out of the box configuration isn't enough.
Use the rest api to get your information

Azure Notification Hubs Register Device Error 404

This is the first time I'm using Azure Notification Hubs and I'm having some trouble getting it working properly with my application.
The part I'm stuck on (at the moment) is registering my device with the notification hub. I'm using the backend method to do the registration ... that is, I'm creating an Installation object and using the CreateOrUpdateInstallationAsync method to register the device via my Web API. I'm only testing it at this stage so I'm hitting my API endpoint with dummy data via Postman.
When I step through my code, I'm getting the following error when I execute CreateOrUpdateInstallationAsync ...
The remote server returned an error: (404) Not Found. Entity does not
exist.TrackingId:203cba37-007d-4dcb-ae25-ced33fa012aa_G1,TimeStamp:2/4/2018
10:24:02 PM
I've tested that I am connecting to the Notification Hub correctly by calling GetAllRegistrationsAsync. This returns an empty list (expected) and no error ... so I have my endpoints set up correctly. I'm wondering if there is a problem with my dummy data? For the installation Id, I've just created a random GUID (Guid.NewGuid). The Device ID and Push Notification Handle are random numbers and letters. And I'm testing this for the Android platform (NotificationPlatform.Gcm).
Has anyone seen this error before and know what it means? Am I able to just use random data for testing purposes (I'm only interested in registering devices at this stage) or do I need legitimate data (real device id's, etc)?
Thanks in advance.
The CreateOrUpdateInstallationAsync method would essentially invoke the REST API Create or Overwrite an Installation. When you register with a notification hub from your custom backend using the Installation, the core code would look like as follows:
NotificationHubClient hubclient = NotificationHubClient.CreateClientFromConnectionString(listenConnString, hubName);
await hubclient.CreateOrUpdateInstallationAsync(installation);
Note: You could install the Microsoft.Azure.NotificationHubs package for back end operations.
For a simpler way, I just created a console application and test this operation as follows:
Note: I just created a new Azure Notification Hub and did not set any notification settings. And I set a GUID as the InstallationId and a random string as the PushChannel, the rest operation could work as expected.
And I could retrieve the previous added registration as follows:
Has anyone seen this error before and know what it means? Am I able to just use random data for testing purposes (I'm only interested in registering devices at this stage) or do I need legitimate data (real device id's, etc)?
The operation could work on my side, I would recommend you debug your application and leverage fiddler to capture the network traces to narrow this issue. Moreover, you could follow Registration management for more details about registering devices with azure notification hubs.
Ok, it turns out that I had the wrong value for Hub Name when instantiating the NotificationHub object using NotificationHubClient.CreateClientFromConnectionString. I was using the namespace, instead of the hub name (visible on the Overview tab in the Azure Portal).

Custom SharePoint 2010 WCF Service - How to set MaxReceivedMessageSize parameter

I have developped a custom WCF Web Service within a SharePoint 2010 Visual Studio empty project.
My web service is working well. The problem is related to the size of the request I can send to this web service. I have realized that is something around 300Kb. If I go bigger than that, the service/client is sending me an exception.
I've looked around on the web and see that the MaxReceivedMessageSize setting may be my solution. I've tried using a FeatureActivated method to set this information using this kind of request:
// increase maximum size of requests to this web service: http://msdn.microsoft.com/en-us/library/ff599489.aspx
SPWebService contentService = SPWebService.ContentService;
contentService.ClientRequestServiceSettings.MaxReceivedMessageSize = -1;
SPWcfServiceSettings csomWcfSettings = new SPWcfServiceSettings();
csomWcfSettings.MaxReceivedMessageSize = 10485760; // 10MB
contentService.WcfServiceSettings["PT-SP-P2S-DocumentCreator.svc"] = csomWcfSettings;
contentService.Update(); // access denied thrown here!
With that code, I have an Access denied (I'm actually the Site Collection Administrator).
I also know that this parameter may be set in the app.config of web service host but, in SharePoint, where to I need to change this parameter.
I think you should make this change in the web.config file of the Web Application in which the feature is activated. SharePoint provides APIs to make web.config changes. In fact, using APIs to make changes to your web.config is preferred option because SharePoint uses Timer Job and makes same updates to all Web Front End servers in your environment. There are 2 ways to make changes to web.config as described here:
http://msdn.microsoft.com/en-us/library/ms460914.aspx
In your case, since you want to make the change only when your feature is activated, you would take the API approach as documented here: http://msdn.microsoft.com/en-us/library/bb861909.aspx

Categories