Actually, you can use DefaultAzureCredential for authentication when writing a Python script. ClientSecretCredential and DefaultAzureCredential are both part of the azure-identity library and are used for authentication in Azure. ClientSecretCredential is a more direct method that requires specific details (client ID, client secret, and tenant ID), while DefaultAzureCredential is a more flexible method that can handle a variety of scenarios. DefaultAzureCredential is a class that provides a simplified authentication experience. It’s designed to interactively authenticate your development environment, a managed identity, or a service principal. It sequentially checks for the availability of multiple credential types and uses the first one it finds. This makes it a more flexible option when you’re unsure of the environment in which your code will be run. I will try to cover it in my future videos !
Yes, it is possible to copy blobs from one storage account to another between different tenants. We can try something like this : from azure.storage.blob import BlobServiceClient # Create BlobServiceClient for source and target storage accounts source_blob_service_client = BlobServiceClient(account_url=".blob.core.windows.net", credential="") target_blob_service_client = BlobServiceClient(account_url=".blob.core.windows.net", credential="") # Get the container client for the source and target containers source_container_client = source_blob_service_client.get_container_client("") target_container_client = target_blob_service_client.get_container_client("") # List all blobs in the source container blobs_list = source_container_client.list_blobs() # Copy each blob from the source container to the target container for blob in blobs_list: source_blob_url = source_blob_service_client.make_blob_url("", blob.name) copied_blob = target_container_client.get_blob_client(blob.name) copied_blob.start_copy_from_url(source_blob_url)
Please refer this. ruclips.net/video/Vs3wyFk9upo/видео.html Search for Microsoft Entra ID instead of Azure Active Directroy. This service has been renamed.
You can do it very easily. We just need to loop over the list of the blobs and print the properties. for blob in container_client.list_blobs(): print(f"Blob name: {blob.name}") print(f"Blob size: {blob.size} bytes")
Awesome Explanation
I searched for many resources, but couldn't find a good one like this
i have one word for this guy: "kamaaal"
Awesome explanation Thank you.
Looking for good vedios further
It’s really detailed video.
Thanks for sharing knowledge!!
Glad it was helpful!
Thank you so much for this detailed tutorial
Most welcome 😊
Thanks for your video. It's really useful
Perfect resource, love your work
GREAT
When i am executing with excel file it is getting encrypted in o/p
How to tackle that
So, if i need to locally write a python script to connect to Azure storage from a linux box, I cannot use DefaultAzureCredential for authentication
Actually, you can use DefaultAzureCredential for authentication when writing a Python script. ClientSecretCredential and DefaultAzureCredential are both part of the azure-identity library and are used for authentication in Azure.
ClientSecretCredential is a more direct method that requires specific details (client ID, client secret, and tenant ID), while DefaultAzureCredential is a more flexible method that can handle a variety of scenarios.
DefaultAzureCredential is a class that provides a simplified authentication experience. It’s designed to interactively authenticate your development environment, a managed identity, or a service principal. It sequentially checks for the availability of multiple credential types and uses the first one it finds. This makes it a more flexible option when you’re unsure of the environment in which your code will be run.
I will try to cover it in my future videos !
Thanks for knowledge sharing, can we copy blobs from one storage account to other between different Tenants.
Yes, it is possible to copy blobs from one storage account to another between different tenants.
We can try something like this :
from azure.storage.blob import BlobServiceClient
# Create BlobServiceClient for source and target storage accounts
source_blob_service_client = BlobServiceClient(account_url=".blob.core.windows.net", credential="")
target_blob_service_client = BlobServiceClient(account_url=".blob.core.windows.net", credential="")
# Get the container client for the source and target containers
source_container_client = source_blob_service_client.get_container_client("")
target_container_client = target_blob_service_client.get_container_client("")
# List all blobs in the source container
blobs_list = source_container_client.list_blobs()
# Copy each blob from the source container to the target container
for blob in blobs_list:
source_blob_url = source_blob_service_client.make_blob_url("", blob.name)
copied_blob = target_container_client.get_blob_client(blob.name)
copied_blob.start_copy_from_url(source_blob_url)
What if I have ADLS Gen2 and not Blob storage.
Can you please also make a video on how to read data from ADLS Gen2 (HNS enabled)
Thanks for the ask. Let me look into it.
can you please share the link of service principle part ?
Please refer this.
ruclips.net/video/Vs3wyFk9upo/видео.html
Search for Microsoft Entra ID instead of Azure Active Directroy. This service has been renamed.
bro how do I download the size of the file ,here the file size is 22bytes, how to write the script which says the file name and the file byte size
You can do it very easily. We just need to loop over the list of the blobs and print the properties.
for blob in container_client.list_blobs():
print(f"Blob name: {blob.name}")
print(f"Blob size: {blob.size} bytes")
How to save this file?
Are you looking to save file on your local ? Could you please explain a bit.
bro awesome , needs some help how to connect with you
Thanks ! You can email. Please go to About -> Business Inquiries -> View Email to get email ID.