From the course: Building a Web Application on Microsoft Azure

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Implementing the StorageService class

Implementing the StorageService class - Azure Tutorial

From the course: Building a Web Application on Microsoft Azure

Implementing the StorageService class

- [Instructor] We're going to implement a new storage service class that encapsulates the logic for communicating to the Azure storage account. In the .NET world, we use NuGet packages for reusing code. So in this project I'm going to add a new NuGet package reference that is Azure Storage Blobs. It was created by Microsoft and it contains all the required libraries for using storage accounts in your .NET code. So let's install this. And now we're ready to add a new folder and let's name it Services. And here, I'm going to add a new class that is storage service, and I want to expose the following method. I want to return the final URL of the file that we're uploading. So public, we're going to return this asynchronously. And let's name this UploadAsync. And this is going to receive a stream and the fileName. So the first thing that I want to do is position this stream at zero. And then I'm going to create a new…

Contents