Using Ghostscript.Net on an ASP.NET Azure Website - c#

I am using Ghostscript.NET in order to convert a PDF page into a jpg. This all works fine when I run it locally, but when I publish it to an Azure website then I get the error:
"This managed library is running under 32-bit process and requires 32-bit Ghostscript native library installation on this machine! To download proper Ghostscript native library please visit: http://www.ghostscript.com/download/gsdnld.html"
Obviously I can't just install Ghostscript on the server that the Azure Website is running on, I don't have access to do that. Is there any way that I can include a Ghostscript library in the publishing profile, and have Ghostscript.NET read from that?
Alternatively, is there any package that would allow me to convert a PDF page to a jpg thumbnail on an ASP.NET server without using Ghostscript at all? I have also tried GhostScriptSharp and had no luck with that either.

You could try to install native ghostscript library to your local machine and get gsdll32.dll (or gsdll64.dll if you are running in x64 bit environment) which you can deploy to your server along with the other dlls.
Take a look at this example how to tell Ghostscript.NET where to search for the native ghostscript library dll: https://github.com/jhabjan/Ghostscript.NET/blob/master/Ghostscript.NET.Samples/Samples/CustomGsdllLocationSample.cs

You have a few options.
Host your website as an Azure Cloud Service Web Role. This allows you to react to the server being created and you can run installation programs (if you can automate them) to prep the machine.
Split this functionality out into an Azure Cloud Service Worker Role (where you can do the same machine prep) and have it respond to an Azure Queue item. This way your website remains pretty much as is.
Be careful though, Cloud Services can get expensive if they are just sitting there doing nothing because its still running on a VM. You can have your Cloud Service scale based on the queue having items or not.

Related

In Azure Devops, how can I deploy an exe file to as server as part of release (or something similar)

A solution consists of...:
Web app
Console app ("jobserver", which pulls jobs and processes them)
All is C#, .Net Core 5.
I have continuous deployment set up, so new versions of the web app are deployed to Azure Web App automatically.
However, the console app, I cannot figure out a good way to deploy to a Windows server (or pull). Right now, I go to the server, stop the app if it is not doing anything (otherwise I wait a bit). Then I copy the files over and start it up again. All manually.
I can think of several complicated workarounds, but I am thinking there must be easier way.
What are some ways the deployment of exe file could be handled? How are others handling this?
Ps. The console app cannot run on Azure Web App or as WebJob or similar, because it has requirements that means it has to run on a "real" windows server.
You can use the PowerShell on Target machines or SSH tasks to run commands on a remote machine. Similarly, to copy files, you can use Windows Machine File Copy or Copy Files Over SSH to copy your .exe to the server.

Win32 DLL not found error in Azure Web Application

I have a web application which is hosted in Azure. When I run the app and authenticate the user, I am getting the error "One of the dependent DLL not found".
Background:
In the web application, I am using fingerprint scanner functionality to capture a fingerprint image. To capture fingerprint image during user registration, I am using a javascript library and it works fine. I am storing the fingerprint in storage. When a user logs in into the website, I need to perform authentication and again I capture fingerprint from the user and compare it with one associated with the user. For comparing two fingerprint images on server-side, my C# code calls fingerprint scanner SDK which in turn calls dependent DLL's (from System32) which I guess comes with fingerprint scanner SDK. When I run the site locally, it works fine (as I have fingerprint SDK installed on the local machine). But when I deploy the application on Azure and this code execute, I am getting the error "One of the dependent DLL not found". I understand run time is looking for one of the dependent DLL from the system32 folder which is not there in the Azure environment.
I tried copying fingerprint scanner DLL's to Azure web apps bin folder but it not working. I am getting the error An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B).
Image - which shows DLL added to root folder
I also tried to include system 32 DLLto .net core class library project but it gives error The reference is invalid or unsupported
Image - Error while adding system32 DLL to .net core project
Is there any way to install third party software on the Azure web app?
You can't directly install 3rd party DLLs in App Service. One way around that is to deploy your app in a Windows container that App Service will pull and run. Another way is to use a virtual machine instead of App Service, this way you have full control of the machine and you can install whatever you want.
One possibility is to use Windows Containers in App Service.
Here you can follow the quickstart to run a Windows Container in App Service:
https://learn.microsoft.com/en-us/azure/app-service/app-service-web-get-started-windows-container
 
