@K Amen , Thanks for the good question.
Just to clarify, are you provisioning it on Azure App Service Web App or Azure Cloud Service/or on an Azure VM?
Just to highlight, since App Service is a fully managed service, it doesn't support installing custom MSIs and custom executables on the underlying workers.
(cannot install custom DLLs in locations other than the file directory structure of the app).
The Azure App Service WebApp runs applications in a sandbox as part of the multi-tenant architecture. The App Service sandbox is discussed in this article.
However, you can try the following to see if you can get your app to successfully find and load the DLL.
You may try setting the DLL file in your project as ‘Copy always’, change the DllImport command to point to "./bin/mylib.dll" and see if that helps.
- Ensure that the native DLL is copied into the /bin subdirectory App
- Define the following DllImport, somewhere in your WebApp - (Looks like you have already defined this)
- Next, in the startup code path of your WebApp, before you call into your managed wrapper, explicitly include the /bin directory of your WebApp in Windows’ default DLL search path.
Also, in the Azure Portal, under 'Configuration' Settings’ ('General Settings') of your WebApp, if the native DLL is a 64-bit DLL, ensure to set the ‘Platform’ setting for the app to 64-bit and then check.
- If your requirement fits you can host it on Windows Container on App Service.
I see that you have also posted this on SO, and have received answers on it, you may also take a look into the suggestions outlined.
Additional info: App Service -Operating System functionality