Lob City
Lob City

Reputation: 87

PDF Attachments in Azure, use memory or temporary directory?

I'm planning on writing an application that sends multiple PDFs to the users' emails as attachments.

Should I use memory (MemoryStream) or is there a temporary directory that I can use? Which is more advisable? Thanks!

BTW I'm using C# ASP.NET

Upvotes: 0

Views: 727

Answers (2)

Pat Filoteo
Pat Filoteo

Reputation: 1026

You could use a different pattern. Put the PDFs in blob storage and place a queue message with the e-mail address & list of PDFs to send. Have a separate worker role build & send the e-mail. You could use X-Small or Small. Since this would also allow for asynch communication, you could just use 1 instance. If it can't keep up, spin up a second one via the config file (i.e. no re-deployment). This also has the added benefit of giving your solution more aggregate bandwidth.

If the traffic isn't very heavy, you could just spin up a separate thread (or process) that does the same thing.

Pat

Upvotes: 0

Mark Rendle
Mark Rendle

Reputation: 9414

I would go with file-system storage, since memory is a more scarce resource. Windows Azure provides Local Storage Resources for this purpose, which are areas of disk that you configure in Service Definition and then access through the Azure SDK at runtime. They are not permanent storage, and will get cleaned up when a role recycles, thus they are ideal for temporary operations such as the one you describe. Although you should still try to clean up the files after each operation to make sure you don't fill up the space.

Full information on Local Storage Resources is here: http://msdn.microsoft.com/en-us/library/windowsazure/ee758708.aspx

A table detailing the amount of disk space available for Local Storage Resources on each instance size is here: http://msdn.microsoft.com/en-us/library/windowsazure/ee814754.aspx

Upvotes: 3

Related Questions