示例#1
0
def get_auth():
    """Authentication to access workspace"""
    try:
        auth = AzureCliAuthentication()
        auth.get_authentication_header()
    except AuthenticationException:
        logger.info("Authentication Error Occured")

    return auth
def get_auth():
    logger = logging.getLogger(__name__)
    logger.debug("Trying to create Workspace with CLI Authentication")
    try:
        auth = AzureCliAuthentication()
        auth.get_authentication_header()
    except AuthenticationException:
        logger.debug("Trying to create Workspace with Interactive login")
        auth = InteractiveLoginAuthentication()
    return auth
示例#3
0
def get_auth():
    '''
    Authentication to access workspace
    '''
    try:
        auth = AzureCliAuthentication()
        auth.get_authentication_header()
    except AuthenticationException:
        print("Authentication Error Occured")

    return auth
示例#4
0
def get_auth():
    """
    Method to get the correct Azure ML Authentication type

    Always start with CLI Authentication and if it fails, fall back
    to interactive login
    """
    try:
        auth_type = AzureCliAuthentication()
        auth_type.get_authentication_header()
    except AuthenticationException:
        auth_type = InteractiveLoginAuthentication()
    return auth_type
示例#5
0
def get_auth():
    '''
        Retreive the user authentication. If they aren't logged in this will
        prompt the standard interactive login method. 

        PARAMS: None

        RETURNS: Authentication object
    '''
    auth = None

    print("Get auth...")
    try:
        auth = AzureCliAuthentication()
        auth.get_authentication_header()
    except AuthenticationException:
        auth = InteractiveLoginAuthentication()

    return auth
示例#6
0
from azureml.pipeline.core import PublishedPipeline
from azureml.core.authentication import AzureCliAuthentication

cli_auth = AzureCliAuthentication()

##------------- Get Workspace

subscriptionId = "<your subscription id>"  # make this a parameter
resourceGroup = "<your resource group>"  # make this a parameter
workspaceName = "<your ml workspace name>"  # make this a parameter

ws = Workspace(subscriptionId, resourceGroup, workspaceName, auth=cli_auth)

##------------- Run Published pipeline using REST endpoint

aad_token = cli_auth.get_authentication_header()
published_pipeline_id = "ab0691a9-438f-416b-a146-5c7660d1be11"  # Replace this with the published pipeline id
published_pipeline = PublishedPipeline.get(ws, published_pipeline_id)
rest_endpoint = published_pipeline.endpoint
print("Rest endpoint: " + rest_endpoint)

response = requests.post(rest_endpoint,
                         headers=aad_token,
                         json={
                             "ExperimentName": "quality_prediction_gb",
                             "RunSource": "SDK",
                             "ParameterAssignments": {
                                 "modelName": "quality_gbm_model.pkl",
                                 "datasetName": "qualitydataset",
                                 "datasetStorePath": "/inputdata/train.csv"
                             }