def register_datastore(ws, datastore, serviceprincipal_definition): if datastore["adlsgen2_datastore_name"] not in ws.datastores: #if the datastore is note registered then register it Datastore.register_azure_data_lake_gen2( workspace=ws, datastore_name=datastore["adlsgen2_datastore_name"], account_name=datastore["account_name"], # ADLS Gen2 account name filesystem=datastore["filesystem"], # ADLS Gen2 filesystem tenant_id=serviceprincipal_definition[ "tenant_id"], # tenant id of service principal client_id=serviceprincipal_definition[ "service_principal_id"], # client id of service principal client_secret=serviceprincipal_definition[ "service_principal_password"] ) # the secret of service principal print("Mounted datastore " + datastore["filesystem"] + "to workspace " + ws.name) else: print("Workspace " + ws.name + " already has datastore " + datastore["filesystem"] + " mounted.")
ct = ComputeTarget.create(ws, ct_name, compute_config) ct.wait_for_completion(show_output=True) # create aks compute targets if args.create_aks: for ct_name in akscomputes: if ct_name not in ws.compute_targets: print(f"Creating AKS compute {ct_name}") compute_config = AksCompute.provisioning_configuration( **akscomputes[ct_name]) ct = ComputeTarget.create(ws, ct_name, compute_config) ct.wait_for_completion(show_output=True) if args.datalake_name not in ws.datastores: print(f"Creating datastore {args.datalake_name}") adlsgen2_datastore = Datastore.register_azure_data_lake_gen2( workspace=ws, datastore_name=args.datalake_name, account_name=args.datalake_name, subscription_id=ws.subscription_id, resource_group=args.datalake_rg_name, filesystem="datalake", grant_workspace_access=True, ) for env_file in Path("./environments/").glob("*.yml"): print(f"Creating env {env_file.name}") env = Environment.from_conda_specification(name=env_file.name, file_path=env_file) env.register(ws)