Search code examples
azure-cognitive-servicesazure-cliazure-gov

Cognitive Services via CLI in Azure Government


The docs mention that it can be accessed via CLI, but there are no samples for CLI in the docs, only PowerShell.

Any advice on where to get started?


Solution

  • You can find the details on how to manage Cognitive Services in the Cognitive Services Azure CLI documentation.

    As usual with Azure Government:

    Here's a quick sample on how to get going:

    az cloud set --name AzureUSGovernment
    az login
    
    az group create -n cogstestrg -l usgovvirginia
    
    az cognitiveservices account create -n cogstestcv -g cogstestrg --sku S0 --kind ComputerVision -l usgovvirginia
    
    az cognitiveservices account show -g cogstestrg -n cogstestcv
    
    az cognitiveservices account keys list -g cogstestrg -n cogstestcv
    
    #Make sure you REPLACE_WITH_YOUR_KEY in the curl command below using the key from the previous command
    curl -v -X POST "https://virginia.api.cognitive.microsoft.us/vision/v1.0/analyze?visualFeatures=Categories,Description,Color&details=&language=en" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: REPLACE_WITH_YOUR_KEY" --data-ascii "{'url' : 'http://upload.wikimedia.org/wikipedia/commons/3/3c/Shaki_waterfall.jpg'}"