이 항목은 아직 평가되지 않았습니다.- 이 항목 평가

CloudBlobContainer.SetPermissions 메서드 (BlobContainerPermissions)

Sets permissions for the container.

네임스페이스: Microsoft.WindowsAzure.StorageClient
어셈블리: Microsoft.WindowsAzure.StorageClient(microsoft.windowsazure.storageclient.dll)
‘사용 방법
Dim instance As CloudBlobContainer
Dim permissions As BlobContainerPermissions

instance.SetPermissions(permissions)
public void SetPermissions (
	BlobContainerPermissions permissions
)
public void SetPermissions (
	BlobContainerPermissions permissions
)
public function SetPermissions (
	permissions : BlobContainerPermissions
)

매개 변수

permissions

The permissions to apply to the container.

The following code example sets both public access permissions and a container-level access policy on the container. The example then generates a shared access signature for the container.

static void CreateSAS()
{
    //Retrieve storage account information from an app.config file.
    //This is one way to store and retrieve a connection string if you are writing an application 
    //that will run locally, rather than in Windows Azure.
    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageAccountConnectionString"]);

    //Create the blob client object.
    CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

    //Get a reference to the container for which the shared access signature will be created.
    CloudBlobContainer container = blobClient.GetContainerReference("mysascontainer");
    container.CreateIfNotExist();

    //Create a permission policy to set the public access setting for the container. 
    BlobContainerPermissions containerPermissions = new BlobContainerPermissions();

    //The public access setting explicitly specifies that the container is private, so that it can't be accessed anonymously.
    containerPermissions.PublicAccess = BlobContainerPublicAccessType.Off;

    //Set the permission policy on the container.
    container.SetPermissions(containerPermissions);

    // Get the shared access signature to share with users, specifying a signature-level access policy.
    string sas = container.GetSharedAccessSignature(new SharedAccessPolicy()
    {
        SharedAccessStartTime = DateTime.Now,
        SharedAccessExpiryTime = DateTime.Now.AddHours(10),
        Permissions = SharedAccessPermissions.Write | SharedAccessPermissions.Read
    });

    //The shared access signature then can be used to create a service client. 
    //This code would likely be run from a different client, but is included here to 
    //demonstrate how to consume the shared access signature.

    //Create the blob client directly, using the shared access signature
    CloudBlobClient sasBlobClient = new CloudBlobClient(storageAccount.BlobEndpoint,
        new StorageCredentialsSharedAccessSignature(sas));

    //Return a reference to a blob.
    CloudBlob blob = sasBlobClient.GetBlobReference("mysascontainer/myblob.txt");

    //Upload text to the blob. If the blob does not yet exist, it will be created. If the blob does exist, its existing
    //content will be overwritten.
    blob.UploadText("Write to a blob using shared access credentials.");
}


The SetPermissions method sets two types of permissions for the container:

  • Public access permissions, which determine whether container data and blob resources are available for anonymous access.

  • Container-level access policies, which can be used to specify parameters for a shared access signature for the container.


이 형식의 모든 public static(Shared, Visual Basic의 경우) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

개발 플랫폼

Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Server 2008 및 Windows 2000

대상 플랫폼

이 정보가 도움이 되었습니까?
(1500자 남음)

커뮤니티 추가 항목

Microsoft는 MSDN 웹 사이트에 대한 귀하의 의견을 이해하기 위해 온라인 설문 조사를 진행하고 있습니다. 참여하도록 선택하시면 MSDN 웹 사이트에서 나가실 때 온라인 설문 조사가 표시됩니다.

참여하시겠습니까?
© 2013 Microsoft. All rights reserved.
facebook page visit twitter rss feed newsletter