Skip to content

Commit d112f98

Browse files
authoredMay 17, 2024··
Fix Python package upload (#195)
1 parent 6df3fc8 commit d112f98

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed
 

‎tools/ci_build/github/azure-pipelines/templates/packaging-pipeline-steps.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,6 @@ steps:
9393
python3 tools/python/upload_python_package_to_azure_storage.py \
9494
--python_wheel_path ${files[0]} \
9595
--account_name onnxruntimepackages \
96-
--account_key $(orttrainingpackagestorageaccountkey) \
96+
--managed_identity_client_id $(managed_identity_client_id) \
9797
--container_name '$web'
98-
displayName: "upload to nightly package channel"
98+
displayName: "upload to nightly package channel"

‎tools/python/upload_python_package_to_azure_storage.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
import os
66
import argparse
7+
from azure.identity import ManagedIdentityCredential
78
from azure.storage.blob import BlobServiceClient, ContentSettings
89

910

10-
def upload_whl(python_wheel_path, account_name, account_key, container_name):
11-
blob_service_client = BlobServiceClient(f"https://{account_name}.blob.core.windows.net",
12-
credential=account_key)
11+
def upload_whl(python_wheel_path, account_name, managed_identity_client_id, container_name):
12+
managed_identity_credential = ManagedIdentityCredential(client_id=managed_identity_client_id)
1313

14+
blob_service_client = BlobServiceClient(f"https://{account_name}.blob.core.windows.net",
15+
credential=managed_identity_credential)
1416

1517
blob_name = os.path.basename(python_wheel_path)
1618
blob_client = blob_service_client.get_blob_client(container_name, blob_name)
@@ -34,11 +36,9 @@ def upload_whl(python_wheel_path, account_name, account_key, container_name):
3436

3537
parser.add_argument("--python_wheel_path", type=str, help="path to python wheel")
3638
parser.add_argument("--account_name", type=str, help="name of the Azure storage account that is used to store package files")
37-
parser.add_argument("--account_key", type=str, help="Azure storage account access key")
39+
parser.add_argument("--managed_identity_client_id", type=str, help="Managed Identity client id to use for authentication")
3840
parser.add_argument("--container_name", type=str, help="the container name within the storage account for the packages")
3941

40-
# TODO: figure out a way to secure args.account_key to prevent later code changes
41-
# that may accidentally print out it to the console.
4242
args = parser.parse_args()
4343

44-
upload_whl(args.python_wheel_path, args.account_name, args.account_key, args.container_name)
44+
upload_whl(args.python_wheel_path, args.account_name, args.managed_identity_client_id, args.container_name)

0 commit comments

Comments
 (0)
Please sign in to comment.