1

I want to check whether my api is working fine. I have an api which only has post requests and no GET.

The tutorial here: https://learn.microsoft.com/en-us/azure/application-insights/app-insights-monitor-web-app-availability mentions that it is very easy to check whether a rest api is working fine.

When I write an availability test, it just asks me a url, but this is not enough for my case as it is a post request.

How to do that in App Insights? Is it not possible??

Rafael
  • 651
  • 13
  • 30

3 Answers3

2

You can use Multi-step Web Tests for this:

https://learn.microsoft.com/en-us/azure/application-insights/app-insights-monitor-web-app-availability#multi-step-web-tests

I think current pricing is $10/month (all locations are included).

EDIT: Simple Web Tests are free.

ZakiMa
  • 5,637
  • 1
  • 24
  • 48
  • The multi-step web tests are like capturing actions in web pages. I have an api with post request. I can't do things like sign in. I have to pass parameters. – Rafael Feb 14 '17 at 05:48
  • Multi-step web test can be recorded based on web browsing. But you also can create your own steps and specify anything there - VERB, headers, payload, get response, parse it into variables and then use them in subsequent requests. – ZakiMa Feb 14 '17 at 08:47
  • Here is an example of creating web service request (it also goes into implementing custom rule extractor - this part is not supported in shared environment; but there are quite a few extractors including regex-based): http://www.thisdevmind.com/2014/12/27/using-visual-studio-web-test-for-automating-api-testing/ – ZakiMa Feb 14 '17 at 08:52
  • Here is another example of using it against API: http://stackoverflow.com/questions/35019470/visual-studio-web-test-for-api-request-failure-invalid-http-header-characters. Doesn't need to be browser-based... – ZakiMa Feb 14 '17 at 08:56
  • Thanks a lot. Any more examples especially for post requests where I pass a query to api would be very helpful. – Rafael Feb 14 '17 at 09:20
  • Hi Zaki, is web test plugin supported? – Rafael Feb 14 '17 at 12:43
  • @Rafael, web test plugins are not supported. Re: examples - I don't see specific to post requests, most of talks/blog posts cover more advanced features. – ZakiMa Feb 15 '17 at 17:55
  • @Rafael, you can create Web Performance Test in Visual Studio and play. Either by creating requests from scratch or start a recorder, record simple web page and then modify requests. – ZakiMa Feb 15 '17 at 17:56
  • @Rafael, another approach - use Fiddler - capture your API call and then export it as VS Web Test - http://docs.telerik.com/fiddler/Save-And-Load-Traffic/Tasks/VSWebTest – ZakiMa Feb 15 '17 at 17:57
1

You can sue also some custom code to do your POST request, and report the telemetry to Application Insight. Here a .netcore sample: https://github.com/rbickel/Azure.Function.AppInsightAvailabilityTest

Raphaël
  • 427
  • 5
  • 14
1

If your API only has POST requests, it won't be possible to use the built-in URL ping test which only sends GET requests.
But rather than settings up a more complicated availability test, it would be easier (if possible) to add a healthcheck resource to your API. Then you could use the built-in URL ping test which will send a GET request to say "/health".

Alternatively, you can create custom availability tests which you have to run and host yourself. The Microsoft Documentation provides this Azure Function example. You could also use PowerShell as I documented on my blog.

Swimburger
  • 6,681
  • 6
  • 36
  • 63