Azure / azure-cli

Azure Command-Line Interface
MIT License
3.93k stars 2.9k forks source link

"az cognitiveservices account deployment create" needs to upgrade API version to 2023-05-01 #26834

Open MarsWangyang opened 1 year ago

MarsWangyang commented 1 year ago

Describe the bug

The command is calling API version with 2022-10-01, which will break the setting of capacity to "Should be null" error when setting the --scale-type "Standard" . However, if I change the API version to 2023-05-01, the problem will be fixed though using RESTful API to change or update the capacity of AOAI model from 120 TPM (Token-Per-Minute) in default to others.

Related command

az cognitiveservices account deployment create \
   -g xxxxxxxxxx \
   -n xxxxxxxxxx \
   --deployment-name MyModel \
   --model-name text-curie-001 \
   --model-version "1"  \
   --model-format OpenAI \
   --scale-type "Standard" \
   --capacity 150 \
   --debug

or

az cognitiveservices account deployment create \
   -g xxxxxxxxxx \
   -n xxxxxxxxxx \
   --deployment-name MyModel \
   --model-name text-curie-001 \
   --model-version "1"  \
   --model-format OpenAI \
   --scale-type "Standard" \
   --scale-settings-capacity 150 \
   --debug

Errors

... cli.azure.cli.core.azclierror: (InvalidCapacity) The capacity should be null for standard deployment. Code: InvalidCapacity Message: The capacity should be null for standard deployment. az_command_data_logger: (InvalidCapacity) The capacity should be null for standard deployment. Code: InvalidCapacity Message: The capacity should be null for standard deployment. ...

Issue script & Debug output

