How to use blob locally in ASP.NET MVC? - c#

I want to use blob to upload non-downloadable movies but I don't want to use Azure blob storage.
I want my files to be stored locally on a personal server.
Please help me if you find a solution.
If there is another way to create non-downloadable files, please explain

Related

How to add trigger to move file to azure blob from azure file share when a file uploaded to azure file share?

The requirement is to move the files from azure file share to azure blob when user is uploading a file to azure file share.
I have gone through the link below:-
https://feedback.azure.com/forums/287593-logic-apps/suggestions/20324680-add-trigger-for-azure-file-storage
What I found out till now is trigger mechanism is not supported on azure file share like we can do on azure blob.So How I can achieve the same functionality on azure file share.
Basically i want a trigger on azure file share so that when file is uploaded i should able to execute my custom logic written in c# to process the file and upload to blob.
As you mentioned the functionality is not yet offered as a connector, however, since you have written your custom logic in C#, you can use Azure Functions, which allows you to run custom code and will be used as if it was a logic app instance. you can get the idea from:
https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-azure-functions
I will also Upvote your feedback and will discuss the status with the internal teams as well.

Storing Images in Azure and Accessing it in Code

Before I published the website I've been working on to Azure, I kept all the images inside a local "Catalog" folder which was referenced in the program like;
image src='/Catalog/Images/Thumbs/<%#:Item.ImagePath%
Now it is deployed on Azure, I believe I need to turn to something called "Unstructured Blob Storage" to store and retrieve the images on the website.
This is my first time using Azure, I am wondering if it is as easy as storing the images in an unstructured blob storage on Azure, then just changing the "Catalog/Images/Thumbs" to the file path on Azure.
Does anybody know exactly how this works?
Thanks!
AFAIK, after deployed your web application to Azure, you could still store your resources (e.g. image, doc, excel, etc.) within your web application. In order to better manage your resources and reduce the pressure for your application when serving the static resources, you could store your resources in a central data store.
This is my first time using Azure, I am wondering if it is as easy as storing the images in an unstructured blob storage on Azure, then just changing the "Catalog/Images/Thumbs" to the file path on Azure.
Based on your requirement, you could create a blob container named catalog and upload your images to the virtual directory Images/Thumbs, and set anonymous read access to your container and blobs. For a simple way, you could leverage Azure Storage Explorer to upload your images and set access level for your container as follows:
And you image would look like this:
<img src="https://brucchstorage.blob.core.windows.net/catalog/Images/Thumbs/lake.jpeg">
Moreover, you could leverage AzCopy to copy data to Azure Blob storage using simple commands with optimal performance. Additionally, you could leverage Azure Storage client library to manage your storage resources, details you could follow here.

How to write a file to an Azure website folder from a webjob or worker role

I need to write an XML file to an Azure website folder under site root, with data pulled from the website's Azure SQL DB. This will be done on a recurring basis.
I have written a worker role which pulls the data and writes the file, however, it writes to a folder within the worker role folder structure using the below code. I am not sure how to specify and access the web folder path.
XmlTextWriter xml = new XmlTextWriter(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "feed.xml"), Encoding.UTF8);
Both the worker role and the website are in the same VS project, and deployed to Azure.
Since both the website and the worker role are in their respective VM instances, maybe the WR cannot access the website - I am not completely sure, and would really appreciate any guidance.
Would a webjob be better suited for this? Can it connect to an Azure DB, and write to a folder within the site root? Appreciate any code examples.
You wouldn't want to write a any single location as the server running your website is rather ethereal and can be taken offline and replaced at any time.
You should consider having your job generate the file and write it to Blob Storage and having your website read and serve the same file. Set up your site to treat the path to the file as a regular non-static route (this will let you keep the path /feeds/feed.xml) and the Action can read the XML file from your blob storage and serve it as the response.

retrieve images from .NET web service stored on azure like blob

Im trying to figure out how to retrieve images from a web service that is connected to azure thats has the images stored as blob.. i just want to be pointed in the right direction, sure if some one have a code example that will be really helpful aswell!
I have not tried any code yet just used google, youtube to find a good example... but no luck.. :/
I can store the images in a folder with the web service if that is easier?
Blobs are accessible using standard URLs. You may need a Shared Access Signature to access the file on a private blob.
I can point you in this direction:
https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/
https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-shared-access-signature-part-1/
Your service should do this (if I understand your need):
Create an output stream
Create in an input stream to a blob object and accessed using a SAS
Connect output stream with input stream
There are plenty of examples around for doing this...

Uploading material to azure storage

I have developed ASP.NET application, and I used for uploading materials to my local pc following code:
filename = Path.GetFileName(FileUpload1.FileName);
FileUpload1.SaveAs(Server.MapPath("~/uploadfile/") + filename);
Label1.Text = "Upload status: File uploaded!";
Now, I want this to upload on Azure and what I need is to change this code to suit uploading to my azure website. I have made storage there, but I don't know how should I code it. I have tried searching on google, but documentation is at least to say, horrible and very confusing. Any help is appreciated.
Thanks in advance.
It isn't entirely clear to me what you are trying to do. Normally in ASP.Net applications you aren't actually trying to upload images from the local computer on which but actually want to have the user be able to use their browser to select an image from their computer. If that is what you are trying to do there are lots of samples out there. Here is a good one from the Mobile Services site, or here is another example - although it appears to use an older version of the storage client library so make sure you upgrade to the >= 4.0 version of the library if you take this app further than prototype. For a good overview of Blob storage look here.
If you are indeed simply trying to upload materials to / from your local PC to Blob Storage then take a look at AzCopy instead - it might be simpler.

Categories