Azure Web Sites Native C++ DLL (p/invoke)

Sometimes you need improve performance of your code or using library which written on other language. Today we will talk how to create x64 C++ library and how to invoke method in C# Azure Web Site.

  1. Create C++ dll library in VS
  2. In project settings (Linker -> Advanced) set Target Machine to MachineX64 (/MACHINE:X64)
  3. In project setting (C/C++ -> Advanced) set Calling Convention to __cdecl (/Gd)
  4. For example create header and source files with name ExpressionExecuter
  5. In header file define prototype function:
  6. Source file realize method ValidateExpression:
  7. Configure Azure Web Site using method described here
  8. Now we need to realize invoke method in C# project:
  9. Now you can use C++ code using p/invoke in Azure Web Site project:
  10. Don’t forget set X64 configuration settings on staging or production azure web site (Configure Tab -> General -> Platform) select 64-BIT option.


Now you have performance code in your C# Azure Web Site project 😉

How I spent half a day trying to solve SSL connection error (ERR_SSL_PROTOCOL_ERROR)

Hope it helps someone to prevent spending a lot of time trying to solve SSL connection error problem during local site debugging.

My web.config contains rewrite section for https requests:

I tried (but it didn’t work):

  • Check localhost ssl certificate
  • Removing rewrite section
  • Clearing rules section after all existing rules
  • Removing localhost from chrome://net-internals/#hsts
  • Change web site port
  • Repairing IIS Express and Visual Studio

The solution was:

  • Just clear cache of your browser (CTRL + R didn’t help)
  • Delete applicationhosts.config in solution folder (.vs/config)


Searching Azure Table Storage entities using query like Substring or Left

Using Azure Tables Storage we know that selecting primary key and row key one of the most important things. In my situation I decide to make a complex Row Key. It looks like some GUID + “_” + Other Data.

The next step is searching some data that contains first part of Row Key – GUID. For example to delete entities.

First part is prepare batch deletion. To achieve this I find great solution here.

The second part is make Expression – to filter entities using Substring or Left method. For that we can use CompareTo method.

For example I need remove users by project:

Success. Now we know how to search entities using method like Substring or Left for Azure Table Storage.

How to backup and restore Azure SQL Database using SQL Server Management Studio

Before upload new server version or new database script the best practice is to do backup. How it works with Azure SQL Database read below.

Note: You must have SQL Server Management Studio to do next steps.

1. Connect to your SQL Server using Management Studio

Connect to SQL Server

2. Click right button on your database and select Tasks -> “Export Data-tier Application …” to create bacpac package with backup of your data.

Export Data-tier Application ...

Go through wizard and get bacpac package which contains schema and data of your DB.

3. Another option to get just schema of your DB is click right button on your database and select Tasks -> “Extract Data-tier Application …”

Extract Data-tier Application ...


Go through wizard and get dacpac package which contains just schema of your DB.


Now if something goes wrong you can restore your Azure SQL Database clicking right button on Database folder under your server and select “Import Data-tier Application …” to restore bacpac backup.

Import Data-tier Application ...


Have a nice deployments!