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 😉

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.