Hi @techazure Welcome to the Microsoft Q&A and thank you for posting your questions here. Sequel to your question, you would like to send a file from Azure blob to GCP storage bucket and also would want to use azure PowerShell based function and using workload identity federation as authentication. To transfer files from Azure Blob Storage to Google Cloud Storage using PowerShell and Workload Identity Federation for authentication you will need to follow a series of steps. Here's my suggested processes.
- Install the PowerShell modules:
Install-Module -Name Az.Storage -Force -AllowClobber
- Set up Workload Identity Federation: Make sure you have Workload Identity Federation configured correctly on both Azure and GCP. This involves creating service accounts assigning roles and configuring permissions as, per your requirements.
- Configure your credentials: Set up your Azure credentials using Workload Identity Federation and Configure Google Cloud Credentials. The specific commands may vary depending on your setup. Generally you will need to use the "az login" and "gcloud auth login" command. Your code will similar to:
az login --identity
gcloud auth login
- Now, you can use PowerShell commands to copy files from Azure Blob Storage to Google Cloud Storage.
# Download file from Azure Blob Storage
$storageAccountName = "<your_storage_account_name>"
$containerName = "<your_container_name>"
$blobName = "<your_blob_name>"
$localFilePath = "C:\Temp\downloaded_file.txt"
az storage blob download --account-name $storageAccountName --container-name $containerName --name $blobName --file $localFilePath
# Upload file to Google Cloud Storage
$bucketName = "<your_gcp_bucket_name>"
$gcpFilePath = "gs://$bucketName/uploaded_file.txt"
gcloud auth application-default login
gcloud storage cp $localFilePath $gcpFilePath
# Make sure to replace the placeholders <your_storage_account_name>, <your_container_name>, <your_blob_name>, and <your_gcp_bucket_name> with your actual Azure and GCP storage details.
Please note that implementing Workload Identity Federation and executing the corresponding commands can be slightly complex depending on your setup. Kindly, modify the above code tailor to your use case. I hope this is helpful! Do not hesitate to let me know if you have any other questions. Please remember to "Accept Answer" if answer helped, so that others in the community facing similar issues can easily find the solution. Best Regards, Sina Salam