Integrate Application Insight with Service Fabric Stateless WebAPI - azure-service-fabric

How can we Integrate Application Insight with Service Fabric Stateless WebAPI?
Do we need to configure separate Listener for it?

I have made a sample application for service fabric for full .NET Framework with Owin hosting. The sample include Dependency Injection and Application insight
https://github.com/duongthaiha/ServiceFarbricSampleApplication

Add Nuget package: Microsoft.ApplicationInsights.ServiceFabric.Native
Configure it:
var host = new WebHostBuilder()
// Adding Service Fabric Telemetry Initializer
.ConfigureServices(services => services.AddSingleton<ITelemetryInitializer>((serviceProvider) => new FabricTelemetryInitializer()))
// Configuring Applciation Insights
.UseApplicationInsights()
.Build();
host.Run();
Here's some more documentation for this.

Related

Service Fabric .NET Framework services and ApplicationInsights.config endpoints for Azure gov

I have a service fabric application that hosts api’s with app insights enabled. The api services are .Net framework 4.8 webapi projects and they are native fabric stateless and stateful services. I don’t use the app insights service fabric specific packages, but do have the standard app insights for webapi packages. I have always been in Azure commercial and logs have worked just fine there.
Now that we are in azure gov, the only way to point a .Net Framework app to the gov app insights endpoints is by modifying the ApplicationInsights.config file.
So I’ve modified the file as per msdn, verified it is deployed with the fabric deploy package and its there next to the rest of the dlls on the vms. Yet my services still won’t log to azure gov app insight instances. Nothing is coming through. We set the instrumentation key programmatically, not in applicationinsights.config, could that be an issue? I noticed some of the msdn examples showed instrumentationkey being included in the config file, but would think that is optional.
Had anyone had experience pointing .net 4.8 fabric services to gov app insights?
When using a government cloud, you need to use a connection string instead of an instrumentation key.
Important
Sovereign clouds, such as Azure Government, require the use of the
Application Insights connection string
(APPLICATIONINSIGHTS_CONNECTION_STRING) instead of the instrumentation
key. To learn more, see the APPLICATIONINSIGHTS_CONNECTION_STRING
reference.
More info here and here.
This ended up being an issue with my gov configuration file. The MSDN document wasn't very clear on where the new config sections go. It made it look like they are all nested under the top level node of the config file. Turns out the TelementyChannel override has to go inside the default TelemenySinks node. I contacted microsoft on github about clarifying this in their docs.
Link to the unclear documentation
https://learn.microsoft.com/en-us/azure/azure-monitor/app/custom-endpoints?tabs=net
Link to github issue to get it fixed
https://github.com/MicrosoftDocs/azure-docs/issues/80066

Azure Service Fabric Template - Which one to choose

I am creating a service fabric application. I saw in the Microsoft documentation that, based on how we store the data we can choose between stateless and sate full template.
But under .net core 2.0 itself, it has "stateless" and "stateless Asp.net core". What is the difference between these two.
My requirement is to migrate a existing web api which is stateless. As per the microservice architecture, I have selected a Stateless Asp.Net core template as the front facing api and I am not able to decide the template for Web api.
Thanks in advance
it has "stateless" and "stateless Asp.net core". What is the
difference between these two.
Stateless Service is a simple template to build a basic reliable services.
Stateless ASP.NET Core is a more complete template to build a reliable service that uses ASP.NET Core. It is a great starting point for any website or web API.
My requirement is to migrate a existing web api which is stateless. As
per the microservice architecture, I have selected a Stateless Asp.Net
core template as the front facing api and I am not able to decide the
template for Web api.
Do chose Stateless ASP.NET Core because you will host a web API.

Customizing the Hyperledger Composer Rest Server

I have a test Hyperledger Fabric running in the IBM Cloud, with the IBM Blockchain Application Service. I also have a kubernetes cluster running the Hyperledger Composer REST Server. Everything works great, but how do I extend the REST api with some custom api's?
The documentation mentions being able to use the swagger definition (yaml file) with the IBM API Connect or Strongloop product...but how do I do that, as I don't see any way to export the swagger definition?
I don't have a tutorial, but as I see it you would have to do three tasks minimally:
write your REST APIs (to do what you want to do) - perhaps these
resources on REST APIs will help ? -> Loopback ->
https://developer.ibm.com/code/patterns/create-rest-apis-using-loopback/
and in architectural in general
->https://www.ibm.com/developerworks/library/ws-restful/ and
build the routes for your custom APIs
customise your swagger
definitions to document your REST APIs - this may help you ->
https://www.ibm.com/developerworks/library/wa-use-swagger-to-document-and-define-restful-apis/index.html
and Swagger itself -> http://swagger.io/
If you write custom api and call it as 3rd party api which is mentioned in IBM already it will help you to response but it has very limted scope. I belive you should use swagger to understand its end point are properly configured

Hybris Create Web Service with Intellij

I'm really new in Hybris. I have Hybris commerce 6.4 and im working with Intellij.
Can anybody tell me how to create a web service rest?
I need the basic steps or a hello word example of a web service exposed from hybris.
Thank you so much.
Hybris is based on Spring, you can create rest web services just as you would do on a normal Spring MVC application.
You can also generate a web service extension using ant extgen, this way you will generate a Ycommercewebservices extension with some rest controllers that you can use as an example.
You can check webservice extension. Create new extension from it.

Azure Service Fabric and API Management Integration

I have provisioned a service fabric cluster on azure. It has two node types: one for the frontend and the other one for the backend.
I have deployed a Stateless self-hosted API on the frontend node-type. Now what i'd like to do is to expose that service through the Azure API Management. I've been trying to import the API without success. I have also tried to use swagger to generate the service specification but it seems that swagger does not work. I can access the swagger URL but it loads a blank page.
Any suggestions on how I can integrate my stateless service with APIM or how swagger works here?
Thanks a lot.
there are a few different ways you can produce your swagger document. If you are using Web API, you can use SwashBuckle to generate your Swagger for you. To validate your swagger file, you can use Swagger Editor. Finally, if you still have problems once you have validated your swagger document, share the document and the error here and we will see what we can do to assist.
Many thanks