Migrate .NET 2.0 application using file system storage to Azure - c#

I have an old ASP.NET 2.0 site that I really have no interest in rebuilding or updating at this point. I'd like to move it to Windows Azure but I'm not all that familiar with Azure so I'm wondering if it's easily portable.
The biggest potential roadblock is the fact that users can upload multiple photos. Upon upload, I create several copies of the image in pre-defined dimensions and store them on the local file system using Server.MapPath("{location}") to indicate where it should be stored.
Can I have a site hosted on Azure (using their Free or Shared tier) and continue to use this method of uploading and storing files or do I have to switch to blob storage? There are only about 400MB of images.
Basically I'm looking for a low/no-cost way to easily host this site on Azure that doesn't involve changes to the code (or at the very least, extremely minimal changes such as changing Server.MapPath to some relative location) so that I can move my other, more current ones to Azure as well. My situation is such that if I can't move this site, it doesn't make sense to move the others because I'll have to keep paying for the server for this one anyways (they're all hosted on the same server for now).

Azure drives are not guaranteed to be stored between reboots of the virtual machine, so you will probably need to use blob storage. But you can mount a blob as a NTFS volume and store it there. This would make the transition quite simple in the code.

Related

Read a folder on local machine using azure function c#

Is it possible to read a file located on local machine path C:\data with an azure function trigger by http request ?
You can expose a local file system to Azure using the on-premises data gateway.
However this supported from Logic Apps, but not as far as I know from Functions. You could however still use the Logic App as a bridge to your Function using the Azure Function Connector.
You are of course free to use your own personal computer however you like, but be aware that the on-premises data gateway exposes machines on your own network directly to the internet, which in the context of a business is often considered a significant security hazard. Definitely do not do this in a business context without clearing it with IT security persons first.
I would say no. The resource that you want to read data from needs to be accessible from the web. Put the files in the cloud so that the function can access them.

How to store files in Azure

We need to store ~50k files every year. Each file is 0.1-5mb which translates to 5gb - 250gb range. Files are: jpg, avi, pdf, docx,etc.
We used to just store file BLOBs in sql server but I guess it's not the best idea in this scenario because database will be huge in 2 years.
What would be the best way to store that data?
I see a lot of different options there and cannot figure out where to start:
Azure storage, Azure SQL, etc. There's also some hybrid versions in new versions of SQL server.
I use the following approach for multiple systems.
Azure Storage for files. You can create multiple containers and access levels if storing proprietary information.
Azure CDN for serving static content from Azure Storage
Azure DB as a database engine
In Azure DB I store the path the the file, with some additional processing in my applications for how to access the file to build up the final URL to serve the file from. This is due to CDN lacking SSL support on custom domains.
If you need examples or more info, just let me know. I'm sitting at an airport so providing a slightly less detailed answer.
As #Martin mentioned in his answer, Azure Storage is viable, specifically because:
Access is independent of any VM, service, database, etc.
Storage is durable - triple-replicated within a region, and optionally geo-replicated
Individual blobs may be up to 200GB, with storage scaling to 500TB
Azure also provides File Service, which is essentially an SMB share sitting on top of blobs.
While there are database services in Azure (SQL Database Service and DocumentDB), you'll find that these are not really optimized for large binary data storage; they're more optimized for metadata. You can certainly store binary data in each of them, but you'll need to worry about storage limits.
You may also spin up your own database solution via Virtual Machines, along with attached disks (again, backed by durable blob storage). Virtual Machines support up to 32 1TB disks attached to a given VM, whether normal blobs or "premium" SSD-based blobs (each premium disk supporting up to 5000 IOPS). Which database solution you choose is completely up to you; there is no "best" solution.

Recommendations For Saving Files in Elastic Beanstalk

