GithubHelp home page GithubHelp logo

brminnick / azureblobstoragesampleapp Goto Github PK

View Code? Open in Web Editor NEW
29.0 7.0 23.0 551 KB

iOS and Android app made using Xamarin.Forms that explores Azure Blob Storage

License: MIT License

C# 100.00%
xamarin xamarin-forms xamarin-android xamarin-ios azure-functions azure-sql-database azure-blob-storage sqlite

azureblobstoragesampleapp's Introduction

AzureBlobStorageSampleApp

This Xamarin app uses a SQLite Database to save the metadata of the Photos (e.g. Url, Title) locally. The local database syncs, via an Azure Function, with an Azure SQL Database that contains the metadata of the Photos stored in Azure Blob Storage.

The Xamarin app also allows the user to take photos and save them to Azure Blob Storage. To do this, the Xamarin app uploads the image to an Azure Function, and the Azure Function saves the image in Azure Blob Storage, then adds the image metadata to the Azure SQL Database.

Learn More

Azure Blob Storage Sample App Diagram

Getting Started

1. Publish The Function App to Azure

  1. In Visual Studio, right-click on AzureBlobStorageSampleApp.Functions and select Publish

  1. Choose Azure Function App -> Create New -> Publish

  1. Fill out details:
  • App Name: Pick a name for your app within Azure
  • Subscription: Select your Azure subscription
  • Resource Group: Pick a resource group or create a new one
  • Hosting Plan: Pick a name, a region close to you, and for Size I chose Consumption
  • Storage Account: Create a new one. Pick a name, for Account Type I chose: Standard - Locally Redudant Storage
  1. Click Create

  2. This will take a couple minutes to deploy; confirm its existance in the Azure portal. We're done with the Function for now, but we'll be back to grab a couple values and add a couple values to the Application Settings.

2. Create Azure SQL Database

  1. In the Azure portal, click on New -> Enter SQL Database into the Search Bar -> Select SQL Database from the search results -> Click Create

  1. Name the SQL Database
  • I named mine XamListDatabase
  1. Select the Subscription
  • I selected my Visual Studio Enterprise subscription
  • If you do not have a VS Enterprise Subscription, you will need to select a different option
  1. Select the Resource Group you published your Function in
  2. Select Blank Database

6. Select Server

  1. Select Create New Server

  2. Enter the Server Name

  3. Create a Server admin login

  • Store this password somewhere safe, because we will need to use it for our database connection later!
  1. Create a password

  2. Select the closest location

  3. Click "Select"

  4. Select "Not Now" for the SQL Elastic Pool option

14. Select Pricing Tier

  1. Select Basic
  2. Move the slider to maximum, 2GB
  • Don't worry, it's the same price for 2GB as it is for 100MB.
  1. Click Apply
  2. Click Create

3. Get SQL Database Connection String

  1. On the Azure Portal, navigate to the SQL Database we created, above
  2. Click on "Connection Strings" -> "ADO.NET"
  3. Copy the entire Connection String into a text editor

  1. In the text editor, change "{your_username}" and "{your_password}" to match the SQL Database Username / Password created above
  • Don't use my username / password because it won't work ;-)

