Logo
CAR REVIEW
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
PREGNANCY
 
 
Windows Azure

Securing Your SharePoint and Windows Azure Solutions : Create a Windows Forms Application to Display the Shared Access Permissions Signature

11/20/2012 6:14:54 PM

Create a Windows Forms Application to Display the Shared Access Permissions Signature

  1. Open Microsoft Visual Studio 2010 and create a blank solution.

  2. Right-click the solution and select Add | New Project.

  3. Select Windows Forms Application, provide a name for the application (such as BLOBUriGenerator), and click OK.

  4. Right-click the project and select Add References. Add Microsoft.WindowsAzure.StorageClient.dll (from C:\Program Files\Windows Azure SDK\v1.3\bin).

  5. Click View | Toolbox, drag two buttons onto the Windows Forms designer surface, and then drag a textbox control onto the designer surface. Your Windows Forms UI should look similar to the graphic shown here. Name the buttons btnGetData and btnExit. Name the textbox control txtbxURI.

    image with no caption
  6. Right-click the Form1.cs in the Solution Explorer and select View Code.

  7. In the code-behind, amend the code by using the bolded code shown here:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Microsoft.WindowsAzure.StorageClient;
    using Microsoft.WindowsAzure;
    
    namespace BLOBUrlGenerator
    {
        public partial class Form1 : Form
        {
    
            CloudBlobContainer azureBlobContainer = null;
            CloudStorageAccount azureStorageAcct = null;
            CloudBlobClient azureBlobClient = null;
            BlobContainerPermissions azureBlobPermissions = null;
            CloudBlob azureBlob = null;
            string submissionDateTime = "";
    
            public Form1()
            {
                InitializeComponent();
                InitializeStorage();
            }
    
            private void InitializeStorage()
            {
                var accountInfo = "DefaultEndpointsProtocol=http;Accountname=fabrikaminc;
    AccountKey=<your account key here>
    
                azureStorageAcct = CloudStorageAccount.Parse(accountInfo);
    
                azureBlobClient = azureStorageAcct.CreateCloudBlobClient();
    
                azureBlobContainer = azureBlobClient.GetContainerReference(
                   "c10testcontainer");
                azureBlobContainer.CreateIfNotExist();
                azureBlob = azureBlobContainer.GetBlobReference("c10testblob");
                azureBlob.UploadText("Test Text");
            }
    
            private void btnGetURI_Click(object sender, EventArgs e)
            {
                SharedAccessPolicy tempAccess = new SharedAccessPolicy();
                tempAccess.SharedAccessStartTime = DateTime.Now;
                tempAccess.SharedAccessExpiryTime = DateTime.Now.AddHours(48);
                tempAccess.Permissions = SharedAccessPermissions.Read;
    
                BlobContainerPermissions tempPermissions = new BlobContainerPermissions();
                tempPermissions.SharedAccessPolicies.Clear();
                tempPermissions.SharedAccessPolicies.Add("John Doe", tempAccess);
                azureBlobContainer.SetPermissions(tempPermissions);
    
                string sharedAccessSig = azureBlobContainer.
                   GetSharedAccessSignature(tempAccess);
                string sharedAccessURI = azureBlobContainer.Uri.AbsoluteUri +
                   sharedAccessSig;
    
                txtbxURI.Text = sharedAccessURI;
            }
    
            private void btnExit_Click(object sender, EventArgs e)
            {
                Application.Exit();
            }
        }
    }

    The preceding code uses the Microsoft.WindowsAzure.StorageClient library to programmatically interact with a Windows Azure BLOB storage account. You’ll note that there are several class-level declarations in the snippet, which represent the different storage objects that you need when interacting with Windows Azure BLOB storage. Then, as was discussed earlier in this section, you use the SharedAccessPolicy class to create a temporary shared access permissions signature, which can be used to download data and information from the BLOB. The shared access permissions URI that is created (sharedAccessURI) is then displayed in the textbox property.

  8. After you finish adding the code, press F5 to debug the application. You should see something similar to the following—which exposes the shared access permissions signature in the form of a URI.

    image with no caption

