Banner

Getting the ML API Key in Azure Databricks

Nov 18, 2018
()

In the old days of using the Azure Machine Learning Workbench, it was easy to get the ML API Key from the portal, but currently (end of 2018) , with the retirement of the Workbench, there is no may to get the ML API key from the Azure portal.  It needs to be called through the API to get that key.

Usually, what you need is the scoring URI of your web service deployed to Azure and that is available through the API and also through the portal, so there are no problems there.

Microsoft is still in state of flux during the preview of the Machine Learning Services API and APIs change quite frequently.  For example, there used to be a function called “service.get_key()” that API no longer exists.

After deploying my webservice from a Databricks notebook successfully, I needed not only the scoring URI but also the ML API Key to be able to get a scoring from a web application that I was testing.

The new documentation states that you would need to call the get_keys() API instead that returns both the primary and secondary keys for the service.

In Python:

primary, secondary = webservice.get_keys()
print(primary)
print(secondary

But that was causing errors in my Azure Databricks Notebook with error “400 bad request” ???

But finally, I found some documentation that state that if you are deploying to Azure Kubernetes Service, authentication is enabled by default and API Keys are generated automatically but if you are using Azure Container Instances (which I was), authentication is disabled by default and NO keys will be generated for the service, which of course was a problem for me.

kdocs

So what I had to do in my notebook, is to go back to my deploy_configuration function and add a very important parameter to enable authentication in order for me to be able to get the Keys.

kae

From there, I was able to deploy my service from model and get my keys and use in my Web Application to get the scoring.

kpk

BTW, to get the scoring URI without having to go back to the portal, you can call the following API in your Databricks notebook (python):

print(webservice.scoring_uri)

Hope that saves someone some time if you are looking for your service’s API Keys.

Load more reviews
You've already submitted a review for this item
|
()

Copyright © 2018 Alain "Lino" Tadros
Using Sitefinity 11.1.6800