4. Connect SQL Database to the Azure Function App

  1. On the Azure Portal, navigate to the Functions App we published from Visual Studio
  2. Select "Application Settings"
  3. In the Application Settings, scroll down to the section "Application Settings"
  4. Create a new string
  • Set the name as PhotoDatabaseConnectionString
  • Make sure to use this exact name, otherwise the source code will not work
  • Copy/paste the Azure SQL connection string from the text editor as the corresponding value
  1. Scroll up and click Save (Note! If you don't click Save - the change will not be reflected.)

5. Create a (Blob) Storage Account

  1. In the Azure portal, click on New -> Enter Storage account into the Search Bar -> Select Storage acount from the search results -> Click Create

  1. In the next screen, you'll enter a few values
  • Select the Subscription and the Resource Group you have been working in
  • Create a Storage account name (note: letters in the name need to be lowercase)
  • Choose a location
  • For Performance, I chose Standard
  • For Account king, I chose StorageV2 (general purchase v2)
  • For Access tier, chose Hot
  1. Click Review and Create

6. Create a Blob container

  1. Click into the Storage account you created.

image

  1. On the left menu, under Blob service, click Blobs

  2. Click the "+ Container" button to create a new container

  3. Use "photos" for the Name, and for the purposes of this exercise, chose Public access level: Container (anonymous read access for containers and blob)

  • In future apps, you'll likely want to increase the privacy of your blob containers

7. Connect the (Blob) Storage Account to the Azure Function App

  1. In the Storage Account, click Access Keys which are under Settings

  2. You'll see key 1 and key 2 along with a Key and Connection String for each of those. Copy either of the Connection Strings.

  1. On the Azure Portal, navigate to the Functions App we published from Visual Studio

  2. Select "Application Settings"

  3. In the Application Settings, scroll down to "Application Settings"

  4. Create a new setting

  • Set the name as BlobStorageConnectionString
  • Make sure to use this exact name, otherwise the source code will not work
  • Copy/paste the Connection setting
  1. Create another setting
  • Set the name as PhotoContainerName
  • Make sure to use this exact name, otherwise the source code will not work
  • Type photos as the corresponding value (This is the name of the container you created earlier.)
  1. Scroll up and click Save (Note! If you don't click Save - the change will not be reflected.)

8. Configure Azure Function Url & Keys for Mobile App

  1. In BackendConstants.cs, you'll need to customize the value of FunctionsAPIBaseUrl to match yours
  • Notice the URL in the upper right of the photo. You'll only need to change the subdomain to match yours (ie. it is important that the URL in code retains the /api).

azureblobstoragesampleapp's People

Contributors

andrewchungxam avatar azureadvocatebit avatar brminnick avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

azureblobstoragesampleapp's Issues

["BlobStorageConnectionString"] and ["PhotoDatabaseConnectionString"] values

Hi Brandon,
Its very useful tutorial on you tube ,and thank you for that. i am a not expert in developing xamarin shared based apps , but i have azure blob-storage account and wanted to go head with your project to test, but its not clear for me where should i declare the values of ["BlobStorageConnectionString"] and ["PhotoDatabaseConnectionString"] , because i don't see the app.settings in your solution, please advice, thank you.
Pan

Android version not working.

Describe the bug
The Android version in this project doesn't work.
To Reproduce
Steps to reproduce the behavior:

  1. Go to 'git client'
  2. Clone the code.
  3. Set the values for Azure tenant id and client id
  4. Build the project.
  5. Set startup to Android project.

Expected behavior
The project should run in the Android Emulator.

Screenshots

Desktop (please complete the following information):

  • OS: Windows 10 Pro
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: Android Emulator Pixel 4
  • OS: Api 30: 5554

Additional context
When the project is run, it throws the following message in the output window.


1>------ Skipped Deploy: Project: AzureBlobStorageSampleApp.Android, Configuration: Debug Any CPU ------
1>Project not selected to build for this solution configuration 
========== Deploy: 0 succeeded, 0 failed, 1 skipped ==========

Rightclick to publish function brings up a different screen.

Describe the bug
I am not getting the correct screen when I right-click the AzureBlobStorageSampleApp.Functions project.

To Reproduce
Steps to reproduce the behavior:

  1. Clone sample from git using git clone
  2. Open solution in visual studio 2019
  3. Right click AzureBlobStorageSample.Functions and click on Publish option.
  4. See error

Expected behavior
I expect the publish screen to get displayed.

Screenshots
PublishAzureFunctionError

Desktop (please complete the following information):

  • OS: [e.g. iOS]

  • Browser [e.g. chrome, safari]

  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: Laptop
  • OS: Windows 10 Pro
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Specified argument was out of the range of valid values. Parameter name: index

Hi Brandon,

Thank you for this bringing this great work to life of combining blob storage and structured database storage connecting all things Xamarin and Azure together.

I am attempting to run the app on my android emulator and device and receiving the error message on the OnSavePhotoFailed in the AddPhotoViewModel. I am hopeful that I have just done something wrong and its not an issue with your code. The message I receive is:
Specified argument was out of the range of valid values. Parameter name: index

Any thoughts you can provide on how I might resolve. Thanks.

Jim

list view doesn't show thumbnails for IOS (emulators or physical device)

on iOS, the list page doesn't show thumbnails, I cannot get this to work on

  1. any emulator - iphone 8, 11, 11 pro,
  2. my iphone (iphone 11 pro max
    the code i am using does work on android emulators and shows thumbnails.

see photos of ios and of android.

IOS:
Screen Shot 2020-01-18 at 7 29 45 PM

ANDROID
Screen Shot 2020-01-18 at 7 31 15 PM

I have latest updated everything here:

=== Visual Studio Community 2019 for Mac (Preview) ===

Version 8.5 Preview (8.5 build 1543)
Installation UUID: 95d11c0e-8fa5-4131-82b1-02b54fa28259
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 6.14.1.17 (d16-5 / d30880059)

Package version: 608000087

=== Mono Framework MDK ===

Runtime:
Mono 6.8.0.87 (2019-10/df42020fe6f) (64-bit)
Package version: 608000087

=== Roslyn (Language Service) ===

3.4.0-beta4-19568-04+82f2e2541478e239dc4b04f231e90dc2b3dcb422

=== NuGet ===

Version: 5.3.0.6192

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.1.100/Sdks
SDK Versions:
3.1.100
3.0.101
3.0.100
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.8.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
3.1.0
3.0.1
3.0.0
2.1.14
2.1.13

=== Xamarin.Profiler ===

Version: 1.6.12.26
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 11.3 (15712)
Build 11C504

=== Xamarin.Mac ===

Version: 6.14.1.17 (Visual Studio Community)
Hash: d30880059
Branch: d16-5
Build date: 2020-01-07 18:20:41-0500

=== Xamarin.iOS ===

Version: 13.14.1.17 (Visual Studio Community)
Hash: d30880059
Branch: d16-5
Build date: 2020-01-07 18:20:41-0500

=== Xamarin Designer ===

Version: 16.5.0.382
Hash: c3bbd0524
Branch: remotes/origin/d16-5
Build date: 2019-12-30 21:46:42 UTC

=== Xamarin.Android ===

Version: 10.2.0.84 (Visual Studio Community)
Commit: xamarin-android/d16-5/ac3f71f
Android SDK: /Users/lucaskrause/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.5
SDK Build Tools Version: 28.0.3

Build Information:
Mono: df42020
Java.Interop: xamarin/java.interop/d16-5@c0cc770
ProGuard: xamarin/proguard@905836d
SQLite: xamarin/sqlite@46204c4
Xamarin.Android Tools: xamarin/xamarin-android-tools/master@9f4ed4b

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/lucaskrause/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.5.0.28
Hash: 2697505
Branch: remotes/origin/d16-5
Build date: 2019-12-18 17:36:18 UTC

=== Android Device Manager ===

Version: 16.5.0.36
Hash: 1ea9748
Branch: remotes/origin/d16-5
Build date: 2019-12-18 17:36:40 UTC

=== Xamarin Inspector ===

Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 805001543
Git revision: c91d9639b1c8c8dff574f5c4fd46bca48dbfd21f
Build date: 2020-01-09 16:05:44-05
Build branch: release-8.5
Xamarin extensions: e97f3dddaff6b0ffa19fc7e2c512f70ac79226a4

=== Operating System ===

Mac OS X 10.15.2
Darwin 19.2.0 Darwin Kernel Version 19.2.0
Sat Nov 9 03:47:04 PST 2019
root:xnu-6153.61.1~20/RELEASE_X86_64 x86_64

IOS version missing functionality on android version.

Issue 1 - When you take a picture on ios (physical device), you can't take photos on emulators for ios, and save it, it then redirects back to the list page, but this page doesn't refresh.

Issue 2 - When you view photo-list, it doesn't show thumbnails like on android version.

crash when navigating from detail screen to list screen

I get this exception in debugger when navigating back from detail of photo the the list view.

machine info:

Visual Studio Community 2019 for Mac (Preview)
Version 8.5 Preview (8.5 build 1543)
Installation UUID: 95d11c0e-8fa5-4131-82b1-02b54fa28259
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 6.14.1.17 (d16-5 / d30880059)

Package version: 608000087

Mono Framework MDK
Runtime:
Mono 6.8.0.87 (2019-10/df42020fe6f) (64-bit)
Package version: 608000087

Roslyn (Language Service)
3.4.0-beta4-19568-04+82f2e2541478e239dc4b04f231e90dc2b3dcb422

NuGet
Version: 5.3.0.6192

.NET Core SDK
SDK: /usr/local/share/dotnet/sdk/3.1.100/Sdks
SDK Versions:
3.1.100
3.0.101
3.0.100
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.8.0/lib/mono/msbuild/Current/bin/Sdks

.NET Core Runtime
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
3.1.0
3.0.1
3.0.0
2.1.14
2.1.13

Xamarin.Profiler
Version: 1.6.12.26
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Apple Developer Tools
Xcode 11.3 (15712)
Build 11C504

Xamarin.Mac
Version: 6.14.1.17 (Visual Studio Community)
Hash: d30880059
Branch: d16-5
Build date: 2020-01-07 18:20:41-0500

Xamarin.iOS
Version: 13.14.1.17 (Visual Studio Community)
Hash: d30880059
Branch: d16-5
Build date: 2020-01-07 18:20:41-0500

Xamarin Designer
Version: 16.5.0.382
Hash: c3bbd0524
Branch: remotes/origin/d16-5
Build date: 2019-12-30 21:46:42 UTC

Xamarin.Android
Version: 10.2.0.84 (Visual Studio Community)
Commit: xamarin-android/d16-5/ac3f71f
Android SDK: /Users/lucaskrause/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 28.0.2
SDK Build Tools Version: 28.0.3

Build Information:
Mono: df42020
Java.Interop: xamarin/java.interop/d16-5@c0cc770
ProGuard: xamarin/proguard@905836d
SQLite: xamarin/sqlite@46204c4
Xamarin.Android Tools: xamarin/xamarin-android-tools/master@9f4ed4b

Microsoft Mobile OpenJDK
Java SDK: /Users/lucaskrause/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 16.5.0.28
Hash: 2697505
Branch: remotes/origin/d16-5
Build date: 2019-12-18 17:36:18 UTC

Android Device Manager
Version: 16.5.0.36
Hash: 1ea9748
Branch: remotes/origin/d16-5
Build date: 2019-12-18 17:36:40 UTC

Xamarin Inspector
Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

Build Information
Release ID: 805001543
Git revision: c91d9639b1c8c8dff574f5c4fd46bca48dbfd21f
Build date: 2020-01-09 16:05:44-05
Build branch: release-8.5
Xamarin extensions: e97f3dddaff6b0ffa19fc7e2c512f70ac79226a4

Operating System
Mac OS X 10.15.2
Darwin 19.2.0 Darwin Kernel Version 19.2.0
Sat Nov 9 03:47:04 PST 2019
root:xnu-6153.61.1~20/RELEASE_X86_64 x86_64

exception in base libraries:

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.Generic.List1[T].get_Item (System.Int32 index) [0x00009] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/List.cs:161 at System.Collections.ObjectModel.Collection1[T].System.Collections.IList.get_Item (System.Int32 index) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:266
at Xamarin.Forms.Platform.iOS.ObservableItemsSource.ElementAt (System.Int32 index) [0x0000f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:264
at Xamarin.Forms.Platform.iOS.ObservableItemsSource.get_Item (System.Int32 index) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:35
at Xamarin.Forms.Platform.iOS.ObservableItemsSource.get_Item (Foundation.NSIndexPath indexPath) [0x00019] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:91
at Xamarin.Forms.Platform.iOS.ItemsViewController1[TItemsView].UpdateTemplatedCell (Xamarin.Forms.Platform.iOS.TemplatedCell cell, Foundation.NSIndexPath indexPath) [0x00012] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:199 at Xamarin.Forms.Platform.iOS.ItemsViewController1[TItemsView].GetCell (UIKit.UICollectionView collectionView, Foundation.NSIndexPath indexPath) [0x0003b] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:84
at at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr(intptr,intptr,intptr,intptr)
at UIKit.UICollectionView.PerformBatchUpdates (System.Action updates, UIKit.UICompletionHandler completed) [0x00055] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.14.1.17/src/Xamarin.iOS/UICollectionView.g.cs:568
at Xamarin.Forms.Platform.iOS.ObservableItemsSource.Add (System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x000a5] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:177
at Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x00023] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:112
at Xamarin.Forms.Platform.iOS.ObservableItemsSource+<>c__DisplayClass24_0.b__0 () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:99
at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.14.1.17/src/Xamarin.iOS/Foundation/NSAction.cs:152
at at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.14.1.17/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.14.1.17/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at AzureBlobStorageSampleApp.iOS.Application.Main (System.String[] args) [0x00000] in /Users/lucaskrause/DeanElmer/AzureBlobStorageSampleApp/AzureBlobStorageSampleApp.iOS/Main.cs:7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.