77from azure .storage .blob import BlobServiceClient
88from azure .identity import AzurePowerShellCredential , ChainedTokenCredential , AzureCliCredential
99
10- UPLOAD_PATTERN = "{build_id}/{filename}"
11- DEFAULT_CONTAINER = os .getenv ("BLOB_CONTAINER" , "ml-sample-submissions" )
12- CONNECTION_STRING = os .getenv ("BLOB_CONNECTION_STRING" , None )
10+ UPLOAD_PATTERN = "python/distributions/ml-sample/{build_id}/{filename}"
11+ BLOB_CONTAINER = "$web"
1312
1413TEST_INSTALL_TEMPLATE = """# <az_ml_sdk_test_install>
1514{install_command}
@@ -38,7 +37,6 @@ def replace_test_install_command(content, targeted_urls):
3837 parser = argparse .ArgumentParser (
3938 description = "This python script modifies build.sh files for the azure ml samples repository. Inputs are a "
4039 + "folder containing the azure-ml whl, the root of a cloned azureml-samples repo, and an optional build id. "
41- + "Retrieves the necessary connection string from BLOB_CONNECTION_STRING."
4240 )
4341
4442 parser .add_argument (
@@ -77,7 +75,7 @@ def replace_test_install_command(content, targeted_urls):
7775 credential_chain = ChainedTokenCredential (AzureCliCredential (), AzurePowerShellCredential ())
7876
7977 blob_service_client = BlobServiceClient (account_url = f"https://{ args .storage_account_name } .blob.core.windows.net" , credential = credential_chain )
80- container_client = blob_service_client .get_container_client (DEFAULT_CONTAINER )
78+ container_client = blob_service_client .get_container_client (BLOB_CONTAINER )
8179 to_be_installed = []
8280
8381 whls = glob .glob (target_glob )
@@ -90,7 +88,12 @@ def replace_test_install_command(content, targeted_urls):
9088
9189 with open (whl , "rb" ) as data :
9290 result = blob_client .upload_blob (data = data , overwrite = True )
93- to_be_installed .append (blob_client .primary_endpoint )
91+ url = blob_client .primary_endpoint
92+
93+ # replace the original blob uri with the static website style uri
94+ # this is such that the install command can be invoked directly without needing to authenticate to the storage account
95+ url = url .replace (f"https://{ args .storage_account_name } .blob.core.windows.net/%24web/" , f"https://{ args .storage_account_name } .z5.web.core.windows.net/" )
96+ to_be_installed .append (url )
9497 else :
9598 print ("Operated on non-whl file or folder {}" .format (whl ))
9699 exit (1 )
0 commit comments