Though this application is fairly simple, it illustrates how you can create controlled access to BLOB storage resources. This code within the simple Windows Forms code can equally apply to SharePoint Web Parts (or other SharePoint artifacts) and Silverlight applications that can be hosted in SharePoint.

Note

Although Windows Azure storage provides shared access permissions, the use of shared access permissions is less apparent with the other parts of the platform. The Windows Azure AppFabric platform, for example, employs a different type of security called the Access Control Service, which uses claims to authenticate users and applications.

Other -----------------
- Securing Your SharePoint and Windows Azure Solutions : Configuring BCS Security - Create an Application ID, Assess Permissions on the ECT
- Deploying to Windows Azure : Changing live configuration, Upgrading the deployment, Running the deployment
- Deploying to Windows Azure : Preparation application for deployment, Ready for deployment
- Setting up hosted service in Windows Azure
- Azure Monitoring and Diagnostics : Logging config data in our application, Transferring and persisting diagnostic data
- Azure Monitoring and Diagnostics : Azure Diagnostics­ under the hood, Enabling diagnostic logging
- Web Services and Azure : Our WCF web services
- Web Services and Azure : Creating a new WCF service web role
- Azure Blob Storage : Windows Azure Content Delivery Network, Blob Storage Data Model
- Azure Blob Storage : Blobs in the Azure ecosystem, Creating Blob Storage
- The Nickel Tour of Azure : How are Azure costs calculated?
- The Nickel Tour of Azure : Explaining Azure to the managers
- Application Life Cycle Management
- Sharing Digital Photographs : Exploring Photo-Sharing Communities
- Sharing Digital Photographs : Exploring Online Photo-Editing Applications
- Surfacing SQL Azure Data in Bing Maps by Using the Client Object Model
- Storing and Sharing Files and Other Online Content : Exploring Online Bookmarking Services
- Storing and Sharing Files and Other Online Content : Understanding Cloud Storage & Evaluating Online File-Storage and -Sharing Services
- Integrating the SharePoint Server Object Model and the Entity Data Model (part 2) - Create a Meeting Scheduler Visual Web Part
- Integrating the SharePoint Server Object Model and the Entity Data Model (part 1) - Create a Console Application to Write Data to a SharePoint List
 
 
Most view of day
- Monitoring Windows Small Business Server 2011 : Using Event Viewer
- Windows Server 2003 on HP ProLiant Servers : File and Print Services, Selection of ProLiant Servers for the Enterprise
- Maintaining Dynamics GP : Speeding security setup with User Copy
- BizTalk Server 2006 : Starting a New BizTalk Project - Creating a Build-and-Integration Environment (part 1) - Five-Step Build Process
- Sharepoint 2013 : Assign Users’ Permissions on a Site
- Microsoft Excel 2010 : SUBTOTAL Function, Subtotal Tool
- Troubleshooting Hardware, Driver, and Disk Issues : How to Use Built-In Diagnostics (part 5)
- What's new and improved in SharePoint 2013 : Creating an asset library
- System Center Configuration Manager 2007 : ConfigMgr Classic Reports Versus SQL Reporting Services
- Adobe Fireworks CS5 : Adding a Flex skin
Top 10
- Microsoft Lync Server 2013 : Director Troubleshooting (part 3) - Synthetic Transactions,Telnet
- Microsoft Lync Server 2013 : Director Troubleshooting (part 2) - DNS Records, Logs
- Microsoft Lync Server 2013 : Director Troubleshooting (part 1) - Redirects, Certificates
- Microsoft Lync Server 2013 : Administration of the Director Role (part 4) - Services Management, Client Version Filter
- Microsoft Lync Server 2013 : Administration of the Director Role (part 3) - Topology Status
- Microsoft Lync Server 2013 : Administration of the Director Role (part 2) - Ports,Firewall Rules
- Microsoft Lync Server 2013 : Administration of the Director Role (part 1) - Services
- Microsoft Lync Server 2013 : Configuring the Director (part 2) - Web Services Ports,Reverse Proxy
- Microsoft Lync Server 2013 : Configuring the Director (part 1) - SRV Records, Web Services FQDN Overrides
- Sharepoint 2013 : SharePoint Designer 2013 (part 2) - Locking Down SharePoint Designer
 
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro