{"id":7802,"date":"2024-06-05T05:54:55","date_gmt":"2024-06-05T05:54:55","guid":{"rendered":"https:\/\/cloudlogz.com\/training_and_placement\/?p=7802"},"modified":"2024-06-05T05:55:11","modified_gmt":"2024-06-05T05:55:11","slug":"creating-containers-and-blobs-in-azure","status":"publish","type":"post","link":"https:\/\/cloudlogz.com\/training_and_placement\/creating-containers-and-blobs-in-azure\/","title":{"rendered":"Creating containers and blobs in Azure"},"content":{"rendered":"<p>Creating containers and blobs in Azure involves a series of steps that can be done through the Azure portal, Azure CLI, or programmatically using SDKs such as .NET, Python, or Java. Below are the detailed steps to create containers and blobs using different methods.<\/p>\n<h3><a href=\"https:\/\/bit.ly\/49CZHT2\" target=\"_blank\" rel=\"noopener\">Using Azure Portal<\/a><\/h3>\n<h4><a href=\"https:\/\/bit.ly\/49CZHT2\" target=\"_blank\" rel=\"noopener\">Create a Container<\/a><\/h4>\n<ol>\n<li><strong>Navigate to the Storage Account<\/strong>:\n<ul>\n<li>Log in to the <a href=\"https:\/\/portal.azure.com\/\" target=\"_new\" rel=\"noreferrer noopener\">Azure Portal<\/a>.<\/li>\n<li>Go to your storage account or create a new one.<\/li>\n<\/ul>\n<\/li>\n<li><a href=\"https:\/\/bit.ly\/49CZHT2\" target=\"_blank\" rel=\"noopener\"><strong>Create a Container<\/strong>:<\/a>\n<ul>\n<li>In the left-hand menu, under the &#8220;Data storage&#8221; section, click on &#8220;Containers&#8221;.<\/li>\n<li>Click on the &#8220;+ Container&#8221; button.<\/li>\n<li>Provide a name for your container.<\/li>\n<li>Set the public access level (Private, Blob, or Container).<\/li>\n<li>Click &#8220;Create&#8221;.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h4><a href=\"https:\/\/bit.ly\/49CZHT2\" target=\"_blank\" rel=\"noopener\">Upload a Blob<\/a><\/h4>\n<ol>\n<li><a href=\"https:\/\/bit.ly\/49CZHT2\" target=\"_blank\" rel=\"noopener\"><strong>Navigate to the Container<\/strong>:<\/a>\n<ul>\n<li>Click on the container you just created.<\/li>\n<\/ul>\n<\/li>\n<li><a href=\"https:\/\/bit.ly\/49CZHT2\" target=\"_blank\" rel=\"noopener\"><strong>Upload a Blob<\/strong>:<\/a>\n<ul>\n<li>Click on the &#8220;Upload&#8221; button.<\/li>\n<li>Select the file you want to upload.<\/li>\n<li>Set the required options and click &#8220;Upload&#8221;.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3><a href=\"https:\/\/bit.ly\/49CZHT2\" target=\"_blank\" rel=\"noopener\">Using Azure CLI<\/a><\/h3>\n<h4><a href=\"https:\/\/bit.ly\/49CZHT2\" target=\"_blank\" rel=\"noopener\">Prerequisites<\/a><\/h4>\n<ul>\n<li>Install the <a href=\"https:\/\/docs.microsoft.com\/en-us\/cli\/azure\/install-azure-cli\" target=\"_new\" rel=\"noreferrer noopener\">Azure CLI<\/a>.<\/li>\n<li>Sign in to Azure using <code>az login<\/code>.<\/li>\n<\/ul>\n<h4><a href=\"https:\/\/bit.ly\/49CZHT2\" target=\"_blank\" rel=\"noopener\"><em>Create a Container<\/em><\/a><\/h4>\n<p># Replace &lt;storage-account-name&gt; and &lt;container-name&gt; with your values<br \/>\naz storage container create \\<br \/>\n&#8211;account-name &lt;storage-account-name&gt; \\<br \/>\n&#8211;name &lt;container-name&gt;<\/p>\n<h4><a href=\"https:\/\/bit.ly\/49CZHT2\" target=\"_blank\" rel=\"noopener\"><em>Upload a Blob<\/em><\/a><\/h4>\n<p># Replace &lt;storage-account-name&gt;, &lt;container-name&gt;, and &lt;file-path&gt; with your values<br \/>\naz storage blob upload \\<br \/>\n&#8211;account-name &lt;storage-account-name&gt; \\<br \/>\n&#8211;container-name &lt;container-name&gt; \\<br \/>\n&#8211;name &lt;blob-name&gt; \\<br \/>\n&#8211;file &lt;file-path&gt;<\/p>\n<h3><a href=\"https:\/\/bit.ly\/49CZHT2\" target=\"_blank\" rel=\"noopener\">Using Python SDK<\/a><\/h3>\n<h4><a href=\"https:\/\/bit.ly\/49CZHT2\" target=\"_blank\" rel=\"noopener\">Prerequisites<\/a><\/h4>\n<ul>\n<li>Install the Azure Storage Blob SDK for Python:<\/li>\n<\/ul>\n<p>pip install azure-storage-blob<\/p>\n<p><em>Create a Container and Upload a Blob<\/em><\/p>\n<p>from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient<\/p>\n<p># Replace with your connection string<br \/>\nconnection_string = &#8220;your_connection_string&#8221;<\/p>\n<p># Create the BlobServiceClient object<br \/>\nblob_service_client = BlobServiceClient.from_connection_string(connection_string)<\/p>\n<p># Create a container<br \/>\ncontainer_name = &#8220;your_container_name&#8221;<br \/>\ncontainer_client = blob_service_client.create_container(container_name)<\/p>\n<p># Upload a blob<br \/>\nblob_name = &#8220;your_blob_name&#8221;<br \/>\nblob_client = blob_service_client.get_blob_client(container=container_name, blob=blob_name)<\/p>\n<p># Open the file and upload<br \/>\nwith open(&#8220;your_file_path&#8221;, &#8220;rb&#8221;) as data:<br \/>\nblob_client.upload_blob(data)<\/p>\n<h3><a href=\"https:\/\/bit.ly\/49CZHT2\" target=\"_blank\" rel=\"noopener\">Using .NET SDK<\/a><\/h3>\n<h4><a href=\"https:\/\/bit.ly\/49CZHT2\" target=\"_blank\" rel=\"noopener\">Prerequisites<\/a><\/h4>\n<ul>\n<li>Install the Azure.Storage.Blobs package:<\/li>\n<\/ul>\n<p>dotnet add package Azure.Storage.Blobs<\/p>\n<h4><a href=\"https:\/\/bit.ly\/49CZHT2\" target=\"_blank\" rel=\"noopener\"><em>Create a Container and Upload a Blob<\/em><\/a><\/h4>\n<p>using Azure.Storage.Blobs;<br \/>\nusing System;<br \/>\nusing System.IO;<br \/>\nusing System.Threading.Tasks;<\/p>\n<p>class Program<br \/>\n{<br \/>\nprivate static string connectionString = &#8220;your_connection_string&#8221;;<\/p>\n<p>static async Task Main(string[] args)<br \/>\n{<br \/>\n\/\/ Create the BlobServiceClient<br \/>\nBlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);<\/p>\n<p>\/\/ Create a container<br \/>\nstring containerName = &#8220;your_container_name&#8221;;<br \/>\nBlobContainerClient containerClient = await blobServiceClient.CreateBlobContainerAsync(containerName);<\/p>\n<p>\/\/ Upload a blob<br \/>\nstring blobName = &#8220;your_blob_name&#8221;;<br \/>\nBlobClient blobClient = containerClient.GetBlobClient(blobName);<\/p>\n<p>\/\/ Open the file and upload<br \/>\nusing FileStream uploadFileStream = File.OpenRead(&#8220;your_file_path&#8221;);<br \/>\nawait blobClient.UploadAsync(uploadFileStream, true);<br \/>\nuploadFileStream.Close();<br \/>\n}<br \/>\n}<\/p>\n<p>These are the common methods for creating containers and uploading blobs in Azure Storage. Each method can be further customized based on specific needs and requirements.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating containers and blobs in Azure involves a series of steps that can be done through the Azure portal, Azure CLI, or programmatically using SDKs such as .NET, Python, or Java. Below are the detailed steps to create containers and blobs using different methods. Using Azure Portal Create a Container Navigate to the Storage Account:&#8230;<\/p>\n","protected":false},"author":1,"featured_media":7374,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7802","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/cloudlogz.com\/training_and_placement\/wp-json\/wp\/v2\/posts\/7802","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudlogz.com\/training_and_placement\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudlogz.com\/training_and_placement\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudlogz.com\/training_and_placement\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudlogz.com\/training_and_placement\/wp-json\/wp\/v2\/comments?post=7802"}],"version-history":[{"count":2,"href":"https:\/\/cloudlogz.com\/training_and_placement\/wp-json\/wp\/v2\/posts\/7802\/revisions"}],"predecessor-version":[{"id":7804,"href":"https:\/\/cloudlogz.com\/training_and_placement\/wp-json\/wp\/v2\/posts\/7802\/revisions\/7804"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudlogz.com\/training_and_placement\/wp-json\/wp\/v2\/media\/7374"}],"wp:attachment":[{"href":"https:\/\/cloudlogz.com\/training_and_placement\/wp-json\/wp\/v2\/media?parent=7802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudlogz.com\/training_and_placement\/wp-json\/wp\/v2\/categories?post=7802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudlogz.com\/training_and_placement\/wp-json\/wp\/v2\/tags?post=7802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}