Posts

Monitoring critical API functionality

Image
There are different cases when you want to check your API, like performance or availability. For most cases there are bunch of monitoring tools which will ping your API or logger which will report and error. But what to do if you want to monitor a partner/integration API which is supposed to call your API and register something like sales. Ideally you dont experience any issues, like performance or errors, all is green, but no sales for long period. Partner can be down or VPN can have troubles.
Lets setup an alert for API which should notify that something is wrong and there are no sales for long time using Application Insights in Azure.

Open AI Alerts of your WebApi



Create new alert and select resource which you want to monitor, which AI service.

The complicated part is to select the condition.
Create new condition and select  ServerRequests from menu


There you can specify a customer query which will check in AI logs for any endpoint you want to monitor

In this case it will check for…

Running Stockfish hosted in Azure function

Image
While working on small chess application had an idea to integrate Stockfish engine, so it will be possible to play with engine.
More about Stockfish here : https://stockfishchess.org/
and here https://github.com/mcostalba/Stockfish

The idea is to pass FEN and Depth for calculation to some API which will suggest the best move.
My main problem is that the goal is to host engine in Azure, as function written in C# while Stockfish is in C++. There are of course some .net ports but really outdated and did not want to experiment with them.

First step is just to clone git repo of Stockfish and build exe file, put it into separate folder in my solution. Stockfish is a command line tool. I will send the commands to console and read the output.

This is what I will send and get:


And in the solution it will look like this:

With "No build" and "Copy to output" options

The function by itself to get the request is pretty simple:
[FunctionName("stockfish")]
        public stat…

SQL query timeout from application but works fast from SSMS

Image
Recently faced very strange problem. Application which was working great during last two years just suddenly had timeout on one particular page. The page was always very fast and was showing just last 12 records from the table.

So I did what always was doing to check slow performing query, started SQL Profiler to trace the query. Query by itself is pretty complex and had a lot of parameters, Profiler is the best tool I think in that cases.

After I easily found long running query in Profiler I copy pasted it into SSMS and what a surprize query just run in 300ms. Meanwhile the query from UI (asp.net) was running almost 2 minutes.

The first to be different is session variables. To get info about sessions you can just select from the sys.dm_exec_sessions table.
more info about table https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-exec-sessions-transact-sql

Easy way to compare between sessions:

SELECT
    session_id,
    [ansi_defaults],
    …

ServicePrinciple authentication for LakeStore and DataFactory

Image
New Authentication method to use in DataFactory to access Lake Store In Feb 2017 there is new authentication method was introduced to use in DataFactory. So you have a choice now between OAuth and Service principle




The OAuth choice will authenticate with Lake store using authentication token which will expire at some point of time. So for that option you just choose OAuth and get token from a popup windows. So Linked Service will look like this for you

For Service Principle you should have a principal created to use it. Here is the link how to do it https://docs.microsoft.com/en-us/azure/data-lake-store/data-lake-store-authenticate-using-active-directory
So you will need to provide ServicePrinciple id and key.
It makes more sense to use ServicePrinciple in case you have a scheduled job to run and avoid surprise with expired token.


Product catalog template is not available in SharePoint 2016 preview.

Image
Hi
Sounds like a bug in preview,
Was preparing for demo but I cannot see Product Catalog template in SharePoint 2016 Preview.



So here is the trick if you need it, just run a powershell command


$template = Get-SPWebTemplate "ProductCatalog#0"

New-SPSite –Url "http:///sites/catalog" -OwnerAlias "\" -Template $template

Sideloading of apps is not enabled on this site - error while debugging SharePoint application

Image
Hi

In case if you want to deploy, test or debug a SharePoint application on you newly created web site you can gen an error which looks like this

Error occurred in deployment step 'Install app for SharePoint': Sideloading of apps is not enabled on this site.

It means that the site does not have development feature enabled. Strange and stupid error message which could be more descriptive!

the solution is actually more stupid. you cannot enable it from features because it is hidden, so just run this from PowerShell and enjoy.

Enable-SPFeature e374875e-06b6-11e0-b0fa-57f5dfd72085 –url http://sptest.cloudapp.net

Skip domain requirement while configuring database for SharePoint

Image
In case if you forgot to configure domain while installing SharePoint or do not know how to do that you can face an error while configuring DB for SharePoint.

“The specified user is a local account . Local account should only be used in stand alone mode”


The easy way just pre create Databases before configuring SharePoint.

Just run SharePoint management shell and run New-SPConfigurationDatabase command and answer some sample question. The command will create configuration databases so you will be able to skip that step in the wizard.


May be not the best idea for production but in test environment this can save a lot of time.