Introduction
Last time, I published an article with the title “Upload Image to blob storage using Xamarin.Android”. In this article, you will learn how you can upload Images to blob storage through Xamarin.forms. I hope you will learn something amazing in xamarin.
Prerequisites
If you don't have an Azure subscription, create a free account before you begin.
Log in to the Azure portal.
Create a storage account

Create a container
Let’s create a xamarin.forms project with .Net standard library.
First of all add the required nuget packages to our application.
- Xam.Plugin.Media
- WindowsAzure.Storage
Step 1 - Create User Interface of App
Open MainPage.xaml file, simply replace the following code inside your ContentPage tages.
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinitionWidth="*" />
- </Grid.ColumnDefinitions>
- <Grid.RowDefinitions>
- <RowDefinitionHeight="*" />
- </Grid.RowDefinitions>
- <Buttonx:Name="btnSelectPic"Grid.Row="0"Grid.Column="0"Text="Select picture" Clicked="btnSelectPic_Clicked" BackgroundColor="DodgerBlue" TextColor="White" />
- <Buttonx:Name="btnTakePic"Grid.Row="0"Grid.Column="1"Text="Take picture" Clicked="btnTakePic_Clicked" BackgroundColor="DodgerBlue" TextColor="White" />
- </Grid>
- <Imagex:Name="imageView"HeightRequest="300"WidthRequest="400" />
- <ActivityIndicatorx:Name="uploadIndicator"IsVisible="False" IsRunning="False" Color="DodgerBlue" />
- <ButtonText="Upload to Blob"Clicked="btnUpload_Clicked" x:Name="btnUpload" BackgroundColor="Green" TextColor="White" />
- <Editorx:Name="UploadedUrl"TextColor="Black"HeightRequest="85" Text="Image URL:" />
- </StackLayout>
Step 2 - Write Backend Code
Open your MainPage.xaml.cs file, replace the following code inside your ContentPage tages.
Note
In the upload function, I am using my own blob storage connection string. But you will use your own blob storage connection string. Go to Access keys inside this tab you will get two keys (key1 and key2) with also connection strings. You can use either key1 or key2. In this demo we only need the connection string, so you will only copy the connection string.
In the upload function, I am using my own blob storage connection string. But you will use your own blob storage connection string. Go to Access keys inside this tab you will get two keys (key1 and key2) with also connection strings. You can use either key1 or key2. In this demo we only need the connection string, so you will only copy the connection string.





Adeoye TemitayoPosted Aug 12, 2020, 4:23 AM
Great tutorial, its works
Mahesh BalasubramanianPosted Jun 21, 2020, 7:27 AM
I have created as= Xamarin Project to upload images to Azure Blob Storage. While I am trying to access the Blob storage from my Local Machine. I am getting the following error while calling the below methods.await container.CreateIfNotExistsAsync(); await blockBlob.UploadFromStreamAsync(stream);
satish maddiliPosted Apr 16, 2019, 2:31 AM
Using PickPhotoAsync after choose the picture nothing will happen in xamarin forms android