Storing binary data (images, files, etc) using WPF + Windows Azure

前端 未结 2 1968
不知归路
不知归路 2021-01-15 04:08

I have a WPF application that uses Windows Azure as the backend. I use SQL Azure to store data that are accessed by the WPF application through a WCF service. I need to be a

相关标签:
2条回答
  • 2021-01-15 05:01

    As @Blam pointed out, Blob Storage is a much better way to store large binary objects. Each blob has a URI that looks like https://mystorage.blob.core.windows.net/somecontainer/someblob.jpg. Each blob may be up to 200GB. You can easily store a blob's URI in SQL Azure, along with related metadata.

    You then have a choice of either returning an image through your WCF service or providing direct access. With the former, you'd basically make a call to blob storage, from your WCF service implementation, to retrieve the blob, then return it in the WCF response.

    With the latter, it gets a bit trickier. You have a choice of making blobs public or private. Public blobs are great for logos, CSS, and other information that doesn't require user permissions to view. Private blobs require use of your storage account key (which you should never give out). However, using a feature called Shared Access Signature, you can provide a URL with a special hash on the querystring, providing temporary access (up to 1 hour). The basic tradeoff: If you go through the WCF service for binary file download, your code will work as it would with any other WCF service, but you may find yourself scaling out to multiple instances of your Azure VM to support increased load. If you go with Shared Access Signatures, you'll likely need to modify your WPF app to grab a binary file based on a URL. However, this would take load off your WCF service, as you'd then be accessing Blob Storage directly to download binary content (which is a massive-scale multi-tenant storage system managed by Windows Azure).

    See here for Windows Azure Storage pricing. At under 13 cents per GB, it's significantly less expensive than SQL Azure.

    0 讨论(0)
  • 2021-01-15 05:06

    Azure blobs. SQL Azure is expensive compared to blobs.

     http://www.windowsazure.com/en-us/home/features/storage/
    
    0 讨论(0)
提交回复
热议问题