Connect application dotNet to APM (Cloud)

Good morning,

I'm using the trial version and i would like connect my .net application to APM. I followed the steps that appears in the documentation but is not running.

I didn't change anything about the configuration of the APM or the indices, and I suppose my config file is correct (the serverUrl and token obviously is different):

>     "ElasticApm": {
>         		"ServerUrls": "http://aaaaaaaa.westeurope.azure.elastic-cloud.com:8200",
>         		"TransactionSampleRate": 1.0,
>         		"SecretToken": "xxxxxx",
>         		"ServiceName": "Orchestrator_Invoicing_Development"
>         	}

I know that the default port of APM is 8200, but in cloud is the same? Is correct?

When I run the application I have this error:

fail: Elastic.Apm[0]
      {CentralConfigFetcher} Exception was thrown while fetching configuration from APM Server and parsing it. ETag: `<null>'. URL: `http://aaaaaaaa.westeurope.azure.elastic-cloud.com:8200/config/v1/agents?service.name=Eurofirms_Orchestrator_Invoicing_Development&service.environment=Development'. Apm Server base URL: `http://aaaaaaaa.westeurope.azure.elastic-cloud.com:8200/'. WaitInterval: 5m. dbgIterationsCount: 1.
      +-> Request:
          Method: GET, RequestUri: 'http://aaaaaa.westeurope.azure.elastic-cloud.com:8200/config/v1/agents?service.name=Orchestrator_Invoicing_Development&service.environment=Development', Version: 2.0, Content: <null>, Headers:
          {
            User-Agent: elasticapm-dotnet/1.4.0
            User-Agent: System.Net.Http/4.6.27110.04
            User-Agent: .NET_Core/2.2.0
            Authorization: Bearer xxxxx
          }
      +-> Response: N/A
      +-> Response body [length: N/A]: N/A
System.Net.Http.HttpRequestException: Se produjo un error durante el intento de conexión ya que la parte conectada no respondió adecuadamente tras un periodo de tiempo, o bien se produjo un error en la conexión establecida ya que el host conectado no ha podido responder ---> System.Net.Sockets.SocketException: Se produjo un error durante el intento de conexión ya que la parte conectada no respondió adecuadamente tras un periodo de tiempo, o bien se produjo un error en la conexión establecida ya que el host conectado no ha podido responder
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at Elastic.Apm.BackendComm.CentralConfigFetcher.FetchConfigHttpResponseImplAsync(HttpRequestMessage httpRequest)
   at Elastic.Apm.Helpers.AgentTimerExtensions.TryAwaitOrTimeout(IAgentTimer agentTimer, Task taskToAwait, AgentTimeInstant until, CancellationToken cancellationToken)
   at Elastic.Apm.Helpers.AgentTimerExtensions.TryAwaitOrTimeout[TResult](IAgentTimer agentTimer, Task`1 taskToAwait, AgentTimeInstant until, CancellationToken cancellationToken)
   at Elastic.Apm.Helpers.AgentTimerExtensions.AwaitOrTimeout[TResult](IAgentTimer agentTimer, Task`1 taskToAwait, AgentTimeInstant until, CancellationToken cancellationToken)
   at Elastic.Apm.BackendComm.CentralConfigFetcher.FetchConfigHttpResponseAsync(HttpRequestMessage httpRequest)
   at Elastic.Apm.BackendComm.CentralConfigFetcher.WorkLoopIteration()
warn: Elastic.Apm[0]
      {PayloadSenderV2} Failed sending events. Following events were not transferred successfully to the server (http://aaaaaaa.westeurope.azure.elastic-cloud.com:8200/):
    Transaction{Id: 88b95afac1b919e3, TraceId: fb1f5f478be34ec22d7c5daf2ae8e819, ParentId: null, Name: GET /API, Type: request, IsSampled: True},
          Transaction{Id: de63d2fecff6a2c6, TraceId: 905ce611e8ffed2eacbd6ba0bcea76ae, ParentId: null, Name: GET /API/index.html, Type: request, IsSampled: True},
          Transaction{Id: d15490ca43286fd8, TraceId: 8a53547a1097eada272f97ab17a46f64, ParentId: null, Name: GET /swagger/v1/swagger.json, Type: request, IsSampled: True}
System.Net.Http.HttpRequestException: Se produjo un error durante el intento de conexión ya que la parte conectada no respondió adecuadamente tras un periodo de tiempo, o bien se produjo un error en la conexión establecida ya que el host conectado no ha podido responder ---> System.Net.Sockets.SocketException: Se produjo un error durante el intento de conexión ya que la parte conectada no respondió adecuadamente tras un periodo de tiempo, o bien se produjo un error en la conexión establecida ya que el host conectado no ha podido responder
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)

Thanks for the help.

Hi @Kirtash,

I know that the default port of APM is 8200, but in cloud is the same? Is correct?

On cloud it's the default https port, so in that case it is not 8220. Basically no port needs to be specified in case the server runs on cloud.

There is a button for this - you can click that and past the url - with that it should work:

The other thing I noticed you use http instead of https - that should be https, like this (with adapting the beginning similarly as you pasted):

"ServerUrls": "https://aaaaaaaa.westeurope.azure.elastic-cloud.com",

so added https and removed the port.

Thanks Greg!!!! Your answer was perfect :wink:

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.