Xamarin.Forms PCL (not shared) app + photos + Azure Blob Storage = ???

faceoffers28faceoffers28 USUniversity ✭✭✭
edited January 2016 in Xamarin.Forms

OK, after weeks of researching, reading and trying all sorts of methods, I've come to the conclusion that I'm going to have to use the HTTP Client to interface with the Azure Blob Storage REST API. This is not ideal as I would like to work with a method that requests the keys from Azure Mobile Services, but I digress. My app works with images either taken by the camera or selected from the gallery. My current profile is PCL 4.5 Profile 7. I believe this is the leanest profile I can work with. I've given up on trying to support Windows Phone 8.1, which is a shame because that happens to be my primary phone. :) My current test device is a Samsung Galaxy 3, running version 19 of the Android API.

I've tried working with the Preview versions of WindowsAzure.Storage, but I can't get the using statements to resolve. I assume it has something to do with my PCL Profile. Since so many of the tutorials use the WindowsAzure.Storage client this is not an option, unless someone has any ideas.

I've tried working with Azure Mobile Services as well. My thought was that I could at least retrieve the storage keys as I've seen done in some tutorials, but that won't work either. The service installs and the using statements and code resolve, but the app hangs when the client is called. I am using Xamarin Insights to capture and report errors. From what I can tell the .ext.dll portion of Azure Mobile Services is missing. I guess I could also call the Azure Mobile Services API using the HTTP Client, but from what I've read, the authentication piece is somewhat difficult. I will still try this method as I will most assuredly learn something new.

I'm waiting to hear back from the folks who make this component, but I just realized/learned today that components don't install into PCL projects, so that's not going to work, either. I've been under the impression ever since I started working with Xamarin that components would work with my project.

https://components.xamarin.com/view/DataNuage.Azure.Blob

I've only been developing for less than a year and working with Xamarin for a little over 6 months. Hopefully, this will start a good discussion and perhaps help someone else who is having the same problems.

If anyone has any suggestions, I'm all ears. In the meantime, I've started working with the Blob Storage Rest API tutorials that I've found, but the authentication appears to be a bit tricky. There's also not as much out there, but I'm willing to try and learn in the process. I'm also considering building an Web API to handle image uploads and insertion into Azure Blob Storage.

Hope this helps.

Posts

  • EdwardBakkerEdwardBakker NLMember

    Hi,

    The Azure Storage library (preview) does work with Xamarin Forms. You have to switch the profile of your PCL project to "Profile259" (you can do this manually in the project file). We have a few apps (also WinPhone 8.1) that work against Azure Table and Blob storage without any issues...

    Edward

  • faceoffers28faceoffers28 USUniversity ✭✭✭

    @EdwardBakker Thanks ever so much for the help. I just switched to Profile259 and received some re-targeting warnings. I was able to re-target everything except Xamarin Forms Labs. Since I use the MediaPicker for my camera functionality, this is a must have. :)

    Could not install package 'Xamarin.Forms.Labs 1.0.1.5'. You are trying to install this package into a project that targets 'portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

    Are there any other profiles I should use or is there a workaround for this?

    Thanks again!

  • faceoffers28faceoffers28 USUniversity ✭✭✭
    edited January 2016

    @EdwardBakker Perhaps I need to upgrade to the refactored code base. http://forums.xamarin.com/discussion/32278/upgrading-xamarin-forms-labs-to-xlabs-forms

    I was always confused between Xamarin.Forms.Labs and XLabs. Now I know why. Hopefully, I can easily switch, but I have no idea how hard or easy that will be.

    Funny, I was using these using statements in different parts of my app and didn't understand the difference between them.

    //using Xamarin.Forms.Labs.Services.Media;
    using XLabs.Platform.Services.Media;

    I still can't get the WindowsAzure.Storage client to work, though. Even though I am now running Profile259, the using statements still won't resolve. This post by Matt Ward seems to confirm it. https://forums.xamarin.com/discussion/30500/unable-to-use-added-package-microsoft-windowsazure-storage

    I've tried 6.1.1 Preview and 3.2.0 Preview. These are the only Preview packages available to me in Xamarin Studio. If I need to install a particular version that I don't have I have to use the Package Manager Console in Visual Studio 2013.

    This so confusing!!! I can't help but laugh.

  • EdwardBakkerEdwardBakker NLMember

    Hi,

    I just checked and I am using 6.2.2 preview... You can also try profile 7, this should work also for Azure Storage (not sure for all your other dependencies.

    Edward

  • faceoffers28faceoffers28 USUniversity ✭✭✭

    @EdwardBakker It seems that this is a Nuget issue. I have to reference the DLL manually as shown here. https://github.com/Azure/azure-storage-net/issues/136

    Here is a screen shot of what that looks like. I have not tested to see if this works, but the using statements now render correctly.

    Thanks for your help with this.

  • faceoffers28faceoffers28 USUniversity ✭✭✭
    edited January 2016

    OK, this is getting even better. I went ahead and downloaded the sample app provided in this Azure tutorial.

    https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-xamarin-forms-get-started/

    I simply could not figure out how to get Azure Mobile Services to work. Now that I know that the target Profile is actually 259, this is starting to make sense.

    It appears that in order to get Azure Mobile Services to work with Xamarin.Forms, you have to use the Azure Mobile Client instead of Azure Mobile Services.

    Azure Mobile Client
    https://www.nuget.org/packages/Microsoft.Azure.Mobile.Client/2.0.0

    Azure Mobile Services
    https://www.nuget.org/packages/WindowsAzure.MobileServices/

    The attached screen shot clearly shows the Azure Mobile Client working with the Xamarin.Forms 259 Profile.

    Hope this helps. This has been so confusing, but I'm glad that I really took the time to understand all the underlying concepts and associated technology. This is much more difficult than it needs to be. :)

  • faceoffers28faceoffers28 USUniversity ✭✭✭

    Here is the correct screen for the post indicated above.

  • faceoffers28faceoffers28 USUniversity ✭✭✭

    This just keeps on getting better. I added the Azure Mobile Client to my Android project as well. I had to do this because I was still encountering an error that stated I was missing the Ext.DLL. Once installed, the Droid versions of the DLL and the Ext.DLL were automatically referenced. Azure Mobile Services is now working in my Xamarin.Forms PCL Project. See attached screen shot for more information.

Sign In or Register to comment.