Skip to navigation Skip to content
GeralexGR

Personal blog

  • Home
  • About
  • Contact
  • Home
  • About
  • Contact

Tag: python azure blob

Posted on February 21, 2023February 21, 2023 by geralexgr — Leave a comment

Get blob files from azure storage account using python

You can use python SDK in order to retrieve blob files from a storage account on azure. First you will need to get your connection string for the storage account from the access keys section.

Then you can execute the below python code.

import os, uuid
from azure.identity import DefaultAzureCredential
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient
connection_string = "CONNECTION_STRING"
service = BlobServiceClient.from_connection_string(connection_string)
try:
account_info = service.get_account_information()
print('Using Storage SKU: {}'.format(account_info['sku_name']))
container_client = service.get_container_client("files")
try:
for blob in container_client.list_blobs():
print("Found blob: ", blob.name)
except ResourceNotFoundError:
print("Container not found.")
except Exception as ex:
print('Exception:')
print(ex)
view raw azure-storage-get-blobs-python hosted with ❤ by GitHub

As seen from the screenshots, I have a container named files

And inside the container I have a test.txt file.

By running the python script (in my case I added on a container) you will get the files inside the blob container.

Quickstart: Azure Blob Storage client library for Python – Azure Storage | Microsoft Learn

Categories: Azure, Devops, Scripts
Tags: Azure, azure-identity, azure-storage-blob, blob, blob retrieve python, python, python azure blob, python sdk, storage, storage account
Mastering Azure Devops CI/CD Pipelines with YAML
Learn how to create advanced automation scenarios using YAML and Azure Devops: https://www.udemy.com/course/mastering-azure-devops-cicd-pipelines-with-yaml
Youtube
Subscribe on my YouTube channel for more tutorials:
Azure DevOps platform Fundamentals – Build CI/CD pipelines
Start your journey with Azure DevOps platform: https://www.udemy.com/course/azure-devops-platform-fundamentals-build-cicd-pipelines/
Adblock notice
Support this blog to maintain its operational costs by turning off Adblock or donate a small amount using the button below
Blog Stats
  • 168,339 Views

Join 6 other subscribers
Recent Posts
  • Automatic rollback procedure for Azure DevOps
  • Install kubernetes plugins with krew
  • InfluxDB Error: error authorizing query: user not authorized to execute statement ‘SHOW RETENTION POLICIES ON _internal’, requires READ on _internal
  • Get blob files from azure storage account using python
  • Run jobs with containers on Azure batch service
Top Posts
  • Error while proxying request: getting credentials: exec: executable kubelogin not found
  • Pass variables values inside terraform modules
  • Trigger Azure Devops build pipelines using REST API
  • Pass secrets as ENV variables on docker build - Azure devops
  • Parameters and variables - GitHub workflows
  • Run Unit tests for .NET applications - Azure DevOps
  • Pass parameters from build to release pipelines on Azure devops
  • Build pipeline on tag push - Azure DevOps build triggers
  • Insert and retrieve data on Azure cosmos DB - C# SDK
  • Build triggers on Azure devops pipelines
Categories
  • Ansible
  • Automation
  • Azure
  • BotFramework
  • C# & .NET
  • Cloud
  • Devops
  • Docker
  • Github
  • Infrastructure
  • Kubernetes
  • Linux
  • Monitoring
  • Scripts
  • Security
  • Terraform
  • Testing
  • UWP apps – Windows 10
  • VMware
  • Web Development
  • Windows
  • Xamarin
Tags
.net ansible api appservice app service az cli Azure azuredevops azure devops build c# centos cli command container containers dependsOn deploy devops docker git github jobs k8s kubernetes linux modules pipeline pipelines postman powershell python redhat release security storage storage account terraform variable variables visual studio vmware web app windows xamarin.forms
Archives
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • December 2019
  • August 2019
  • April 2019
  • March 2019
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • March 2018
  • July 2017
  • May 2017
  • February 2016
  • October 2015
  • August 2015
  • February 2015
  • November 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
Check out my Azure DevOps Udemy course
© GeralexGR 2023
Built with Storefront.