Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"cognitiveservices account create" has variable lag in keys? #29674

Closed
thomasnield opened this issue Aug 7, 2024 · 2 comments
Closed

"cognitiveservices account create" has variable lag in keys? #29674

thomasnield opened this issue Aug 7, 2024 · 2 comments
Labels
Auto-Assign Auto assign by bot Auto-Resolve Auto resolve by bot Cognitive Services az cognitiveservices customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team. Upgrade az upgrade

Comments

@thomasnield
Copy link

Describe the bug

Hi Azure CLI team,

I've developed some Azure interactive training scenarios for O'Reilly Media on Azure CLI. My colleagues and I have noticed that after running a Cognitive Services account creation like this...

az cognitiveservices account create \
    --name lesson21translater \
    --resource-group $resource \
    --kind TextTranslation \
    --sku F0 \
    --location eastus \
    --yes

And we successfully extract the key like this:

my_key=$(az cognitiveservices account keys list \
    --name lesson21translater \
    --resource-group $resource \
    --query 'key1')

echo $my_key

And we have a Python file to use the service like this:

import requests, uuid, json, sys

# Add your subscription key and endpoint
subscription_key = sys.argv[1].strip('"')

endpoint = "https://api.cognitive.microsofttranslator.com"


# Add your location, also known as region. The default is global.
# This is required if using a Cognitive Services resource.
location = "eastus"

path = '/translate'
constructed_url = endpoint + path

params = {
    'api-version': '3.0',
    'from': 'en',
    'to': ['de', 'it']
}
constructed_url = endpoint + path

headers = {
    'Ocp-Apim-Subscription-Key': subscription_key,
    'Ocp-Apim-Subscription-Region': location,
    'Content-type': 'application/json',
    'X-ClientTraceId': str(uuid.uuid4())
}

# You can pass more than one object in body.
body = [{
    'text': 'Hello World!'
}]

request = requests.post(constructed_url, params=params, headers=headers, json=body)
response = request.json()

print(json.dumps(response, sort_keys=True, ensure_ascii=False, indent=4, separators=(',', ': ')))

I get an error object with "code" 401001 indicating the key does not exist. However, if we wait for a variable amount of time, anywhere from 2 minutes to as much of an hour, the key will then be seen. It's like there is an unpredictable, variable lag for when the key is ready.

It's one thing if there's a predictable lag, but a lag with that variance is not ideal to document. Is this a bug or just how the design on the backend works?

Related command

cognitiveservices account create

Errors

{
"error": {
"code": 401001,
"message": "The request is not authorized because credentials are missing or invalid."
}
}

Issue script & Debug output

python3 translate.py $my_key --debug
/usr/lib/python3/dist-packages/requests/init.py:89: RequestsDependencyWarning: urllib3 (2.2.2) or chardet (3.0.4) doesn't match a supported version!
warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
{
"error": {
"code": 401001,
"message": "The request is not authorized because credentials are missing or invalid."
}
}

Expected behavior

Ideally the cognitiveservices account create should not complete until the keys are ready to use. If they cannot, the lag should at least take a deterministic amount of time. With any lag, it should be documented to the user to expect the lag so they don't think the service is broken or they did something wrong.

Environment Summary

azure-cli 2.62.0 *

core 2.62.0 *
telemetry 1.1.0

Extensions:
account 0.2.5
ad 0.1.0
aem 0.3.0
arcdata 1.5.16
authV2 0.1.3
azure-devops 1.0.1
azure-firewall 1.1.0
azure-iot 0.24.0
baremetal-infrastructure 2.0.1
communication 1.9.3
connectedk8s 1.9.0
connectedmachine 1.0.0b1
costmanagement 0.3.0
customlocation 0.1.3
databox 1.1.0
databricks 1.0.0
datafactory 1.0.2
desktopvirtualization 1.0.0
dev-spaces 1.0.6
express-route-cross-connection 0.1.1
front-door 1.2.0
healthcareapis 0.4.0
hpc-cache 0.1.5
image-copy-extension 0.2.13
k8s-configuration 2.0.0
k8s-extension 1.6.1
kusto 0.5.0
managementpartner 0.1.3
ml 2.28.0
monitor-control-service 1.2.0
peering 0.2.1
rdbms-connect 1.0.6
redisenterprise 1.0.0
resource-graph 2.1.0
sap-hana 0.6.5
sentinel 0.2.0
spring 1.25.0
spring-cloud 3.1.8
ssh 2.0.5
stack-hci 1.1.0
storagesync 1.0.0
support 2.0.0
timeseriesinsights 1.0.0b1
vm-repair 1.0.7
vmware 6.0.1
webpubsub 1.4.0

Dependencies:
msal 1.28.1
azure-mgmt-resource 23.1.1

Python location '/opt/az/bin/python3'
Extensions directory '/root/.azure/cliextensions'

Python (Linux) 3.11.8 (main, Jul 4 2024, 02:23:43) [GCC 9.4.0]

Legal docs and information: aka.ms/AzureCliLegal

You have 2 update(s) available. Consider updating your CLI installation with 'az upgrade'

Additional context

We are running this with an O'Reilly training environment.
https://learning.oreilly.com/interactive-lab/cognitive-services-ai/9781098131371/lab/

@thomasnield thomasnield added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Aug 7, 2024
Copy link

Hi @thomasnield,

This is not the official Azure CLI published by Microsoft.

How to tell if the installed Azure CLI is unofficial:

Please follow https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux to install Microsoft official Azure CLI.

If you feel that further discussion is needed, please add a comment with the text /clibot unresolve to reopen the issue.

@azure-client-tools-bot-prd azure-client-tools-bot-prd bot added the Auto-Resolve Auto resolve by bot label Aug 7, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. Auto-Assign Auto assign by bot Upgrade az upgrade labels Aug 7, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added Azure CLI Team The command of the issue is owned by Azure CLI team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Cognitive Services az cognitiveservices Service Attention This issue is responsible by Azure service team. labels Aug 7, 2024
@yonzhan
Copy link
Collaborator

yonzhan commented Aug 7, 2024

Thank you for opening this issue, we will look into it.

@yonzhan yonzhan removed bug This issue requires a change to an existing behavior in the product in order to be resolved. Azure CLI Team The command of the issue is owned by Azure CLI team labels Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot Auto-Resolve Auto resolve by bot Cognitive Services az cognitiveservices customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team. Upgrade az upgrade
Projects
None yet
Development

No branches or pull requests

3 participants