Following will be the steps to resolve the issue
• Make sure correct native library (Third party DLL’s) copied to a wwwroot folder on the server (either 64bit or 32 bit)
• Check azure web service configuration platform (If third party dll is 64 bit then change to 64 bit)
• From the visual studio, while publish an application using web deploy to make sure deployment mode is self-contained and Target runtime win-x64
Additional things that need to take care
• If the project is in the .net core then we can not add direct third part dll reference, we need to add an existing item and in property of dll make sure it copies always
• Change Platform target to 64 or 32 bit as per project requirement
Above steps works for me

Pechkin with Windows Azure

I'm getting this error whenever I try to debug the Azure project from Visual Studio. I checked on my original site project file the Platform Target and project's and every dependence as well are using "Any CPU". Not really sure what to do from here.
Could not load file or assembly 'Pechkin' or one of its dependencies.
Are you running 32 bit allowed? Lots of docs out there talk about this being a limitation.
mark as the answer please if that is the problem. There are solutions as well. apparently a guy did a fork called tuesPechkin with 64 bit versions.
It's not possible to get wkhtmltopdf working on Azure. See this thread and this Gitgub issue.
I am assuming you mean running wkhtmltopdf on Windows Azure Websites.
wkhtmltopdf uses Window's GDI APIs which currently don't work on Azure
Websites.
A solution could be to create a Windows service (or for example a web api endpoint), which runs the Tuespechkin converter. Then create a VM in Azure and install the Windows service/end point there.

Executing windows azure web job

I create a small .exe that updates some tables in my database also create in azure, but all the times that I upload the .zip file required shows this error
Reading blogs I realized that some people are using the windows azure web job sdk, to upload their projects, it is worth to point it out that this library doesn't have a version for Visual Studio 2010, so it can't be used.
Is the use of the aforementioned sdk the only way to create and use console application web jobs?
Usually you get the failed to upload job error if the zip file does not have the job exe in the root folder.
This often happens when you zip the Debug/Release folder instead of its contents.
You don't have to use the Azure WebJobs SDK for your job. Any console application will work.
sdk the only way ...
No, WebJobs can run without the cloud SDK. To quote Hanselman
You don't have to use the WebJobs SDK with the WebJobs feature of
Windows Azure Web Sites.
As to what the exact problem is...with VS2010 and Azure that is hard to say with what you have presented.
WebJobs, since it sits on top of the Azure Web Sites service, it supports everything the Web Sites support. Including: python, php, bash, powershell, node.js, .net, cmd, bat, etc...

Socket Server in Amazon Elastic Beanstalk

Currently, I have a socket server, that listens to incoming connections on two ports (e.g. 7777 and 7778) and replies to them. The data is stored in an RDS environment, part of a bigger Elastic Beanstalk environment that accesses the same data. The socket server is implemented as a Windows service. So far, so good. It works.
However, I am asking myself, whether it's possible to have the socket server also within the same (or possibly another) Elastic Beanstalk environment, but so far, I haven't found any way to do that.
My goals are
to have a far simpler deployment procedure, as in the productive environment, I need the socket servers to be behind a load balancer and don't want to deploy a windows service on each instance.
to have only one environment to deploy to, so that I won't have to deploy (manually or automatically) each time I have a change in the DAL.
The socket server does not need to be implemented as a Windows service, it just is now.
Everything is implemented in C#. Any help is appreciated.
I think, I got this covered. However, I couldn't deploy the Windows Service without errors stand-alone, but only as part of a Web application. Not a real problem in my scenario, though.
I have two projects for this scenario; a Web Application and a Windows Service application.
On the build server, I create a ZIP file of the Windows Service
executables (using zip.exe)
On the build server, I upload the ZIP file to an S3 bucket (using s3.exe)
On the project of the web application, I create a .ebextensions directory
In the .ebextensions directory, I have a whatever.config file that
Takes the ZIP file from S3 and unpacks it onto the C-Drive in my preferred directory
Calls a batch file (part of the ZIP file) that uninstalls and reinstalls the Windows Service with the InstallUtil.exe utility (part of the .Net framework)
In my nightly builds (of the complete solution), I deploy the web application to Elastic Beanstalk using awsdeploy.exe.
Therefore, I point to a configuration.txt file in a builds directory of my web application.
You can generate such a build file with a manual Elastic Beanstalk deployment from Visual Studio; but they are quite easy after a while.
What happens now, is that in my Nightly Builds the Web application is deployed to the Elastic Beanstalk environment; the deployment will recognize that there is a configuration and will execute the steps mentioned below step 4 above. As the Nightly Build created and uploaded the ZIP file of the Windows Service before that, I am sure that I will install the most recent Windows Service.
My only problem now is that the Windows Service does not always install itself because of the infamous marked for deletion error. But that's another story.
I hope this helps somebody. If anyone has a suggestion to simplify this, he's welcome to add a comment.

Categories