Custom Vision Prediction call error via Java SDK on Android studio - "Unable to Resolve Host"

Ashfak Ifham 1 Reputation point
2021-08-27T06:40:33.243+00:00

Service: - Azure Custom Vision prediction service from android studio
Documentation link - https://learn.microsoft.com/en-us/azure/cognitive-services/custom-vision-service/quickstarts/image-classification?tabs=visual-studio&pivots=programming-language-java

Issue:
While using the java version of the SDK, and following the instructions on the documentation, Im not able to query a prediction service due to below error :
Unable to resolve host "findalgea-prediction.cognitiveservices.azure.com"
I have initiated the instances as required and the system has them active in the runtime. The attached images would provide further insight on to how I have called the prediction service, how the objects have been initiated and available at the runtime, and the subsequent error after it.

The prediction call is as done on the documentation and Im not able to zero in on the root cause of the matter. Please share some insights.

Attached images for your reference.127009-debug-mode-initated-data.png127010-prediction-endpoint-error.png127028-customvision-prediction-call.png

Azure AI Custom Vision
Azure AI Custom Vision
An Azure artificial intelligence service and end-to-end platform for applying computer vision to specific domains.
235 questions
{count} votes

1 answer

Sort by: Most helpful
  1. romungi-MSFT 43,696 Reputation points Microsoft Employee
    2021-08-27T10:37:38.353+00:00

    @Ashfak Ifham I think the issue is you are trying to use the endpoint provided on Azure portal for a custom vision resource as the prediction endpoint. This is partly true because the key to your prediction endpoint request is the key of this resource. But, the endpoint is dependent on region in which your resource is created along with the project id and the iteration number which is actually published to this prediction resource.

    A very simple way to get the prediction endpoint is to create it following the below convention for a image URL or a image file respectively:

    https://<region_of_your_prediciton_resource>.api.cognitive.microsoft.com/customvision/v3.0/Prediction/<project_id>/classify/iterations/<published_iteration_name>/url     
    https://<region_of_your_prediciton_resource>.api.cognitive.microsoft.com/customvision/v3.0/Prediction/<project_id>/classify/iterations/<published_iteration_name>/image  
    

    You can also lookup the prediction endpoint from Azure custom vision portal from the predictions tab for the published iteration:

    127125-image.png