Elijah M
Elijah M

Reputation: 1

HTTP Error from Deploying Endpoint from Model in Azure ML

I'm doing the code from this tutorial: https://learn.microsoft.com/en-us/azure/machine-learning/tutorial-deploy-model?view=azureml-api-2

This should deploy an endpoint from a model I already have registered. I am however getting this error:

HttpResponseError: (InvalidSubscriptionId) The provided subscription identifier '' is malformed or invalid.
Code: InvalidSubscriptionId
Message: The provided subscription identifier '' is malformed or invalid.

In particular these two lines in the code are throwing this error:

endpoint = ml_client.online_endpoints.begin_create_or_update(endpoint).result()
endpoint = ml_client.online_endpoints.get(name=online_endpoint_name)

There's absolutely nothing wrong with the subscription ID, I am having trouble figuring this out.

Is it possibly calling HTTP when it should be calling HTTPS?

I attempted to retry the subscription ID, there's nothing wrong there, even tried a different workspace.

I don't believe its an authentication problem, I am able to connect with other projects.

Upvotes: 0

Views: 537

Answers (1)

Elijah M
Elijah M

Reputation: 1

Solved the issue, utilizing a different ml_client instantiator.

Write it to JSON in notebooks:
%%writefile workspace.json
{
    "subscription_id": "6f247126-9881-4267-9635-80cd63c7b5a1",
    "resource_group": "Candidate_5_GenAI",
    "workspace_name": "candidate_5_gen_ai"
}

Then define your workspace like this, not like in the tutorial:

from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential
from azure.ai.ml import MLClient, Input, Output
from azure.ai.ml.constants import AssetTypes
from azure.ai.ml.dsl import pipeline
from azureml.core import Workspace

try:
    credential = DefaultAzureCredential()
    # Check if given credential can get token successfully.
    credential.get_token("https://management.azure.com/.default")
except Exception:
    # Fall back to InteractiveBrowserCredential in case DefaultAzureCredential not work
    credential = InteractiveBrowserCredential()

try:
    ml_client = MLClient.from_config(credential=credential, path="workspace.json")
except Exception as ex:
    raise Exception(
        "Failed to create MLClient from config file. Please modify and then run the above cell with your AzureML Workspace details."
    ) from ex
    # ml_client = MLClient(
    #     credential=credential,
    #     subscription_id="",
    #     resource_group_name="",
    #     workspace_name=""
    # )

ws = Workspace(
    subscription_id=ml_client.subscription_id,
    resource_group=ml_client.resource_group_name,
    workspace_name=ml_client.workspace_name,
)
ml_client

Upvotes: 0

Related Questions