Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Azure

BLOBs : Setting shared access permissions

3/10/2011 8:57:07 AM
- Windows 10 Product Activation Keys Free 2019 (All Versions)
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire
Access to a BLOB is controlled by the container that it lives in. If the BLOB lives in a public container, it’s available to the world. If the BLOB lives in a private container, you can access it only with your private authentication key.

Warning

Don’t distribute your private authentication key. Doing so is a surefire way to have some evildoer trash your data.


These levels of access are a little too extreme; we need a more granular way of controlling access to our BLOBs, namely Shared Access Signatures. Using shared access, you can set a policy on a private container (or BLOB), and anyone who makes a request with the correct signature can perform the appropriate action on the BLOB (say, download the BLOB).

Although you can assign permissions at an individual BLOB level, this is a pain to maintain. It’s easier to maintain permissions at a container level (you can always have a container that consists of a single BLOB).

Let’s now return to the podcast example and look at how you can control download access to one of your podcasts.

1. Setting shared access permissions on a container

Let’s say your podcasting business has gone well and you’ve decided to start selling some of your podcasts to the general public. In this scenario, after some rich dude has purchased the podcast, you need to provide a way for them to download the podcast without making it public (you obviously don’t want to give them your owner authentication key). To achieve this, you’re going to store your podcast (podcast03.mp3) in its own private container (Podcast03), which isn’t available to the general public.

After your customer has purchased the podcast, you’ll generate a Shared Access Signature that will give that customer permission to read any BLOBs (in this case, podcast03.mp3) in the Podcast03 container, for a period of 24 hours. After the 24-hour period has expired, the customer will no longer be able to download the podcast.

The first thing you need to do is generate a shared access policy that will restrict the download period to the next 24 hours, using the following code:

var oneDayDownloadpolicy = new SharedAccessPolicy();
oneDayDownloadpolicy.SharedAccessStartTime = DateTime.Now;
oneDayDownloadpolicy.SharedAccessExpiryTime = DateTime.Now.AddDays(1);
oneDayDownloadpolicy.Permissions = SharedAccessPermissions.Read;

As shown in the code, you can specify both a start time and an expiry time for the policy. If you don’t specify a start time, the value now is substituted as a default. After you’ve specified this policy, apply it to the container.

var permissions = new BlobContainerPermissions();
permissions.SharedAccessPolicies.Clear();
permissions.SharedAccessPolicies.Add("CustomerA", oneDayDownloadPolicy);
container.SetPermissions(permissions);

Finally, you can generate a URI that customers will be able to use to download the BLOB, using the following code:

string sharedAccessSignature = container.GetSharedAccessSignature(oneDayDownloadpolicy);
string uri = blob.Uri.AbsoluteUri + sharedAccessSignature;


The generated URI will look something like this:

https://chrishayuk.blob.core.windows.net/podcast03/podcast03.mp3?st=2010-01-04T12%3A08%3A00Z&se=2010-01-05T12%3A08%3A00Z&sr=b&sp=r&sig=ByfV3a1SXOXT04G4GF%2FNQo%2B9cxx4vrRE45kYxbhFhJk%3D

And that’s about it; you can now dynamically assign permission to read BLOBs that are in containers.

Assigning other types of permissions

What if you want to be able to assign permissions at a BLOB level (rather than at a container level) or if you want to provide more than just read permissions? You can generate Shared Access Signatures that give users permissions to write to certain BLOBs in your container. This scenario is a little too detailed for what we would like to show in this book, but feel free to visit the online documentation for more details at http://msdn.microsoft.com/en-us/library/ee395415.aspx.


Other -----------------
- Enterprise Service Bus with BizTalk Server and Windows Azure : Distributed and Scalable ESB Architecture
- Enterprise Service Bus with BizTalk Server and Windows Azure : The ESB Toolkit
- Enterprise Service Bus with BizTalk Server and Windows Azure : Integration with BizTalk
- Copying BLOBs - Copying files via the StorageClient library
- Using local storage with BLOB storage (part 3) - Improving your handler to check the last modified time
- Using local storage with BLOB storage (part 2) - Updating your HTTP handler to use local storage & Checking properties of a BLOB without downloading it
- Using local storage with BLOB storage (part 1) - Using a local cache & Defining and accessing local storage
- Integrating BLOBs with your ASP.NET websites
- Downloading BLOBs
- Managing BLOBs using the StorageClient library (part 2) - Uploading BLOBs & Deleting BLOBs
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Popular tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 windows Phone 7 windows Phone 8
programming4us programming4us
Celebrity Style, Fashion Trends, Beauty and Makeup Tips.
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server