I upgraded Azure Storage to version 2.0 from 1.7 and I've found a number of differences when using storage. I thought how I'd document how I upgraded these more awkward bits of Azure Storage in version 2.0.
DownloadByteArray has gone missing
For whatever reason DownloadByteArray has been taken from me. So has DownloadToFile, DownloadText, UploadFromFile, UploadByteArray, and UploadText
Without too much whinging I'm just going to get on and fix it. This is what was working PERFECTLY FINE in v1.7:
public byte[] GetBytes(string fileName) { var blob = Container.GetBlobReference(fileName); return blob.DownloadByteArray(); }
And here is the code modified to account for the face that DownloadByteArray no longer exists in Azure Storage v2.0:
public byte[] GetBytes(string fileName) { var blob = Container.GetBlockBlobReference(fileName); using (var ms = new MemoryStream()) { blob.DownloadToStream(ms); ms.Position = 0; return ms.ToArray(); } }
How to get your CloudStorageAccount
Another apparently random change is that you can't get your storage account info in the same way as you used to. You used to be able to get it like this in Storage Client v1.7:
var storageAccountInfo = CloudStorageAccount.FromConfigurationSetting(configSetting); var tableStorage = storageAccountInfo.CreateCloudTableClient();
But in Azure Storage v2.0 you must get it like this:
var storageAccountInfo = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting(configSetting)); var tableStorage = storageAccountInfo.CreateCloudTableClient();
Why?.. not sure. I have had problems with getting storage account information before so maybe this resolve that.
What happened to CreateTableIfNotExist?
Again, it's disappeared but who cares.. Oh you do? Right well let's fix that up. So, in Azure Storage Client v1.7 you did this:
var tableStorage = storageAccountInfo.CreateCloudTableClient(); tableStorage.CreateTableIfNotExist(tableName);
But now in Azure Storage Client Library v2.0 you must do this:
var tableStorage = storageAccountInfo.CreateCloudTableClient(); var table = tableStorage.GetTableReference(tableName); table.CreateIfNotExists();
Attributes seem to have disappeared and LastModifiedUtc has gone
Another random change that possibly doesn't achieve anything other than making you refactor your code. This was my old code from Storage Library Client v1.7:
var blob = BlobService.FetchAttributes(FileName); if (blob == null || blob.Attributes.Properties.LastModifiedUtc < DateTime.UtcNow.AddHours(-1)) { ... }
But now it should read like this because thought it looks prettier (which it does in fairness).
var blob = BlobService.FetchAttributes(FileName); if (blob == null || blob.Properties.LastModified < DateTimeOffset.UtcNow.AddHours(-1)) { ... }
Change your development storage connection string
This is just a straight bug so that's excellent. I was getting a useless exception stating "The given key was not present in the dictionary" when trying to create a CloudStorageAccount reference. To resolve this change your development environment connection string from UseDevelopmentStorage=true
to UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1
then it will magically work.
Bitch and moan
Apologies for the whingy nature of this post, I'm quite a fan of Azure but I have wasted about 3-4 hours with this "upgrade" from Azure Storage Client Library 1.7 to 2.0. It's been incredibly frustrating particularly since there seems to be no obvious reason why these changes were made. I just can't believe the amount of breaking changes when I haven't really written that much Azure storage code.
Randomly taking out nice methods like DownloadByteArray and DownloadText is surely a step backwards no? Or randomly renaming CreateIfNotExist()
to CreateIfNotExists()
... what is the point in that?!
I remember when upgrading to ASP.NET 4 from 3.5, I spent very little time working through breaking changes and I have 100 times more .NET code than I do Azure Storage code. As well as that, I was well aware of the many improvements with that .NET version update, with this Azure Storage update I have no idea what I'm getting. No matter the improvements, it is just an Azure storage API and this number of breaking changes, often for the benefit of syntax niceties is just unnacceptable.
Oh, if you are still in pain doing this I have found a complete list of breaking changes in this update along with minimal explanations here.
You 'Bitch and moan', so that I didn't have to!
ReplyDeleteThanks :-)
The problem was made worse (IMO) by the pretty rubbish pages MS put out to 'support' this.
The 'breaking changes and migration guide' did very little other than tell me what I already knew - my code wasn't going to work any more.
And the 'deep dive', while informative for writers of new code, ignores the topic of migration.
Ultimately it feels like the 2.0 lib is 'better' than the 1.7 lib, at least for new projects.
I do have a few concerns about needing to have BOTH if I want diagnostics to work though.
It is very nice and informative blog through which we gain a lot information for our some purpose. Upgrading Azure Storage really awesome post. New Grass Mesh available in different sizes visit http://groundreinforcementmeshuk.co.uk/grass-mats.html for more detail.
ReplyDeleteOnline gaming is a hobby of many people. Game Run Unblockedversions as Run 3 Unblocked or Run 4 Unblocked is a very interesting game to control the bear run or jump to the safe landing area falls. risks with such racing game Car Racing Games or interesting as the game Donkey Kong Unblocked or Car Racing Games wrap pulled a lot of players. Good luck!
ReplyDeleteWith football we always have exciting games such as head soccer and head soccer unblocked and soccer heads and head soccer 2 or big head basketball big head soccer or head soccer will bring to everyone the good entertainment Best. After work you can play with Big Head Football and Big Head Soccer or Head Soccer to reduce the pressure of work. With big head basketball
ReplyDeleteHead Soccer and Big Head Football you will have the best experience on the sport king. big head basketball and Head Soccer and Big Head Soccer and Big Head Football will make the most demanding on electronic games must also satisfied. Come to Big Head Football and big head basketball and Big Head Soccer to experience the most wonderful thing. Thank you.
ReplyDeleteCreating your own Infographic can be made easy with these six great Website suggestions for Infographic Templates and Free Infographic Downloads. Infographics are great for a number of purposes whether you are creating a timeline of information, analyzing the findings of a study or assembling a how to guide. See more infographic design online
ReplyDeleteHere we present to introduce to all visitors in this great blog. and thank you for allowing me . cara menggugurkan kandungan
ReplyDeleteThis is a very good article material and it is very useful for us all. thank you . cara menggugurkan kandungan
ReplyDeletePest Control services in Kirti Nagar
ReplyDeletePest Control services in Modi Nagar
Pest Control services in Patel Nagar
Pest Control services in Rajouri Garden
Pest Control services in Tilak Nagar
Pest Control services in Janakpuri
Pest Control services in Paschim Vihar
Awesome post about also check it Blog!Mobilism for android simcity buildit mod android download dead trigger mod apk
ReplyDeleteIndia's only Digital News Channel with True Voice of India.
ReplyDeleteFinding #Championsofchange2018 #rahulshivkant
the universal post teams
the universal post youtube
loksabha election 2018
top trending news
top viral news
best trending news in india
Prospectus Patrachar Vidyalaya
ReplyDeleteCBSE Forms
CBSE Patrachar Delhi
Patrachar Vidyalaya phone no.
packer and mover chandigarh
Packers and movers in panchkula
packers and movers in mohali
nice post friend , Thank you for sharing with us, and we sincerely hope you will continue to update or post other articles
ReplyDeletemutilateadoll23.com
luffygames.com
Thanks to this article I can learn more.http://chouraha.com/si-kaise-bane-sub-inspector-taiyari-kaise-kare/ Expand your knowledge and abilities. Actually the article is very practical.
ReplyDeleteMotifz Designer Lawn. 1, 2 & 3 Piece Unstitched Premium Embroidered Lawn 2019, Premium Lawn, Lawn 2019, Best lawn collection, Motifz, Best Lawn in Pakistan, Shipping worldwide. Stitching option available.
ReplyDeleteBuy Premium lawn Online for Women's at best prices available at Motifz. ✓ Latest Fashion, ✓ Trendy Designs ➤ Shop Now!
ReplyDeleteThis is really unbelievable and extraordinary work. Everyone should read. Thanks for sharing and don't miss WORLD'S BEST
ReplyDeleteMonsterTrucks
Hey,
ReplyDeleteThenkx For Sharing this article for us. this is really cool.
Thenkx again
Regards
ChaluBaba
123movies Very good article and I like it. Thank you for giving me information
ReplyDeleteFake driving license online at cheap price
ReplyDeleteWelcome to Buy All Documents online site. We are a licensee of New Life Identity and are recognised internationally as a leading company in document security feature technologies. Since opening 2011, we have been favourites in the fake ID cards online, real and fake passport industry for innovative ideas, superior customer care and quality. Buy Real Fake Documents offer 100% authentic & cheap fake driving license online to UK, US, Canada and all over the world.
For more details you can visit our website: https://buyalldocument.com/ OR WhatsApp: +1(443) 351-8162 OR Email us at buyrealfake.documents@yandex.com
Wholesale printed custom perfume boxes with the highest quality and affordable prices. Free worldwide Delivery and free Custom Perfume Boxes design.
ReplyDeleteBuy online wholesale printed custom candle boxes and packaging at easy prices and shipping worldwide, with 24/7 customer support. Get a free custom quote now!!
ReplyDeleteBuy online wholesale lipstick boxes and packaging at seashore packaging at the easy price Free shipping worldwide with 24/7 customer support.
ReplyDeleteBlackbird packaging provide you with any size, shape design, CBD boxes sooner than any other packaging competitor in the market
ReplyDeletePackaging town is a one-stop solution for the short-run Custom Packaging, Wholesale CBD Boxes needs, and supplies at ease.
ReplyDeletemylar label bags in stock now. Ready made Cali pack designs. Fast Shipping at Your Supplies. Custom designs available
ReplyDeleteBlackbird packaging provide you with any size, shape design, cbd bath bomb boxes sooner than any other packaging competitor in the market
ReplyDeleteGreat Article
ReplyDeleteCloud Computing Projects
Networking Projects
Final Year
Projects for CSE
JavaScript Training in Chennai
JavaScript
Training in Chennai
The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals,
Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer.
Angular Training
Blackbird packaging provide you with any size, shape design, bath bomb display boxes sooner than any other packaging competitor in the market
ReplyDeletePackaging town is a one stop solution for the short-run custom tuck boxes needs and supplies. At affordable prices. Request a free quote now.
ReplyDeletecali spliff 3.5g Direct Print on the front and back. % Cali Packs Available at Your Supplies. Heat sealable mylar bags. Fast Shipping.
ReplyDeleteBlackbird packaging provide you with any size, shape design, custom pet food packaging sooner than any other packaging competitor in the market
ReplyDeletecustom printed mylar bags uk in stock now. Ready made Cali pack designs. Fast Shipping at Your Supplies. Custom designs available
ReplyDeleteBlackbird packaging provide you with any size, shape design, custom wholesale cookie boxes sooner than any other packaging competitor in the market
ReplyDeleteBlackbird packaging company can provide you with any size, shape design, and crafted cbd tincture boxes sooner than any other packaging competitor in the market
ReplyDeleteI like your post. It is good to see you verbalize from the heart and clarity on this important subject can be easily observed.
ReplyDeleteLove back Solution Specialist
Famous Pandit in New Zealand
Famous Pandit in UK
Famous Pandit in USA
Famous Pandit in Canada
Famous Pandit in AustraliaLove back Solution Specialist
Love Guru in New ZealandLove Guru in Canada
Love Guru in Australia
Packaging town is a one stop solution for the short-run custom pillow boxes needs and supplies. At affordable prices. Request a free quote now.
ReplyDeletebuy men sweatshirts online from wild goat clothing
ReplyDeletelahore electronics
ReplyDeletelahore grocery
ReplyDeleteShop for Electronic Goods at Al-Fatah, Pakistan's leading chain of departmental stores. Shop from a huge range of top brands Home Appliances, Smart-tech and Phones and Sound bars from Al-Fatah. Shop from huge range of electronics available at Al-Fatah. Avail Free Delivery on orders above 1000 PKR in selected cities.
buy grocery online in lahore from alfatah at best prices. get free shipping
ReplyDeletebuy online men zipper hoodie from wild goat clothing at best prices. Get Free shipping
ReplyDeletebuy custom essential oil boxes from blackbird packaging at best prices. Get free shipping.
ReplyDeleteBlackbird packaging company can provide you with any size, shape design, and packaging for bath bombs sooner than any other packaging competitor in the market
ReplyDeleteHello, My Dearest Friends Super class independent Escorts Services available incall & outcall
ReplyDeleteservice in VIP hotels.and call girls available for booking 24x7 hours IF You
want Physical Relationship any time contact me & ?meet with me to get my
number from website and call
Thank You & Visit Again""_____
Guwahati Call Girls
Call Girls in Guwahati
Hello, This is a Nitu roy very interesting blog. this content is written very well This is an amazing
ReplyDeletepost, keep blogging.thanks for sharing.Anyways I am here now and could just like to say thank
for a tremendous post and a all round entertaining website.
Guwahati Escort
Call girl service in Guwahati
Maybe you are also looking for the right person to ensure the higher quality
ReplyDeletesex and that’s why you are in this place because here we are going to share
the data and information of Guwahati Escorts.
Guwahati escorts
Escorts in Guwahati
Explore the profiles of guwahati escorts, guwahati call girls, call girls in guwahati and
ReplyDeleteescorts in guwahati for female companionship in top rated hotels.
Get affordable escort services in guwahati hotels now.
Guwahati call girl
Guwahati escort service
Very nicely written blog...Relly loved reading it...Please check my blogs for
ReplyDeleteBhubaneswar escort
Call girl in Bhubaneswar
Shop from a wide range of Local and Imported variety of makeup removers and makeup remover wipes from Al-Fatah. Shop from a diversified range of makeup removers and makeup remover wipes from all top brands. Buy the best for your skin. Avail Free Delivery on orders above 1000 PKR for selected cities in Pakistan.
ReplyDeleteBlackbird packaging company can provide you with any size, shape design, and bath bomb boxes sooner than any other packaging competitor in the market
ReplyDeletePackaging town is a one stop solution for the short-run custom soap boxes needs and supplies. At affordable prices. Request a free quote now.
ReplyDelete