Skip to content

Commit 411b1cf

Browse files
committed
feat: updated the scripts to use CLI Auth
1 parent a06eadc commit 411b1cf

File tree

8 files changed

+26
-16
lines changed

8 files changed

+26
-16
lines changed

aml_service/01-Experiment.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@
2626
import os
2727
from azureml.core import Experiment
2828
from azureml.core import Workspace
29-
29+
from azureml.core.authentication import AzureCliAuthentication
30+
cli_auth = AzureCliAuthentication()
3031

3132
def getExperiment():
32-
ws = Workspace.from_config()
33+
ws = Workspace.from_config(auth=cli_auth)
3334
script_folder = "."
3435
experiment_name = "devops-ai-demo"
3536
exp = Experiment(workspace=ws, name=experiment_name)

aml_service/02-AttachTrainingVM.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@
3333
from azureml.core.compute import RemoteCompute
3434
from azureml.core.compute import DsvmCompute
3535
from azureml.core.compute_target import ComputeTargetException
36-
36+
from azureml.core.authentication import AzureCliAuthentication
37+
cli_auth = AzureCliAuthentication()
3738

3839
# Get workspace
39-
ws = Workspace.from_config()
40+
ws = Workspace.from_config(auth=cli_auth)
4041

4142
# Read the New VM Config
4243
with open("aml_config/security_config.json") as f:

aml_service/11-TrainOnLocalEnv.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@
3232
from azureml.core import Experiment
3333
from azureml.core import ScriptRunConfig
3434

35+
from azureml.core.authentication import AzureCliAuthentication
36+
cli_auth = AzureCliAuthentication()
37+
3538
# Get workspace
36-
ws = Workspace.from_config()
39+
ws = Workspace.from_config(auth=cli_auth)
3740

3841
# Attach Experiment
3942
experiment_name = "devops-ai-demo"

aml_service/12-TrainOnVM.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@
3030
from azureml.core.runconfig import RunConfiguration
3131
from azureml.core import ScriptRunConfig
3232
import azureml.core
33+
from azureml.core.authentication import AzureCliAuthentication
3334

34-
35+
cli_auth = AzureCliAuthentication()
3536
# Get workspace
36-
ws = Workspace.from_config()
37+
ws = Workspace.from_config(auth=cli_auth)
38+
3739

3840
# Read the New VM Config
3941
with open("aml_config/security_config.json") as f:

aml_service/50-deployOnAci.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,11 @@
3030
from azureml.core.image import Image
3131
from azureml.core.webservice import Webservice
3232
from azureml.core.webservice import AciWebservice
33+
from azureml.core.authentication import AzureCliAuthentication
3334

35+
cli_auth = AzureCliAuthentication()
3436
# Get workspace
35-
ws = Workspace.from_config()
36-
37-
38-
# Get the Image to deploy details
37+
ws = Workspace.from_config(auth=cli_auth)# Get the Image to deploy details
3938
try:
4039
with open("aml_config/image.json") as f:
4140
config = json.load(f)

aml_service/51-deployOnAks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@
3030
from azureml.core.image import Image
3131
from azureml.core.compute import AksCompute, ComputeTarget
3232
from azureml.core.webservice import Webservice, AksWebservice
33+
from azureml.core.authentication import AzureCliAuthentication
3334

35+
cli_auth = AzureCliAuthentication()
3436
# Get workspace
35-
ws = Workspace.from_config()
37+
ws = Workspace.from_config(auth=cli_auth)
3638

3739
# Get the Image to deploy details
3840
try:

aml_service/60-AciWebserviceTest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
from azureml.core.image import Image
3232
from azureml.core.webservice import Webservice
3333
from azureml.core.webservice import AciWebservice
34+
from azureml.core.authentication import AzureCliAuthentication
3435

36+
cli_auth = AzureCliAuthentication()
3537
# Get workspace
36-
ws = Workspace.from_config()
37-
38+
ws = Workspace.from_config(auth=cli_auth)
3839
# Get the ACI Details
3940
try:
4041
with open("aml_config/aci_webservice.json") as f:

aml_service/61-AksWebserviceTest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@
3030
from azureml.core.model import Model
3131
from azureml.core.image import Image
3232
from azureml.core.webservice import Webservice
33+
from azureml.core.authentication import AzureCliAuthentication
3334

34-
35+
cli_auth = AzureCliAuthentication()
3536
# Get workspace
36-
ws = Workspace.from_config()
37+
ws = Workspace.from_config(auth=cli_auth)
3738

3839
# Get the AKS Details
3940
try:

0 commit comments

Comments
 (0)