简体   繁体   中英

Is it possible to print through .NET code from an Azure Worker Role

To start off with, I am aware of this question that seems to ask the same thing . However I'm going to ask it again with a slight modification.

I'm working on a project to print PDF's. We have a library for PDF manipulation. We can use it to render a PDF to a file that the System.Drawing.Printing.PrintDocument object can use and print in c#. We are going to have an Azure Worker role that takes many 1-page pdf's and turns them into one large pdf, and I would like to have another Azure Worker Role that then spools that large PDF to a Windows Print Server here locally.

Since the printing part is so much slower (compared to the pdf creation/aggregation piece) I would like to be able to host it in azure to easily scale.

My initial thought was "I don't think this is even possible. How would Azure be able to know anything about my local print server." Which is the basic answer from the above similar question. But after some searching, I found some results that seem to indicate setting up a VPN Site-To-Site Tunnel or ExpressRoute Connection would let me do what I want. However I'm relatively new to Azure and the results I found are short on actual, useful, helpful details.

If it can't be done, fine, I can set up an application server locally to do the printing. But if someone has ideas or more insight on how to accomplish this I would love to hear it.

Basically, you could store PDFs into Azure Blob Storage like:

http://azureaccount.blob.core.windows.net/PDF/pdf1.pdf

Then you define an Azure Queue entity like:

MyQueue(Pdf_Id, Pdf_Blob_Url)

MyQueue(1, http://azureaccount.blob.core.windows.net/PDF/pdf1.pdf) 
MyQueue(2, http://azureaccount.blob.core.windows.net/PDF/pdf2.pdf)

and submit to the Azure Queue .

Then on your Printing server, just setup an application to check the AzureQueue to process the PDFs. At this point, just get the PDFs directly from Azure blob storage url to do anything you want like merging, printing,....

Without getting into the VPN / Site-To-Site setups, here is an Idea:

You could have a small application hosted on your network that uses Service Bus Relay to expose a WCF service (this will allow incoming connections to the service from the role)

The worker role can consume this Service and then send the PDF for printing to it.

Your App would send the PDF to the printer via PrintDocument object you mentioned.

See:

https://azure.microsoft.com/en-gb/documentation/articles/service-bus-dotnet-how-to-use-relay/

What is the Service Bus relay? The Service Bus relay service enables you to build hybrid applications that run in both an Azure datacenter and your own on-premises enterprise environment. The Service Bus relay facilitates this by enabling you to securely expose Windows Communication Foundation (WCF) services that reside within a corporate enterprise network to the public cloud, without having to open a firewall connection, or require intrusive changes to a corporate network infrastructure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM