4
4
5
5
import os
6
6
import argparse
7
+ from azure .identity import ManagedIdentityCredential
7
8
from azure .storage .blob import BlobServiceClient , ContentSettings
8
9
9
10
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 )
13
13
14
+ blob_service_client = BlobServiceClient (f"https://{ account_name } .blob.core.windows.net" ,
15
+ credential = managed_identity_credential )
14
16
15
17
blob_name = os .path .basename (python_wheel_path )
16
18
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):
34
36
35
37
parser .add_argument ("--python_wheel_path" , type = str , help = "path to python wheel" )
36
38
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 " )
38
40
parser .add_argument ("--container_name" , type = str , help = "the container name within the storage account for the packages" )
39
41
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.
42
42
args = parser .parse_args ()
43
43
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