I recently started working on a Xamarin.Forms project, where I need to use Azure Blob Storage to host pictures taken from a mobile device’s camera. Along the way, I came across several great tutorials illustrating how to take advantage of blob storage, but they were all missing one key part: I couldn’t use this namespace:
That storage namespace kept coming up missing. Bizarre, considering I knew I had the NuGet package installed. After 2 days of searching, I finally resolved it. Hopefully this help you. Let me know if you have an alternative means to get this to work.
Changing the profile & retargeting the PCL
After installing these NuGet packages, you actually need to change the profile on your Xamarin project. You can do this by going to the shared project -> Options -> General – > C#
- Change the Current Profile to PCL 4.5 – Profile111
- (I have no idea of what this does.)
- You need to retarget your NuGet packages for this new profile now.
- Right click on Packages within the shared project, and you’ll have 5 options here.
- Retarget will be available. Click that. (Not shown here, as I’ve already retargeted)
- Rebuild your project
How I figured this out
I stumbled across this Xamarin forum post, where someone had the exact same issue. One user pointed us towards a bug report, where PCL references were not added automatically via NuGet package installation. They recommended retargeting, and it worked! Now I can include the using Microsoft.WindowsAzure.Storage.Blob; namespace.
- Azure Mobile Services Companion app
- This sample adds support for images to the Mobile Apps todo list quickstart.
- What is a shared access signature? -pt 1
- Overview & best practices
- Use blob storage for Xamarin (preview)
- I can’t seem to do this on OSX, so I generated the SAS token on Windows.
- You then get two keys – primary and secondary. Specify either. You have two so you can give one out to someone (such as giving the secondary key to a 3rd-party monitoring company) and revoke it by changing the key, without impacting you (assuming you’re using the primary key for yourself).
- This is also a great sample to start with
- Also can generate SAS tokens for you