I have an ELB application that we have just added photo upload functionality to. Currently this saves the images in a folder within the deployment directory in ELB, saving the URL to a DynamoDb table. Everything works fine. Whenever a user wants to see an image we simply attach the URL to the src attribute of an tag in the UI and the browser downloads the image directly.
However it occurred to me that if the underlying EC2 instance is terminated and re-started we will most likely lose all the photos. Am I correct in this assumption? If so, what's the best practice here? Should uploads always be saved in an S3 bucket? Any guidance hugely appreciated.
Should uploads always be saved in an S3 bucket?
TL;DR
In an elastic cloud environment, yes always move your static content to reliable external storage (in this case S3). It will make your app scale better. See the S3 question here
Resources:
IAM Credentials Giving your app keys to access s3 right out of the box in Beanstalk.
S3 Getting Started
Media Reference Architecture Describes at least part of what you're looking for. Look at the S3/Datastore/Web Server interaction there. More here.
Longer Description
In a traditional architecture you might have a drive attached to a web server or two and you store the files there. You always expect those to be up. If you run out of disk space you have a problem. If you're server craps out, you've also got a problem. Even if you have a backup, you run the risk of both going down and you needing to restore all your data AND bringing up a server manually.
In a cloud architecture you're basically admitting that the "machine" is fallible and no longer relying on it to store any application state. It should be used to store things you need on disk to launch the app and/or temporary storage, but if you need something long term thats why services like S3 exist! By eliminating state from your app servers you can scale them automatically (however you see fit) without worrying about your users' content. If you had other services that needed that content, they could get it from there as well with the proper permissions.

Correct way to handle roaming data storage with C# in Metro?

I'm creating a C# Metro/Modern UI app, and I need a way to handle some user data (mostly just small strings, but a fair amount of them), and specifically I'd like the data to 'roam' with a user's Microsoft Account. I know that you can handle this with roamingSettings, but it seems like that's supposed to be used more for like storing user IDs and other one-time settings, whereas I would be using it to store all of my app's data, and there seems to be a limit to the amount of space I get with that. I was thinking about using SkyDrive to host a "MyApp Data" folder, but I can't seem to figure out how to upload a simple text file to it :(
It seems like the best way to handle it would be to set up an account on Azure or EC2 and then make a simple PHP API so I could access the SQL database from my app, but I'd rather not have to pay for hosting.
I've seen other questions about Metro app storage on StackExchange and Microsoft's own forums, but most of those are in reference to local storage and using SQL servers to handle the storage.
So should I just use roamingSettings and keep an eye on the quota, should I try to use cloud hosting, or is there a better solution I just haven't thought of yet?
Thanks!
A few things about roaming settings:
- they are intended for that, settings. Not as a data replication scheme, thus the quota
- they are not immediate. You can create a setting named "highpriority" that will replicate in less than a minute, but other settings can take several minutes to replicate. If you need data to be available immediately, roaming settings are not an option. Also, if you exceed quota all your data will stop replicating, which is a bad thing. :) It also will not replicate between different versions of your app even if the settings are the same. In addition, if you do not use the app for a period of time (default is 30 days), then the roaming data will be deleted from the cloud. I am pretty sure roaming data can also be turned off via group policy in enterprise settings.
You can leverage SkyDrive. Make sure you download the Live SDK. Overview of using SkyDrive is here... http://msdn.microsoft.com/en-us/library/live/hh826521.aspx It is, fundamentally, just a collection of REST APIs. See the SkyDrive photo sample for an app that uploads files to SkyDrive http://code.msdn.microsoft.com/windowsapps/Live-SDK-Windows-Developer-8ad35141
I would go for a cloud based solution. A MS employee told me that the roaming data is a "best effort" there is no control if it actually works, sometimes it works, sometimes it just doesn't.
Personally I'd try to use the skydrive option

Obtaining Files From A Local Web Server or Network Share - Which Is Better

Here's the scenerio.
I have to access a web service on the local LAN to obtain a list of files which I then must retrieve from the machine running the web service. The question has arisen whether to use a mapped drive or just retrieve the files via HTTP from the web service (or web server if the service is self-hosting).
All machines are running Windows XP or later.
I am leaning towards the web server approach - because it has the fewest unknowns as far as having the necessary permissions to access the files.
So basically the question is which is the better approach - web server or network share?
I would go the webservice route because it reduces the number of variables in the equation. Based on your current setup you already need a web service in order to get a list of files to download. At this point you know access to the web service isn't a problem so putting the files there removes a lot of unknowns.
If you put files onto another machine you run the risk of hitting at least the following problems that do not exist with the web service (since you already know you have access)
Permission Issues
Firewall issues
I would think it depends on various factors you haven't mentioned: will lots of clients be trying to access these files at a given time? Will the app be distributed across multiple servers in the future? Might you need to implement a caching system in the future?
If the answer is no to all of these, then you should probably pick what's easiest.
I would lean towards plain old HTTP. Doing it via the web service would probably involve marshalling the file as an array, for example, which makes it larger. A file share means needing to worry about permissions.

Categories