Reputation: 228
In punctual, I created about 5000 public containers. However, as I am using SAS token for blobs and containers, I will have to set private permission for all 5000 of these containers.
When I tried to set permissions for the containers in azure portal, I couldn't select all to set new permissons.
Is there an example, or documentation on how best to handle this issue?
I Solved my problem. If you have same problem, you can see my code on github. https://gist.github.com/AliYmn/75479db7d334813ff8ea76ede8b1ba86
Upvotes: 0
Views: 331
Reputation: 14324
For now in the portal if you want to change the container access level, you have to select the container one by one then set their level, there is no way to select all.
If you want to implement it you could use code to do this, I test with Microsoft.Azure.Storage.Blob v11
this could implement this, and the below is my test code.
static async Task Main(string[] args)
{
string connectionString = "connection string ";
CloudStorageAccount storageAccount;
CloudStorageAccount.TryParse(connectionString, out storageAccount);
CloudBlobClient cloudBlobClient = storageAccount.CreateCloudBlobClient();
ContainerResultSegment resultSegment = null;
BlobContinuationToken continuationToken = null;
resultSegment = await cloudBlobClient.ListContainersSegmentedAsync(continuationToken);
foreach (var container in resultSegment.Results)
{
Console.WriteLine("\tContainer:" + container.Name);
await SetPublicContainerPermissions(container);
}
}
private static async Task SetPublicContainerPermissions(CloudBlobContainer container)
{
BlobContainerPermissions permissions = await container.GetPermissionsAsync();
permissions.PublicAccess = BlobContainerPublicAccessType.Container;
await container.SetPermissionsAsync(permissions);
Console.WriteLine("Container {0} - permissions set to {1}", container.Name, permissions.PublicAccess);
}
Hope this could help you, if you still have other problem please feel free to let me know.
Upvotes: 1