SlideShare une entreprise Scribd logo
1  sur  8
Télécharger pour lire hors ligne
UWP WITH MICROSOFT AZURE
BY ENG SOON CHEAH
1
UWP WITH MICROSOFT AZURE
UWP with Microsoft Azure
STORE IMAGE AND RETRIEVE IMAGE BY USING BLOB STORAGE
Pre-Requirement
1. Install Visual Studio 2015
2. Install Azure SDK
3. Microsoft Azure Account
Let Start to Code!
Click the NEW > DATA SERVICES > STORAGE > QUICK CREATE > fill in the information > Create storage
Account
2
UWP WITH MICROSOFT AZURE
After the account is created you will find the dashboard.
To access azure storage we have a storage account name and access keys.
Click on manage access keys at the bottom and you will find them as below.
We will now create a Windows UWP with the following UI. Add mobile services and azure storage
nuget package foe the app.
<Button x:Name="button" Content="Select Picture" HorizontalAlignment="Left" Margin="65,77,0,0"
VerticalAlignment="Top" Height="68" Width="221" Click="SelectPic_clicked" FontSize="26.667"/>
<Image x:Name="image" HorizontalAlignment="Left" Height="240" Margin="65,256,0,0"
VerticalAlignment="Top" Width="335"/>
3
UWP WITH MICROSOFT AZURE
In the button click event paste the following code,
private async void SelectPic_clicked(object sender, RoutedEventArgs e)
{
try
{
FileOpenPicker fop = new FileOpenPicker();
fop.FileTypeFilter.Add(".jpg");
fop.FileTypeFilter.Add(".jpeg");
fop.FileTypeFilter.Add(".png");
fop.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
StorageFile sf = await fop.PickSingleFileAsync();
IRandomAccessStream str = await sf.OpenAsync(FileAccessMode.Read);
CloudStorageAccount account;
CloudBlobClient blobClient;
CloudBlobContainer container;
account = new CloudStorageAccount(new StorageCredentials("Insert your account name", "Insert
your key"), true);
blobClient = account.CreateCloudBlobClient();
container = blobClient.GetContainerReference("pictures");
await container.CreateIfNotExistsAsync();
BlobContainerPermissions per = new BlobContainerPermissions();
per.PublicAccess = BlobContainerPublicAccessType.Blob;
await container.SetPermissionsAsync(per);
CloudBlockBlob blob = container.GetBlockBlobReference(sf.Name);
await blob.UploadFromFileAsync(sf);
BitmapImage bmp = new BitmapImage();
bmp.UriSource = blob.Uri;
BlobData imageData = new BlobData
{
imageUrl = blob.Uri.ToString(),
name = sf.Name
};
4
UWP WITH MICROSOFT AZURE
await App.MobileService.GetTable<BlobData>().InsertAsync(imageData);
var m1 = new MessageDialog("Image Uploaded").ShowAsync();
image.Source = bmp;
}
catch(Exception ex)
{
var m2 = new MessageDialog(ex.ToString()).ShowAsync();
}
In the above code I have used FileOpenPicker to select an image. And used Mobile service to store
blob name and url once uploaded.
Use your account name and account key. I have used the following code for class.
To retrieve images from the blob storage, I used mobile services to store the information. Use the
following code to make the UI.
Add the following is the c# code for retrieval of images.
public class BlobData
{
public string id { get; set; }
public string name { get; set; }
public string imageUrl { get;
set; }
}
<Button x:Name="button1" Content="Download Images" HorizontalAlignment="Left"
Margin="618,64,0,0" VerticalAlignment="Top" Height="81" Width="259" FontSize="26.667"
Click="Download_clicked"/>
<ListView x:Name="ImageList" HorizontalAlignment="Left" Height="483" Margin="659,184,0,0"
VerticalAlignment="Top" Width="496">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding name}" />
<Image Height="120" Width="150" Source="{Binding imageUrl}"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
List<BlobData> allImages = await
App.MobileService.GetTable<BlobData>().ToListAsync();
ImageList.ItemsSource = allImages;
5
UWP WITH MICROSOFT AZURE
Screenshot 1
Screenshot 2
Screenshot 3
6
UWP WITH MICROSOFT AZURE
Screenshot 4
Screenshot 5
7
UWP WITH MICROSOFT AZURE
References:
1. How to operate Azure Blob and Table Storage in Windows Store apps
https://code.msdn.microsoft.com/windowsapps/How-to-use-Windows-Azure-b3447051
2. Universal Windows Platform (UWP) App Development
https://channel9.msdn.com/Series/Windows-10-development-for-absolute-beginners

Contenu connexe

En vedette

67+68 M5C2 Lezione 5. dalla scuola del curricolo alla scuola dei piani di stu...
67+68 M5C2 Lezione 5. dalla scuola del curricolo alla scuola dei piani di stu...67+68 M5C2 Lezione 5. dalla scuola del curricolo alla scuola dei piani di stu...
67+68 M5C2 Lezione 5. dalla scuola del curricolo alla scuola dei piani di stu...raffaelebruno1
 
Using git in visual studio 2015
Using git in visual studio 2015Using git in visual studio 2015
Using git in visual studio 2015Cheah Eng Soon
 
67+68 M5C3 Lezione 5. il diritto all integrazione scolastica
67+68 M5C3 Lezione 5. il diritto all integrazione scolastica67+68 M5C3 Lezione 5. il diritto all integrazione scolastica
67+68 M5C3 Lezione 5. il diritto all integrazione scolasticaraffaelebruno1
 
Дайджест вакансий второй площадки ИТ-парка в г. Набережные Челны май 2013
Дайджест вакансий второй площадки ИТ-парка в г. Набережные Челны май 2013Дайджест вакансий второй площадки ИТ-парка в г. Набережные Челны май 2013
Дайджест вакансий второй площадки ИТ-парка в г. Набережные Челны май 2013itpark-kazan
 
Presentacion general supension plus 2015 2015 01 06
Presentacion general supension plus 2015 2015 01 06Presentacion general supension plus 2015 2015 01 06
Presentacion general supension plus 2015 2015 01 06Cano Asesor
 
2nd batxillerat general information
2nd batxillerat general information2nd batxillerat general information
2nd batxillerat general informationAmalio_Arnandis
 

En vedette (9)

67+68 M5C2 Lezione 5. dalla scuola del curricolo alla scuola dei piani di stu...
67+68 M5C2 Lezione 5. dalla scuola del curricolo alla scuola dei piani di stu...67+68 M5C2 Lezione 5. dalla scuola del curricolo alla scuola dei piani di stu...
67+68 M5C2 Lezione 5. dalla scuola del curricolo alla scuola dei piani di stu...
 
Using git in visual studio 2015
Using git in visual studio 2015Using git in visual studio 2015
Using git in visual studio 2015
 
Latest
LatestLatest
Latest
 
De donde vienen las ideas
De donde vienen las ideasDe donde vienen las ideas
De donde vienen las ideas
 
67+68 M5C3 Lezione 5. il diritto all integrazione scolastica
67+68 M5C3 Lezione 5. il diritto all integrazione scolastica67+68 M5C3 Lezione 5. il diritto all integrazione scolastica
67+68 M5C3 Lezione 5. il diritto all integrazione scolastica
 
Дайджест вакансий второй площадки ИТ-парка в г. Набережные Челны май 2013
Дайджест вакансий второй площадки ИТ-парка в г. Набережные Челны май 2013Дайджест вакансий второй площадки ИТ-парка в г. Набережные Челны май 2013
Дайджест вакансий второй площадки ИТ-парка в г. Набережные Челны май 2013
 
新土俵戦略2012
新土俵戦略2012新土俵戦略2012
新土俵戦略2012
 
Presentacion general supension plus 2015 2015 01 06
Presentacion general supension plus 2015 2015 01 06Presentacion general supension plus 2015 2015 01 06
Presentacion general supension plus 2015 2015 01 06
 
2nd batxillerat general information
2nd batxillerat general information2nd batxillerat general information
2nd batxillerat general information
 

Plus de Cheah Eng Soon

Microsoft Defender for Endpoint
Microsoft Defender for EndpointMicrosoft Defender for Endpoint
Microsoft Defender for EndpointCheah Eng Soon
 
Azure Active Directory - Secure and Govern
Azure Active Directory - Secure and GovernAzure Active Directory - Secure and Govern
Azure Active Directory - Secure and GovernCheah Eng Soon
 
MEM for OnPrem Environments
MEM for OnPrem EnvironmentsMEM for OnPrem Environments
MEM for OnPrem EnvironmentsCheah Eng Soon
 
Microsoft Threat Protection Automated Incident Response
Microsoft Threat Protection Automated Incident Response Microsoft Threat Protection Automated Incident Response
Microsoft Threat Protection Automated Incident Response Cheah Eng Soon
 
Azure Penetration Testing
Azure Penetration TestingAzure Penetration Testing
Azure Penetration TestingCheah Eng Soon
 
Azure Penetration Testing
Azure Penetration TestingAzure Penetration Testing
Azure Penetration TestingCheah Eng Soon
 
Penetration Testing Azure for Ethical Hackers
Penetration Testing Azure for Ethical HackersPenetration Testing Azure for Ethical Hackers
Penetration Testing Azure for Ethical HackersCheah Eng Soon
 
Microsoft Threat Protection Automated Incident Response Demo
Microsoft Threat Protection Automated Incident Response DemoMicrosoft Threat Protection Automated Incident Response Demo
Microsoft Threat Protection Automated Incident Response DemoCheah Eng Soon
 
Microsoft Secure Score Demo
Microsoft Secure Score DemoMicrosoft Secure Score Demo
Microsoft Secure Score DemoCheah Eng Soon
 
Microsoft Cloud App Security Demo
Microsoft Cloud App Security DemoMicrosoft Cloud App Security Demo
Microsoft Cloud App Security DemoCheah Eng Soon
 
M365 Attack Simulation Demo
M365 Attack Simulation DemoM365 Attack Simulation Demo
M365 Attack Simulation DemoCheah Eng Soon
 
Azure Active Directory - External Identities Demo
Azure Active Directory - External Identities Demo Azure Active Directory - External Identities Demo
Azure Active Directory - External Identities Demo Cheah Eng Soon
 
Azure Weekend 2020 Build Malaysia Bus Uncle Chatbot
Azure Weekend 2020 Build Malaysia Bus Uncle ChatbotAzure Weekend 2020 Build Malaysia Bus Uncle Chatbot
Azure Weekend 2020 Build Malaysia Bus Uncle ChatbotCheah Eng Soon
 
Microsoft Azure的20大常见安全漏洞与配置错误
Microsoft Azure的20大常见安全漏洞与配置错误Microsoft Azure的20大常见安全漏洞与配置错误
Microsoft Azure的20大常见安全漏洞与配置错误Cheah Eng Soon
 
20 common security vulnerabilities and misconfiguration in Azure
20 common security vulnerabilities and misconfiguration in Azure20 common security vulnerabilities and misconfiguration in Azure
20 common security vulnerabilities and misconfiguration in AzureCheah Eng Soon
 
Integrate Microsoft Graph with Azure Bot Services
Integrate Microsoft Graph with Azure Bot ServicesIntegrate Microsoft Graph with Azure Bot Services
Integrate Microsoft Graph with Azure Bot ServicesCheah Eng Soon
 
Azure Sentinel with Office 365
Azure Sentinel with Office 365Azure Sentinel with Office 365
Azure Sentinel with Office 365Cheah Eng Soon
 

Plus de Cheah Eng Soon (20)

Microsoft Defender for Endpoint
Microsoft Defender for EndpointMicrosoft Defender for Endpoint
Microsoft Defender for Endpoint
 
Azure Active Directory - Secure and Govern
Azure Active Directory - Secure and GovernAzure Active Directory - Secure and Govern
Azure Active Directory - Secure and Govern
 
Microsoft Zero Trust
Microsoft Zero TrustMicrosoft Zero Trust
Microsoft Zero Trust
 
MEM for OnPrem Environments
MEM for OnPrem EnvironmentsMEM for OnPrem Environments
MEM for OnPrem Environments
 
Microsoft Threat Protection Automated Incident Response
Microsoft Threat Protection Automated Incident Response Microsoft Threat Protection Automated Incident Response
Microsoft Threat Protection Automated Incident Response
 
Azure Penetration Testing
Azure Penetration TestingAzure Penetration Testing
Azure Penetration Testing
 
Azure Penetration Testing
Azure Penetration TestingAzure Penetration Testing
Azure Penetration Testing
 
Penetration Testing Azure for Ethical Hackers
Penetration Testing Azure for Ethical HackersPenetration Testing Azure for Ethical Hackers
Penetration Testing Azure for Ethical Hackers
 
Microsoft Threat Protection Automated Incident Response Demo
Microsoft Threat Protection Automated Incident Response DemoMicrosoft Threat Protection Automated Incident Response Demo
Microsoft Threat Protection Automated Incident Response Demo
 
Microsoft Secure Score Demo
Microsoft Secure Score DemoMicrosoft Secure Score Demo
Microsoft Secure Score Demo
 
Microsoft Cloud App Security Demo
Microsoft Cloud App Security DemoMicrosoft Cloud App Security Demo
Microsoft Cloud App Security Demo
 
M365 Attack Simulation Demo
M365 Attack Simulation DemoM365 Attack Simulation Demo
M365 Attack Simulation Demo
 
Cloud Security Demo
Cloud Security DemoCloud Security Demo
Cloud Security Demo
 
Azure Active Directory - External Identities Demo
Azure Active Directory - External Identities Demo Azure Active Directory - External Identities Demo
Azure Active Directory - External Identities Demo
 
Azure WAF
Azure WAFAzure WAF
Azure WAF
 
Azure Weekend 2020 Build Malaysia Bus Uncle Chatbot
Azure Weekend 2020 Build Malaysia Bus Uncle ChatbotAzure Weekend 2020 Build Malaysia Bus Uncle Chatbot
Azure Weekend 2020 Build Malaysia Bus Uncle Chatbot
 
Microsoft Azure的20大常见安全漏洞与配置错误
Microsoft Azure的20大常见安全漏洞与配置错误Microsoft Azure的20大常见安全漏洞与配置错误
Microsoft Azure的20大常见安全漏洞与配置错误
 
20 common security vulnerabilities and misconfiguration in Azure
20 common security vulnerabilities and misconfiguration in Azure20 common security vulnerabilities and misconfiguration in Azure
20 common security vulnerabilities and misconfiguration in Azure
 
Integrate Microsoft Graph with Azure Bot Services
Integrate Microsoft Graph with Azure Bot ServicesIntegrate Microsoft Graph with Azure Bot Services
Integrate Microsoft Graph with Azure Bot Services
 
Azure Sentinel with Office 365
Azure Sentinel with Office 365Azure Sentinel with Office 365
Azure Sentinel with Office 365
 

Dernier

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Dernier (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

UWP with Microsoft Azure

  • 1. UWP WITH MICROSOFT AZURE BY ENG SOON CHEAH
  • 2. 1 UWP WITH MICROSOFT AZURE UWP with Microsoft Azure STORE IMAGE AND RETRIEVE IMAGE BY USING BLOB STORAGE Pre-Requirement 1. Install Visual Studio 2015 2. Install Azure SDK 3. Microsoft Azure Account Let Start to Code! Click the NEW > DATA SERVICES > STORAGE > QUICK CREATE > fill in the information > Create storage Account
  • 3. 2 UWP WITH MICROSOFT AZURE After the account is created you will find the dashboard. To access azure storage we have a storage account name and access keys. Click on manage access keys at the bottom and you will find them as below. We will now create a Windows UWP with the following UI. Add mobile services and azure storage nuget package foe the app. <Button x:Name="button" Content="Select Picture" HorizontalAlignment="Left" Margin="65,77,0,0" VerticalAlignment="Top" Height="68" Width="221" Click="SelectPic_clicked" FontSize="26.667"/> <Image x:Name="image" HorizontalAlignment="Left" Height="240" Margin="65,256,0,0" VerticalAlignment="Top" Width="335"/>
  • 4. 3 UWP WITH MICROSOFT AZURE In the button click event paste the following code, private async void SelectPic_clicked(object sender, RoutedEventArgs e) { try { FileOpenPicker fop = new FileOpenPicker(); fop.FileTypeFilter.Add(".jpg"); fop.FileTypeFilter.Add(".jpeg"); fop.FileTypeFilter.Add(".png"); fop.SuggestedStartLocation = PickerLocationId.PicturesLibrary; StorageFile sf = await fop.PickSingleFileAsync(); IRandomAccessStream str = await sf.OpenAsync(FileAccessMode.Read); CloudStorageAccount account; CloudBlobClient blobClient; CloudBlobContainer container; account = new CloudStorageAccount(new StorageCredentials("Insert your account name", "Insert your key"), true); blobClient = account.CreateCloudBlobClient(); container = blobClient.GetContainerReference("pictures"); await container.CreateIfNotExistsAsync(); BlobContainerPermissions per = new BlobContainerPermissions(); per.PublicAccess = BlobContainerPublicAccessType.Blob; await container.SetPermissionsAsync(per); CloudBlockBlob blob = container.GetBlockBlobReference(sf.Name); await blob.UploadFromFileAsync(sf); BitmapImage bmp = new BitmapImage(); bmp.UriSource = blob.Uri; BlobData imageData = new BlobData { imageUrl = blob.Uri.ToString(), name = sf.Name };
  • 5. 4 UWP WITH MICROSOFT AZURE await App.MobileService.GetTable<BlobData>().InsertAsync(imageData); var m1 = new MessageDialog("Image Uploaded").ShowAsync(); image.Source = bmp; } catch(Exception ex) { var m2 = new MessageDialog(ex.ToString()).ShowAsync(); } In the above code I have used FileOpenPicker to select an image. And used Mobile service to store blob name and url once uploaded. Use your account name and account key. I have used the following code for class. To retrieve images from the blob storage, I used mobile services to store the information. Use the following code to make the UI. Add the following is the c# code for retrieval of images. public class BlobData { public string id { get; set; } public string name { get; set; } public string imageUrl { get; set; } } <Button x:Name="button1" Content="Download Images" HorizontalAlignment="Left" Margin="618,64,0,0" VerticalAlignment="Top" Height="81" Width="259" FontSize="26.667" Click="Download_clicked"/> <ListView x:Name="ImageList" HorizontalAlignment="Left" Height="483" Margin="659,184,0,0" VerticalAlignment="Top" Width="496"> <ListView.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding name}" /> <Image Height="120" Width="150" Source="{Binding imageUrl}"/> </StackPanel> </DataTemplate> </ListView.ItemTemplate> </ListView> List<BlobData> allImages = await App.MobileService.GetTable<BlobData>().ToListAsync(); ImageList.ItemsSource = allImages;
  • 6. 5 UWP WITH MICROSOFT AZURE Screenshot 1 Screenshot 2 Screenshot 3
  • 7. 6 UWP WITH MICROSOFT AZURE Screenshot 4 Screenshot 5
  • 8. 7 UWP WITH MICROSOFT AZURE References: 1. How to operate Azure Blob and Table Storage in Windows Store apps https://code.msdn.microsoft.com/windowsapps/How-to-use-Windows-Azure-b3447051 2. Universal Windows Platform (UWP) App Development https://channel9.msdn.com/Series/Windows-10-development-for-absolute-beginners