upload image to azure blob storage c# ms crm plugin

Before reading this article, please go through the following article:

  • Installation Of Azure SDK And Hulk Storage In Azure: Part 1

In this article, I'll tell you the uses of Azure Hulk Storage and how to use blob storage in ASP.NET Project. Firstly, create an ASP.Cyberspace project in Visual Studio, then open up Visual Studio and follow these steps:

Step 1: Open Visual Studio and select the File bill of fare, New, then Project.

new

Step 2: Get to Templates, Visual C#, then ASP.Net Web Application.

Step 3: In the proper noun section, give a proper name to project. Here I have given the name "Azure Hulk Storage".

Pace 4: Click on "OK" push to create a project.

project

In the following figure, choose "Empty" project.

Click "OK" button.

button

We can run into, in our projection, at that place are three types of categories items, properties, References, and Web.config.

refrences

Now nosotros need to install the Windows Azure Storage package for using Azure Storage Access and all supported classes.

Now go to the "TOOLS" menu, select "NuGet Package Manager", and select "Manage NuGet Packages for Solution".

NuGet

In the following effigy get to the search box and type "azure". Afterwards this you lot will find the "Windows Azure Storage", click on "Install" push button.

Windows Azure Storage

Now in the post-obit figure, you can meet the installation of the "Windows Azure Storage".

installation

Hither in the post-obit window,you will exist asked to install "Windows Azure Storage" for the current project, and so here we want to install the packages for current projection.

Merely click on "OK" push.

Windows Azure Storage

The installing process is going on.

process

process

Hither in the following figure, click on "I Have" button.

Acceptance

Now nosotros successfully installed the "Windows Azure Storage" (in the small reddish circle).

Click on "Shut" button.

Close

Here we also demand to install the azure storage customer packages. So become to the search box, blazon the "Azure Storage Client". After typing, click on "Install" button.

Azure Storage Client

Nosotros successfully installed the "Azure Storage Client" package also.

Click on "Shut" button.

Close

Become to your project, here my project name is "Azure Blob Storage".

Right click on to projection, select "Add" and select "New Detail".

Add

Here, I am going to create a Spider web Form, so select a Web Form in the listing and give the name to your Web Form; here I gave the name "MyForm" to my Web Course, you can give any name to your Web Form.

Click on "Add" button.

Add

After creating a class, y'all tin can run across your project, where class will be created successfully with the name "MyForm.aspx"

MyForm

In the "MyForm.aspx.cs" page, let me do some changes.

MyForm

In the "MyForm.aspx.cs" page, I have added all namespaces which is minimum required.

MyForm

Now we need "accountname" and "accesskey" to get continued with Azure Account, and then go to Azure portal.

Become to "Storage" option where I have created a Storage Business relationship with the name "nitindemostorage" in my previous commodity. You lot can visit my previous article of azure.

  • Installation Of Azure SDK And Blob Storage In Azure: Role 1

Here, subsequently clicking "nitindemostroage" named Storage Account, go to bottom of the window and select "Manage Access Keys".

Access

You will find the following window, copy the "Storage Account Name" and "Primary Access Key" from here,

Key

Go back in your project and make some changes over there.

In the "accountname" and "accesskey" paste the copied item over in that location.

And make some other code over there for getting connections with Azure storage business relationship with "CloudStorageAccount" class object and at terminal convert your image into stream upload every bit in the post-obit image:

CloudStorageAccount

Code

  1. string accountname = "nitindemostorage" ;
  2. string accesskey ="8TeQ8Li/b5U75aSPeTUvmg6w6s6emWSC5KKksNR7hRmSS5GmxzY8wxXFxJtNlwnwSbvlWGAX07dnR0W8jrb+Og==" ;
  3. effort
  4. {
  5.     StorageCredentialscreden = newStorageCredentials(accountname, accesskey);
  6.     CloudStorageAccountacc = newCloudStorageAccount(creden, useHttps:true );
  7.     CloudBlobClient customer = acc.CreateCloudBlobClient();
  8.     CloudBlobContainercont = client.GetContainerReference("mysample" );
  9.     cont.CreateIfNotExists();
  10.     cont.SetPermissions(newBlobContainerPermissions
  11.         {
  12.             PublicAccess = BlobContainerPublicAccessType.Blob
  13.         });
  14.     CloudBlockBlobcblob = cont.GetBlockBlobReference("Sampleblob.jpg" );
  15. using (Stream file = System.IO.File.OpenRead(@ "D:\amit\Nitin sir\Nitinpandit.jpg" ))
  16.     {
  17.         cblob.UploadFromStream(file);
  18.     }
  19. }grab  (Exception ex)
  20. {
  21. }

I more thing, hither we need to create a Web App Profile for publishing our app into the cloud.

Simply get to "Spider web APPS" in your Azure Portal and click on "New" to add a new Web App.

Web App

Later clicking on "New", yous will meet the following window.

Go to "COMPUTE" option, select "Spider web APP", and select "QUICK CREATE".

Create

In the URL section, you can write your Web App name. Here I accept given "nitinblobstoragedemo", if the entered name is right it will create a cheque sign (in blue color).

In the "APP SERVICE PLAN" click on "Default1 (East Asia, Shared)".

Click on "CREATE Spider web APP".

Create WEB APP

We accept created our Spider web App successfully. Later on doing this, we can encounter our created Spider web APP("nitinblobstoragedemo").

And it is in running way.

nitinblobstoragedemo

We make some code in the Web Config file likewise.

Hither in the <add value="MyForm.aspx"/>, "My Course" is my Web form.

Form

In the "MyForm.aspx" you lot can give any message for output. Whenever yous build your project, the typed message volition be your output.

So, here in the div section I have given a bulletin, "Creating Hulk---Past Nitin Pandit".

blob

Now we need to publish our created project in the deject. It will also save in the Azure Explorer. You can publish your project by two means. Here, I am going to discuss both means. Firstly, right click on your project. Here my projection is "AzureBlobStorage", so select the "Publish" option.

publish

In the post-obit figure, you can see "nitinblobstoragedemo" is my Web App name, which nosotros have created in the starting. Select your Web APP profile and click "Publish" push.

publish

After clicking on "publish" push button the project would publish on cloud too as in your Azure Explorer. The second manner to publish your projection is to go for cloud. Yous can download your contour from the Azure business relationship in your Web Apps. For this click on your Web App profile, in the Publish your app section, click on "Download the publish profile".

profile

Afterwards clicking, your contour volition be downloaded in your system.

system

After this, now nosotros can see the condition of our publishing. So my "nitinblobstoragedemo" app service published successfully.

Now build your project and get your output.

output

Now run the application, printing F5.

So, finally we got our output.

output

We tin run into the changes of this in our Azure Explorer.

Now refresh the Azure Explorer to bank check your prototype.

image

"Sampleblob.jpg" is my epitome which is generated by programming,

Sampleblob

Right click on prototype and open up it and if you want to become that images by code on your view, you can see in my next article. Then, expect for that and stay tuned.

click

Information technology tin accept few moments to download the image is in progress.

progress

Hither'south the concluding output and y'all tin can see my image:

output

Thank you for reading this article and await for next,

Connect("Nitin Pandit");

greentrigive.blogspot.com

Source: https://www.c-sharpcorner.com/UploadFile/8ef97c/upload-image-to-azure-blob-storage-in-Asp-Net-part-2/

0 Response to "upload image to azure blob storage c# ms crm plugin"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel