本文整理汇总了C#中Microsoft.WindowsAzure.StorageClient.CloudBlobContainer.SetPermissions方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobContainer.SetPermissions方法的具体用法?C# CloudBlobContainer.SetPermissions怎么用?C# CloudBlobContainer.SetPermissions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.StorageClient.CloudBlobContainer
的用法示例。
在下文中一共展示了CloudBlobContainer.SetPermissions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnStart
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
DiagnosticMonitor.Start("DiagnosticsConnectionString");
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
RoleEnvironment.Changing += RoleEnvironmentChanging;
// read storage account configuration settings
CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter)
=> configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)));
var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
// initialize blob storage
CloudBlobClient blobStorage = storageAccount.CreateCloudBlobClient();
container = blobStorage.GetContainerReference("converteddata");
// initialize queue storage
CloudQueueClient queueStorage = storageAccount.CreateCloudQueueClient();
queue = queueStorage.GetQueueReference("workercommands");
Trace.TraceInformation("Creating container and queue...");
bool storageInitialized = false;
while (!storageInitialized)
{
try
{
// create the blob container and allow public access
container.CreateIfNotExist();
var permissions = container.GetPermissions();
permissions.PublicAccess = BlobContainerPublicAccessType.Container;
container.SetPermissions(permissions);
// create the message queue
queue.CreateIfNotExist();
storageInitialized = true;
}
catch (StorageClientException e)
{
if (e.ErrorCode == StorageErrorCode.TransportError)
{
Trace.TraceError("Storage services initialization failure. "
+ "Check your storage account configuration settings. If running locally, "
+ "ensure that the Development Storage service is running. Message: '{0}'", e.Message);
Thread.Sleep(5000);
}
else
{
throw;
}
}
}
return base.OnStart();
}
示例2: CreateIfNotExist
public void CreateIfNotExist(CloudBlobContainer cloudBlobContainer, bool isPublic = true)
{
cloudBlobContainer.CreateIfNotExist();
var permission = cloudBlobContainer.GetPermissions();
var blobContainerPermissions = new BlobContainerPermissions {PublicAccess = isPublic ? BlobContainerPublicAccessType.Container : BlobContainerPublicAccessType.Off};
cloudBlobContainer.SetPermissions(blobContainerPermissions);
}
示例3: OnStart
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 100;
//Initialize Indexer
storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("CrawlerStorage"));
//Initialize URL Queue
urlQueueClient = storageAccount.CreateCloudQueueClient();
urlQueue = urlQueueClient.GetQueueReference("urlqueue");
if (urlQueue.CreateIfNotExist())
{
//Add first URL to the queue
CloudQueueMessage firstURL = new CloudQueueMessage(startURL);
urlQueue.AddMessage(firstURL);
}
//Initialize Index Queue
indexQueueClient = storageAccount.CreateCloudQueueClient();
indexQueue = indexQueueClient.GetQueueReference("indexqueue");
indexQueue.CreateIfNotExist();
//Initialize Database Blob
databaseClient = storageAccount.CreateCloudBlobClient();
databaseContainer = databaseClient.GetContainerReference("wordfrequencies");
databaseContainer.CreateIfNotExist();
var permission = databaseContainer.GetPermissions();
permission.PublicAccess = BlobContainerPublicAccessType.Container;
databaseContainer.SetPermissions(permission);
return base.OnStart();
}
示例4: Storage
public Storage(CloudStorageAccount account)
{
this.account = account;
fileStorage = account.CreateCloudBlobClient();
/* Initialize file container */
container = fileStorage.GetContainerReference(filesContainer);
container.CreateIfNotExist();
var permissions = container.GetPermissions();
/* Full permissions. From MSDN, Container-level public access. Anonymous clients can
* read blob content and metadata and container metadata, and can list the blobs within the container.
*
* Other alternatives are Blob (can read content but not metadata) and Off (no
* anonymous access).
*/
// permissions.PublicAccess = BlobContainerPublicAccessType.Container;
permissions.PublicAccess = BlobContainerPublicAccessType.Off;
permissions.SharedAccessPolicies.Remove("basic");
permissions.SharedAccessPolicies.Add("basic", new SharedAccessPolicy()
{
});
container.SetPermissions(permissions);
/* Initialize table (for file metadata) */
CloudTableClient.CreateTablesFromModel(
typeof(FileDataContext),
account.TableEndpoint.AbsoluteUri,
account.Credentials);
}
示例5: AzureBlobRepository
public AzureBlobRepository(CloudStorageAccount storageAccount, CloudBlobClient blobClient, CloudBlobContainer blobContainer)
{
this._storageAccount = storageAccount;
this._blobClient = blobClient;
this._blobContainer = blobContainer;
_blobContainer.SetPermissions(GetPermissions());
}
示例6: ConnectToBlobStorage
/// <summary>
/// Connects to the storage account and creates the default container
/// </summary>
private void ConnectToBlobStorage()
{
storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
blobClient = storageAccount.CreateCloudBlobClient();
blobContainer = blobClient.GetContainerReference("testcontainer");
blobContainer.CreateIfNotExist();
blobContainer.SetPermissions(new BlobContainerPermissions() { PublicAccess = BlobContainerPublicAccessType.Blob });
}
示例7: AzureHelper
static AzureHelper()
{
var cloudStorageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=http;AccountName=mintchipmarket;AccountKey=6wtpT0uW75m2LsThfROjp+cMA5zWx8VllZhJ5tM7kPAZZlIbPZ0t7pIXkO0s0AnzZ4sWMnl+rc5+1KjlNWKlfA==");
var blobClient = new CloudBlobClient(cloudStorageAccount.BlobEndpoint, cloudStorageAccount.Credentials);
_container = blobClient.GetContainerReference("files");
_container.CreateIfNotExist();
_container.SetPermissions(new BlobContainerPermissions() { PublicAccess = BlobContainerPublicAccessType.Off });
}
示例8: AzureFileSystem
public AzureFileSystem(string containerName, string root, bool isPrivate, CloudStorageAccount storageAccount) {
// Setup the connection to custom storage accountm, e.g. Development Storage
_storageAccount = storageAccount;
ContainerName = containerName;
_root = String.IsNullOrEmpty(root) || root == "/" ? String.Empty : root + "/";
BlobClient = _storageAccount.CreateCloudBlobClient();
// Get and create the container if it does not exist
// The container is named with DNS naming restrictions (i.e. all lower case)
Container = BlobClient.GetContainerReference(ContainerName);
Container.CreateIfNotExist();
if ( isPrivate ) {
Container.SetPermissions(new BlobContainerPermissions
{PublicAccess = BlobContainerPublicAccessType.Off});
}
else {
Container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Container });
}
}
示例9: AzureBlobFileRepository
public AzureBlobFileRepository(IConfigSettings configSettings)
{
var setting = configSettings.Get("StorageConnectionString");
containerName = configSettings.Get("BlobContainerName");
storageAccount = CloudStorageAccount.Parse(setting);
blobClient = storageAccount.CreateCloudBlobClient();
container = blobClient.GetContainerReference(containerName.ToLower());
container.CreateIfNotExist();
container.SetPermissions(new BlobContainerPermissions
{
PublicAccess = BlobContainerPublicAccessType.Blob
});
}
示例10: OnStart
public override bool OnStart()
{
//Initialize Indexer
storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("CrawlerStorage"));
//Initialize Database Blob
databaseClient = storageAccount.CreateCloudBlobClient();
databaseContainer = databaseClient.GetContainerReference("wordfrequencies");
databaseContainer.CreateIfNotExist();
var permission = databaseContainer.GetPermissions();
permission.PublicAccess = BlobContainerPublicAccessType.Container;
databaseContainer.SetPermissions(permission);
return base.OnStart();
}
示例11: CreateContainer
static void CreateContainer()
{
//get blob container
account = CloudStorageAccount.FromConfigurationSetting("BlobConnectionString");
client = account.CreateCloudBlobClient();
container = client.GetContainerReference("userphotos");
container.CreateIfNotExist();
BlobContainerPermissions permissions = new BlobContainerPermissions()
{
PublicAccess = BlobContainerPublicAccessType.Blob
};
container.SetPermissions(permissions);
}
示例12: AzureShellSettingsManager
public AzureShellSettingsManager(CloudStorageAccount storageAccount, IShellSettingsManagerEventHandler events)
{
// Setup the connection to custom storage accountm, e.g. Development Storage
_storageAccount = storageAccount;
_events = events;
BlobClient = _storageAccount.CreateCloudBlobClient();
// Get and create the container if it does not exist
// The container is named with DNS naming restrictions (i.e. all lower case)
Container = new CloudBlobContainer(ContainerName, BlobClient);
Container.CreateIfNotExist();
// Tenant settings are protected by default
Container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Off });
}
示例13: FriendLikesService
public FriendLikesService(string id)
{
this.UserId = id;
account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("DataConnectionString"));
// Table Client
tableClient = new CloudTableClient(account.TableEndpoint.ToString(), account.Credentials);
tableClient.CreateTableIfNotExist(FRIEND_LIKES_TABLE);
// Blob Client
blobClient = new CloudBlobClient(account.BlobEndpoint.ToString(), account.Credentials);
blobContainer = blobClient.GetContainerReference(FRIEND_LIKES_BLOB_CONTAINER);
blobContainer.CreateIfNotExist();
blobContainer.SetPermissions(new BlobContainerPermissions() { PublicAccess = BlobContainerPublicAccessType.Blob });
}
示例14: InitAzureStorage
/// <summary>
/// Init Azure Storage if needed
/// </summary>
private static void InitAzureStorage()
{
if (storageAccount == null)
{
storageAccount = CloudStorageAccount.FromConfigurationSetting(connectionString);
if (blobClient == null)
{
blobClient = storageAccount.CreateCloudBlobClient();
blobContainer = blobClient.GetContainerReference(FilesFolder);
blobContainer.CreateIfNotExist();
var permissions = blobContainer.GetPermissions();
permissions.PublicAccess = BlobContainerPublicAccessType.Container;
blobContainer.SetPermissions(permissions);
}
}
}
示例15: CreateStorageContainer
private void CreateStorageContainer()
{
Log("Attaching to or creating the blob container");
_container = CloudStorageAccount
.Parse(RoleEnvironment.GetConfigurationSettingValue(WorkerRole.StorageConnectionString))
.CreateCloudBlobClient()
.GetContainerReference(WorkerRole.KinectonitorImageContainer);
_container.CreateIfNotExist();
_container.SetPermissions(new BlobContainerPermissions
{
PublicAccess = BlobContainerPublicAccessType.Blob
});
Log("Attached to the blob container");
}