Street To AZ 204 – Creating Options That Use Blob Storage
Getting Container Properties:
- az storage container present –name $containerName –account-name $storageAccountName –account-key NSs2H9xg8DIpKH8y3EeYMiIpM1zYl/K9oAlBvDnPJaOpwUuS1GIwnbllIBuWngVpUYkpzmiRHdJiybgmGR3tag==
Setting and Getting Container Metadata, the eye that the replace command overwrites the present container metadata
- az storage container metadata replace –account-name $storageAccountName –name $containerName –metadata creationType=AzureCli –auth-mode key –account-key “P3o/5qMhTrI8rJgt34SPSaeLuv7ED6Szft5kAf7hixh2UiSwltBW52CG4FejDs3nhV4t2lAE/2XEAIAsUvKorA==”
- az storage container metadata present –account-name $storageAccountName –name $containerName –auth-mode key –account-key “P3o/5qMhTrI8rJgt34SPSaeLuv7ED6Szft5kAf7hixh2UiSwltBW52CG4FejDs3nhV4t2lAE/2XEAIAsUvKorA==”
Setting and Getting Blob Metadata, consideration that the replace command overwrites the present blob metadata
- az storage blob metadata replace –name “frequent.jpg” –account-name $storageAccountName –container-name $containerName –metadata creationType=azurecli –auth-mode key –account-key “P3o/5qMhTrI8rJgt34SPSaeLuv7ED6Szft5kAf7hixh2UiSwltBW52CG4FejDs3nhV4t2lAE/2XEAIAsUvKorA==”
- az storage blob metadata present –name “frequent.jpg” –account-name $storageAccountName –container-name $containerName –auth-mode key –account-key “P3o/5qMhTrI8rJgt34SPSaeLuv7ED6Szft5kAf7hixh2UiSwltBW52CG4FejDs3nhV4t2lAE/2XEAIAsUvKorA==”
Utilizing .NET
Getting Container Properties
- personal static readonly string connectionString = “DefaultEndpointsProtocol=https;AccountName=samplestorageaccountblob;AccountKey=NSs2H9xg8DIpKH8y3EeYMiIpM1zYl/K9oAlBvDnPJaOpwUuS1GIwnbllIBuWngVpUYkpzmiRHdJiybgmGR3tag==;EndpointSuffix=core.home windows.internet”;
- personal static readonly string containerName = “sampleblobcontainer”;
- static async Activity Primary(string[] args)
- {
- Console.WriteLine(“Program began. Connecting to Blob Shopper”);
- BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
- BlobContainerClient containerClient = null;
- if (blobServiceClient.GetBlobContainers().The place(x => x.Identify == containerName).Any())
- {
- Console.WriteLine(“Blob Container Shopper discovered.”);
- containerClient = blobServiceClient.GetBlobContainerClient(containerName);
- }
- else
- {
- Console.WriteLine(“Blob Container Shopper not discovered, creating a new one.”);
- containerClient = await blobServiceClient.CreateBlobContainerAsync(containerName);
- Console.WriteLine(“Blob Container Shopper created.”);
- }
- var properties = containerClient.GetProperties();
- }
Setting and Getting Container Metadata, concentrate that the SetMetada technique overwrites the present metadata.
- personal static readonly string connectionString = “DefaultEndpointsProtocol=https;AccountName=samplestorageaccountblob;AccountKey=P3o/5qMhTrI8rJgt34SPSaeLuv7ED6Szft5kAf7hixh2UiSwltBW52CG4FejDs3nhV4t2lAE/2XEAIAsUvKorA==;EndpointSuffix=core.home windows.internet”;
- personal static readonly string containerName = “sampleblobcontainer”;
- static async Activity Primary(string[] args)
- {
- Console.WriteLine(“Program began. Connecting to Blob Shopper”);
- BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
- BlobContainerClient containerClient = null;
- if (blobServiceClient.GetBlobContainers().The place(x => x.Identify == containerName).Any())
- {
- Console.WriteLine(“Blob Container Shopper discovered.”);
- containerClient = blobServiceClient.GetBlobContainerClient(containerName);
- }
- else
- {
- Console.WriteLine(“Blob Container Shopper not discovered, creating a new one.”);
- containerClient = await blobServiceClient.CreateBlobContainerAsync(containerName);
- Console.WriteLine(“Blob Container Shopper created.”);
- }
- Dictionary<string, string> containerMetadata = new Dictionary<string, string>();
- containerMetadata.Add(“creationType”, “.Web SDK”);
- containerMetadata.Add(“seccondMetadata”, “.Web SDK”);
- containerClient.SetMetadata(containerMetadata);
- var containerProperties = containerClient.GetProperties();
- }
Setting and Getting Blob Metadata, concentrate that the SetMetada technique overwrites the present metadata.
- personal static readonly string connectionString = “DefaultEndpointsProtocol=https;AccountName=samplestorageaccountblob;AccountKey=P3o/5qMhTrI8rJgt34SPSaeLuv7ED6Szft5kAf7hixh2UiSwltBW52CG4FejDs3nhV4t2lAE/2XEAIAsUvKorA==;EndpointSuffix=core.home windows.internet”;
- personal static readonly string containerName = “sampleblobcontainer”;
- static async Activity Primary(string[] args)
- {
- Console.WriteLine(“Program began. Connecting to Blob Shopper”);
- BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
- BlobContainerClient containerClient = null;
- if (blobServiceClient.GetBlobContainers().The place(x => x.Identify == containerName).Any())
- {
- Console.WriteLine(“Blob Container Shopper discovered.”);
- containerClient = blobServiceClient.GetBlobContainerClient(containerName);
- }
- else
- {
- Console.WriteLine(“Blob Container Shopper not discovered, creating a new one.”);
- containerClient = await blobServiceClient.CreateBlobContainerAsync(containerName);
- Console.WriteLine(“Blob Container Shopper created.”);
- }
- Dictionary<string, string> blobMetadata = new Dictionary<string, string>();
- blobMetadata.Add(“creationType”, “.Web SDK”);
- blobMetadata.Add(“seccondMetadata”, “.Web SDK”);
- BlobClient consumer = containerClient.GetBlobClient(“frequent.jpg”);
- consumer.SetMetadata(blobMetadata);
- var blobMetadataValues = consumer.GetProperties().Worth.Metadata;
- }
End result from Azure Portal
Transferring gadgets between Blob Storage and Containers
You’ll be able to copy a single Blob or a Batch of Blobs, right here we can be shifting a batch of Blobs from one container to a different inside the identical Blob Storage Account.
The error right here is because of the Uncommon.jpg being rehydrated.
- az storage blob copy start-batch –account-name $storageAccountName –destination-container “anothercontainer” –source-container $containerName –account-key NSs2H9xg8DIpKH8y3EeYMiIpM1zYl/K9oAlBvDnPJaOpwUuS1GIwnbllIBuWngVpUYkpzmiRHdJiybgmGR3tag==
Transferring from one container to a different inside one other storage account.
- az storage blob copy start-batch –account-name “cloudshell325844558” –source-account-name $storageAccountName –source-container “anothercontainer” –destination-container “containeranotheraccount” –account-key Oc3mEd/80DqJ65+nxMUJb/C9nq/hre+YLdVEfXeZ7M3gvcwJ7zqB7SAzNaiRtPyOrEtYXBub9Wn4xVUgTv5BTw== –source-account-key NSs2H9xg8DIpKH8y3EeYMiIpM1zYl/K9oAlBvDnPJaOpwUuS1GIwnbllIBuWngVpUYkpzmiRHdJiybgmGR3tag==
Sizzling, Cool, and Archiving Storage
By default, if you create a Blob its entry tier is ready routinely to the one configured when creating Azure Storage. And by default, Blob Storages are created with the Sizzling Entry Tier, with a purpose to change the default entry tier of the Storage Account, examine the configuration tab beneath the settings sector.
To alter the entry tier of a blob you must individually set its new entry tier. We’re going to arrange the blobs in keeping with their requirements: frequent picture stays within the sizzling tier, not so frequent picture stays within the cool tier and the uncommon picture goes to be positioned within the archiving tier.
- az storage blob set-tier –account-name $storageAccountName –container-name $containerName –name “not so frequent.png” –tier Cool –account-key NSs2H9xg8DIpKH8y3EeYMiIpM1zYl/K9oAlBvDnPJaOpwUuS1GIwnbllIBuWngVpUYkpzmiRHdJiybgmGR3tag==
- az storage blob set-tier –account-name $storageAccountName –container-name $containerName –name “uncommon.jpg” –tier Archive –account-key NSs2H9xg8DIpKH8y3EeYMiIpM1zYl/K9oAlBvDnPJaOpwUuS1GIwnbllIBuWngVpUYkpzmiRHdJiybgmGR3tag==
Lead to Azure Portal
To maneuver one merchandise from Archive Entry Tier to a different Entry Tier you can even set the rehydrate precedence to excessive. This characteristic continues to be in preview mode.
- az storage blob set-tier –account-name $storageAccountName –container-name $containerName –name “uncommon.jpg” –tier Cool –rehydrate-priority excessive –account-key NSs2H9xg8DIpKH8y3EeYMiIpM1zYl/K9oAlBvDnPJaOpwUuS1GIwnbllIBuWngVpUYkpzmiRHdJiybgmGR3tag==
Implementing Archiving and Retention – Lifecycle Administration