cli.knack.cli: Command arguments: ['cognitiveservices', 'account', 'deployment', 'create', '-g', 'xxxxxxxxxxx', '-n', 'xxxxxxxxxxx', '--deployment-name', 'MyModel', '--model-name', 'text-curie-001', '--model-version', '1', '--model-format', 'OpenAI', '--scale-type', 'Standard', '--scale-settings-capacity', '150', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x10553df30>, <function OutputProducer.on_global_arguments at 0x1055c6ef0>, <function CLIQuery.on_global_arguments at 0x1060203a0>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'cognitiveservices': ['azure.cli.command_modules.cognitiveservices']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: cognitiveservices         0.034         8        31
cli.azure.cli.core: Total (1)                 0.034         8        31
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name                  Load Time    Groups  Commands  Directory
cli.azure.cli.core: Total (0)                 0.000         0         0
cli.azure.cli.core: Loaded 8 groups, 31 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : cognitiveservices account deployment create
cli.azure.cli.core: Command table: cognitiveservices account deployment create
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x106c2e9e0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/mars/.azure/commands/2023-07-07.01-30-30.cognitiveservices_account_deployment_create.90031.log'.
az_command_data_logger: command args: cognitiveservices account deployment create -g {} -n {} --deployment-name {} --model-name {} --model-version {} --model-format {} --scale-type {} --scale-settings-capacity {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x106c47370>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x106cdd090>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x106cdd1b0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x1055c6f80>, <function CLIQuery.handle_query_parameter at 0x106020430>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x106cdd120>]
cli.azure.cli.core.commands.client_factory: Getting management service client client_type=CognitiveServicesManagementClient
cli.azure.cli.core.auth.persistence: build_persistence: location='/Users/mars/.azure/msal_token_cache.json', encrypt=False
cli.azure.cli.core.auth.binary_cache: load: /Users/mars/.azure/msal_http_cache.bin
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.authority: openid_config = {'token_endpoint': 'https://login.microsoftonline.com/xxxxxxxxxxx/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/xxxxxxxxxxx/discovery/v2.0/keys', 'response_modes_supported': ['query', 'fragment', 'form_post'], 'subject_types_supported': ['pairwise'], 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 'issuer': 'https://login.microsoftonline.com/xxxxxxxxxxx/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/xxxxxxxxxxx/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/xxxxxxxxxxx/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/xxxxxxxxxxx/oauth2/v2.0/logout', 'claims_supported': ['sub', 'iss', 'cloud_instance_name', 'cloud_instance_host_name', 'cloud_graph_host_name', 'msgraph_host', 'aud', 'exp', 'iat', 'auth_time', 'acr', 'nonce', 'preferred_username', 'name', 'tid', 'ver', 'at_hash', 'c_hash', 'email'], 'kerberos_endpoint': 'https://login.microsoftonline.com/xxxxxxxxxxx/kerberos', 'tenant_region_scope': 'WW', 'cloud_instance_name': 'microsoftonline.com', 'cloud_graph_host_name': 'graph.windows.net', 'msgraph_host': 'graph.microsoft.com', 'rbac_url': 'https://pas.windows.net'}
msal.application: Broker enabled? False
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
cli.azure.cli.core.auth.msal_authentication: UserCredential.get_token: scopes=('https://management.core.windows.net//.default',), claims=None, kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: xxxxxxxxxxx
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/xxxxxxxxxxx/resourceGroups/xxxxxxxxxxx/providers/Microsoft.CognitiveServices/accounts/xxxxxxxxxxx/deployments/MyModel?api-version=2022-10-01'
cli.azure.cli.core.sdk.policies: Request method: 'PUT'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies:     'Content-Type': 'application/json'
cli.azure.cli.core.sdk.policies:     'Content-Length': '150'
cli.azure.cli.core.sdk.policies:     'Accept': 'application/json'
cli.azure.cli.core.sdk.policies:     'x-ms-client-request-id': 'xxxxxxxxxxx'
cli.azure.cli.core.sdk.policies:     'CommandName': 'cognitiveservices account deployment create'
cli.azure.cli.core.sdk.policies:     'ParameterSetName': '-g -n --deployment-name --model-name --model-version --model-format --scale-type --scale-settings-capacity --debug'
cli.azure.cli.core.sdk.policies:     'User-Agent': 'AZURECLI/2.50.0 (HOMEBREW) azsdk-python-mgmt-cognitiveservices/13.3.0 Python/3.10.12 (macOS-13.4.1-arm64-arm-64bit)'
cli.azure.cli.core.sdk.policies:     'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: {"properties": {"model": {"format": "OpenAI", "name": "text-curie-001", "version": "1"}, "scaleSettings": {"scaleType": "Standard", "capacity": 150}}}
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions/xxxxxxxxxxx/resourceGroups/xxxxxxxxxxx/providers/Microsoft.CognitiveServices/accounts/xxxxxxxxxxx/deployments/MyModel?api-version=2022-10-01 HTTP/1.1" 400 101
cli.azure.cli.core.sdk.policies: Response status: 400
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies:     'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies:     'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies:     'Content-Length': '101'
cli.azure.cli.core.sdk.policies:     'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.sdk.policies:     'Expires': '-1'
cli.azure.cli.core.sdk.policies:     'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies:     'x-ms-request-id': 'xxxxxxxxxxx'
cli.azure.cli.core.sdk.policies:     'x-envoy-upstream-service-time': '36'
cli.azure.cli.core.sdk.policies:     'Server': 'istio-envoy'
cli.azure.cli.core.sdk.policies:     'x-ms-ratelimit-remaining-subscription-writes': '1199'
cli.azure.cli.core.sdk.policies:     'x-ms-correlation-request-id': 'xxxxxxxxxxx'
cli.azure.cli.core.sdk.policies:     'x-ms-routing-request-id': 'EASTASIA:xxxxxxxxxxx'
cli.azure.cli.core.sdk.policies:     'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies:     'Date': 'Thu, 06 Jul 2023 17:30:33 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"error":{"code":"InvalidCapacity","message":"The capacity should be null for standard deployment."}}
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.50.0/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/homebrew/Cellar/azure-cli/2.50.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/opt/homebrew/Cellar/azure-cli/2.50.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/homebrew/Cellar/azure-cli/2.50.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
  File "/opt/homebrew/Cellar/azure-cli/2.50.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/homebrew/Cellar/azure-cli/2.50.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/opt/homebrew/Cellar/azure-cli/2.50.0/libexec/lib/python3.10/site-packages/azure/cli/command_modules/cognitiveservices/custom.py", line 265, in deployment_begin_create_or_update
    return client.begin_create_or_update(resource_group_name, account_name, deployment_name, dpy, polling=False)
  File "/opt/homebrew/Cellar/azure-cli/2.50.0/libexec/lib/python3.10/site-packages/azure/core/tracing/decorator.py", line 78, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/opt/homebrew/Cellar/azure-cli/2.50.0/libexec/lib/python3.10/site-packages/azure/mgmt/cognitiveservices/operations/_deployments_operations.py", line 552, in begin_create_or_update
    raw_result = self._create_or_update_initial(  # type: ignore
  File "/opt/homebrew/Cellar/azure-cli/2.50.0/libexec/lib/python3.10/site-packages/azure/mgmt/cognitiveservices/operations/_deployments_operations.py", line 413, in _create_or_update_initial
    raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
azure.core.exceptions.HttpResponseError: (InvalidCapacity) The capacity should be null for standard deployment.
Code: InvalidCapacity
Message: The capacity should be null for standard deployment.

cli.azure.cli.core.azclierror: (InvalidCapacity) The capacity should be null for standard deployment.
Code: InvalidCapacity
Message: The capacity should be null for standard deployment.
az_command_data_logger: (InvalidCapacity) The capacity should be null for standard deployment.
Code: InvalidCapacity
Message: The capacity should be null for standard deployment.
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x106c2ec20>]
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 6.330 seconds (init: 2.283, invoke: 4.047)

Expected behavior

The command should change the capacity (120 TPM in default) to the integer the user put in. e.g. 120TPM --> 150 TPM

Environment Summary

azure-cli 2.50.0

core 2.50.0 telemetry 1.0.8

Extensions: aks-preview 0.5.145 appservice-kube 0.1.8 azure-devops 0.26.0 azure-firewall 0.14.8 connectedk8s 1.3.20 containerapp 0.3.35 customlocation 0.1.3 interactive 0.5.1 k8s-extension 1.4.2 log-analytics 0.2.2 spring 1.14.0 spring-cloud 3.1.8 ssh 1.1.6

Dependencies: msal 1.22.0 azure-mgmt-resource 23.1.0b2

Additional context

yonzhan commented 1 year ago

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

johnnyreilly commented 1 year ago

Is this related to https://github.com/Azure/bicep-types-az/issues/1660 ?

MarsWangyang commented 1 year ago

@johnnyreilly Essentially yes, they also use 2022-10-01 version in AzCLI right now, which ran into the same problem as yours. I'm just afraid they might forget not only in bicep but also in AzCLI 😅

johnnyreilly commented 1 year ago

It's probably a common underlying dependency I guess - though I note @JFolberth reported general issues with 2023-05-01 so I wonder if there's other problems

navba-MSFT commented 1 year ago

Adding Service team to look into this.

kgluszczyk commented 1 year ago

Any update on this?

Same happens when offered to create deployment on https://portal.azure.com/

Screenshot 2023-07-21 at 15 26 48 Screenshot 2023-07-21 at 15 26 56