Azure / azure-cli

Azure Command-Line Interface
MIT License
3.96k stars 2.94k forks source link

az cognitiveservices account keys list --name returns : Operation returned an invalid status 'Bad Request' #25686

Closed ezYakaEagle442 closed 1 year ago

ezYakaEagle442 commented 1 year ago

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

Related command

az cognitiveservices account keys list

Describe the bug

az cognitiveservices account keys list dies not returns the keys

To Reproduce

openAiCognitiveServiceName=$(az deployment group show --name openai -g ${{ env.RG_APP }} --query properties.outputs.openAiCognitiveServiceName.value -o tsv)
echo "openAiCognitiveServiceName" $openAiCognitiveServiceName

openAiCognitiveServiceId=$(az deployment group show --name openai -g ${{ env.RG_APP }} --query properties.outputs.openAiCognitiveServiceId.value -o tsv)
echo "openAiCognitiveServiceId" $openAiCognitiveServiceId

az cognitiveservices account keys list --name $openAiCognitiveServiceName -g ${{ env.RG_APP }} 

OPEN_AI_KEY1=$(az cognitiveservices account keys list --name $openAiCognitiveServiceName -g ${{ env.RG_APP }} --query "key1" | tr -d '"')
Operation returned an invalid status 'Bad Request'
az cognitiveservices account keys list --name $openAiCognitiveServiceName -g ${{ env.RG_APP }} --debug
cli.knack.cli: Command arguments: ['cognitiveservices', 'account', 'keys', 'list', '--name', 'cog-openai-reddog7wwufb7rkg2oe-dev\r', '-g', 'rg-aca-reddog-quarkus', '--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 0x02F1A418>, <function OutputProducer.on_global_arguments at 0x03268BB0>, <function CLIQuery.on_g
lobal_arguments at 0x03285808>]
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.004         8        31
cli.azure.cli.core: Total (1)                 0.004         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 keys list
cli.azure.cli.core: Command table: cognitiveservices account keys list
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x03D27DF0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\bob\.azure\commands\2023-03-05.12-02-26.cognitiveservices_account_keys_list.33660.log'.
az_command_data_logger: command args: cognitiveservices account keys list --name {} -g {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x03D4DFA0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x03D530B8>, <function register_cache_arguments.<locals>.add_cache_arguments
at 0x03D5F610>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x03268BF8>, <function CLIQuery.handle_query_parameter at 0x03285850>, <function register_ids_arg
ument.<locals>.parse_ids_arguments at 0x03D5F5C8>]
cli.azure.cli.core.commands.client_factory: Getting management service client client_type=CognitiveServicesManagementClient
cli.azure.cli.core.auth.persistence: build_persistence: location='C:\\Users\\bob\\.azure\\msal_token_cache.bin', encrypt=True
cli.azure.cli.core.auth.binary_cache: load: C:\Users\bob\.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/42424242424242/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_po
st', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/42424242424242/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/42424242424242/v2.0', 'request_uri_parameter_supported': False, 'userinfo
_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/42424242424242/oauth2/v2.0/authorize', 'device_authorization_e
ndpoint': 'https://login.microsoftonline.com/42424242424242/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': '
https://login.microsoftonline.com/42424242424242/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/7744
e593-db09-4d56-bcbd-c874c9323670/kerberos', 'tenant_region_scope': 'NA', '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: e4653e77-753d-47ba-907f-22d9ac1c13c2
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/212121212121/resourceGroups/rg-aca-reddog-quarkus/providers/Microsoft.CognitiveServices/
accounts/cog-openai-reddog7wwufb7rkg2oe-dev%0D/listKeys?api-version=2022-10-01'
cli.azure.cli.core.sdk.policies: Request method: 'POST'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies:     'Accept': 'application/json'
cli.azure.cli.core.sdk.policies:     'x-ms-client-request-id': '36c1aa61-bb45-11ed-bdb1-a02942ae5ee7'
cli.azure.cli.core.sdk.policies:     'CommandName': 'cognitiveservices account keys list'
cli.azure.cli.core.sdk.policies:     'ParameterSetName': '--name -g --debug'
cli.azure.cli.core.sdk.policies:     'User-Agent': 'AZURECLI/2.45.0 azsdk-python-mgmt-cognitiveservices/13.3.0 Python/3.10.8 (Windows-10-10.0.22621-SP0)'
cli.azure.cli.core.sdk.policies:     'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: This request has no body
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "POST /subscriptions/212121212121/resourceGroups/rg-aca-reddog-quarkus/providers/Microsoft.CognitiveServices/accounts/cog
-openai-reddog7wwufb7rkg2oe-dev%0D/listKeys?api-version=2022-10-01 HTTP/1.1" 400 324
cli.azure.cli.core.sdk.policies: Response status: 400
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies:     'Content-Type': 'text/html; charset=us-ascii'
cli.azure.cli.core.sdk.policies:     'Server': 'Microsoft-HTTPAPI/2.0'
cli.azure.cli.core.sdk.policies:     'Date': 'Sun, 05 Mar 2023 11:02:26 GMT'
cli.azure.cli.core.sdk.policies:     'Connection': 'close'
cli.azure.cli.core.sdk.policies:     'Content-Length': '324'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid URL</h2>
<hr><p>HTTP Error 400. The request URL is invalid.</p>
</BODY></HTML>

azure.mgmt.cognitiveservices._serialization: Ran into a deserialization error. Ignoring since this is failsafe deserialization
Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/mgmt/cognitiveservices/_serialization.py", line 1433, in _deserialize
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/mgmt/cognitiveservices/_serialization.py", line 1180, in rest_key_extractor
AttributeError: 'str' object has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/mgmt/cognitiveservices/_serialization.py", line 1506, in failsafe_deserialize
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/mgmt/cognitiveservices/_serialization.py", line 1378, in __call__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/mgmt/cognitiveservices/_serialization.py", line 1448, in _deserialize
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/core/exceptions.py", line 78, in raise_with_traceback
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/mgmt/cognitiveservices/_serialization.py", line 1433, in _deserialize
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/mgmt/cognitiveservices/_serialization.py", line 1180, in rest_key_extractor
azure.core.exceptions.DeserializationError: (", AttributeError: 'str' object has no attribute 'get'", 'Unable to deserialize to object: type', AttributeError("'str' object has no attribute 'get'"))
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 663, in execute
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 697, in _run_job
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 333, in __call__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/core/tracing/decorator.py", line 73, in wrapper_use_tracer
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/mgmt/cognitiveservices/operations/_accounts_operations.py", line 1244, in list_keys
azure.core.exceptions.HttpResponseError: Operation returned an invalid status 'Bad Request'
Content: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid URL</h2>
<hr><p>HTTP Error 400. The request URL is invalid.</p>
</BODY></HTML>

cli.azure.cli.core.azclierror: Operation returned an invalid status 'Bad Request'
az_command_data_logger: Operation returned an invalid status 'Bad Request'
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x03D27F10>]
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 0.852 seconds (init: 0.459, invoke: 0.392)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 3296 in cache
telemetry.check: Negative: The C:\Users\bob\.azure\telemetry.txt was modified at 2023-03-05 12:02:04.967703, which in less than 600.000000 s

Expected behavior

Environment summary

VSCode/Terminal/WSL2/Ubuntu2204

 az version
{
  "azure-cli": "2.45.0",
  "azure-cli-core": "2.45.0",
  "azure-cli-telemetry": "1.0.8",
  "extensions": {
    "spring": "1.6.8"
  }
}

Additional context

see :

ezYakaEagle442 commented 1 year ago

I share with you the Bicep template so that yo ucan test :

@description('A UNIQUE name')
@maxLength(33)
param appName string = 'reddog${uniqueString(resourceGroup().id, subscription().id)}'

@description('The location of the Azure resources.')
param location string = resourceGroup().location

// az cognitiveservices account list-skus -l westeurope --query  "kind[?kind == 'CognitiveServices']".name
// https://github.com/Azure/azure-resource-manager-schemas/blob/main/schemas/2022-12-01/Microsoft.CognitiveServices.json
// these are generic parameters of a shared schema, and aren't relevant for Cognitive Services
// The schema doesn't validate anything in these fields beyond the type
@description('The Cognitive Service Account SKU Name. Ex: P3. It is typically a letter+number code. Test with az cognitiveservices account list-skus --help')
@allowed([
  'F0'
  'S0'
  'S1'
  'S2'
  'S3'
  'S4'
  'C2'
  'C3'
  'C4'
  'D3'
])
param skuName string = 'S0'

/*
@description('The Cognitive Service Account SKU Capacity')
@allowed([

])
param skuCapacity string =

@description('The Cognitive Service Account SKU Family')
@allowed([

])
param skuFamily string =

@description('The Cognitive Service Account SKU Size')
@allowed([

])
param skuSize string =
*/

@description('The Cognitive Service Account SKU Tier')
@allowed([
  'Basic'
  'Enterprise'
  'Free'
  'Premium'
  'Standard'
])
param skuTier string = 'Standard'

@description('The Cognitive Service Account Kind. Test with az cognitiveservices account list-kinds')
@allowed( [
  'OpenAI'
  'CognitiveServices'
  'Face'
  'SpeechServices'
])
param cognitiveServicesKind string = 'OpenAI'

@description('The VNet rules to whitelist for the Cognitive Service Account')
param  vNetRules array = []

@description('The IP rules to whitelist for the Cognitive Service Account')
param  ipRules array = []

param customsubdomain string = 'quarkusrocks.com'

@secure()
param aadClientId string

@secure()
param aadTenantId string = subscription().tenantId

@description('The Storage Account name, Storage account name must be between 3 and 24 characters in length and use numbers and lower-case letters only')
param azureStorageName string = 'sta${appName}'

@description('The Azure OpenAI Cognitive Service Identity name, see Character limit: 3-128 Valid characters: Alphanumerics, hyphens, and underscores')
param openAIIdentityName string = 'id-aca-${appName}-openai-dev-${location}-101'

@description( 'The OpenAI Cognitive Service name. cog-<project, app or service>-<environment>. Ex: cog-navigator-prod')
param openAiCognitiveServiceName string = 'cog-openai-${appName}-dev'

resource openAIIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2022-01-31-preview' existing = {
  name: openAIIdentityName
}

@description('The Tags. See https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/tag-resources?tabs=bicep#apply-an-object')
param tags object = {
  Environment: 'Dev'
  Dept: 'IT'
  Scope: 'EU'
  CostCenter: '42'
  Owner: 'Reddog'
}

@description('The Azure Strorage Identity name, see Character limit: 3-128 Valid characters: Alphanumerics, hyphens, and underscores')
param storageIdentityName string = 'id-aca-${appName}-strorage-dev-${location}-101'

resource storageIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2022-01-31-preview' existing = {
  name: storageIdentityName
}

resource azurestorage 'Microsoft.Storage/storageAccounts@2022-09-01' existing = {
  name: azureStorageName
}

// https://learn.microsoft.com/en-us/azure/templates/microsoft.cognitiveservices/accounts?pivots=deployment-language-bicep
resource openAiCognitiveService 'Microsoft.CognitiveServices/accounts@2022-12-01' = {
  kind: cognitiveServicesKind // az cognitiveservices account list-kinds --help
  name: openAiCognitiveServiceName
  location: location
  tags: tags
  identity: {
    type: 'UserAssigned'
    userAssignedIdentities: {
      '${openAIIdentity.id}': {}
    }
  }  
  sku: {
    name: skuName
    tier: skuTier
    //capacity: skuCapacity
    //family: skuFamily
    //size: skuSize
  }  
  properties: {
    /*
    apiProperties: {
      aadClientId: aadClientId
      aadTenantId: aadTenantId
      storageAccountConnectionString: azurestorage.listKeys().keys[0].value
    }
    locations: {
      regions: [
        {
          // customsubdomain: customsubdomain
          name: location
          value: 100
        }
      ]
      routingMethod: 'Weighted'
    }
    */
    networkAcls: {
      defaultAction: 'Deny'
      ipRules:  [for ipRule in ipRules: {
          value: ipRule
      }]
      virtualNetworkRules:  [for vNetId in vNetRules: {
          id: vNetId
          ignoreMissingVnetServiceEndpoint: true
          // state:
        }]
    }
    publicNetworkAccess: 'Disabled'
    restore: false
    restrictOutboundNetworkAccess: false
    /*
    userOwnedStorage: [
      {
        identityClientId: storageIdentity.properties.clientId
        resourceId: azurestorage.id
      }
    ]
    */
  }     
}

output openAiCognitiveServiceId string = openAiCognitiveService.id
output openAiCognitiveServiceName string = openAiCognitiveService.name
output openAiCognitiveServiceKind string = openAiCognitiveService.kind
output openAiCognitiveServiceEndpoint string = openAiCognitiveService.properties.endpoint
//output openAiCognitiveServiceUserOwnedStorageResourceId string = openAiCognitiveService.properties.userOwnedStorage[0].resourceId
//output openAiCognitiveServiceSuperUser string = openAiCognitiveService.properties.apiProperties.superUser
// output openAiCognitiveServiceKey string = openAiCognitiveService.listKeys().key1

resource openAIADAModel 'Microsoft.CognitiveServices/accounts/deployments@2022-12-01' = {
  name: 'open-ai-ada-001'
  parent: openAiCognitiveService
  properties: {
    model: {
      format: 'OpenAI'
      name: 'text-ada-001'
      version: '1'
    }
    scaleSettings: {
      scaleType: 'Standard'
    }
  }
}

output openAIADAModelName string = openAIADAModel.name
output openAIADAModelId string = openAIADAModel.id
output openAIADAModelFormat string = openAIADAModel.properties.model.format

resource openAIDavinciModel 'Microsoft.CognitiveServices/accounts/deployments@2022-12-01' = {
  name: 'text-davinci-002'
  parent: openAiCognitiveService
  dependsOn: [
    openAIADAModel
  ]  
  properties: {
    model: {
      format: 'OpenAI'
      name: 'text-davinci-002'
      version: '1'
    }
    scaleSettings: {
      scaleType: 'Standard'
    }
  }
}

output openAIDavinciModelName string = openAIDavinciModel.name
output openAIDavinciModelId string = openAIDavinciModel.id
output openAIDavinciModelFormat string = openAIDavinciModel.properties.model.format
yonzhan commented 1 year ago

route to CXP team

navba-MSFT commented 1 year ago

@ezYakaEagle442 Thanks for reaching out to us and reporting this issue. Looking at the error message the issue seems to be with the request URL.

azure.core.exceptions.HttpResponseError: Operation returned an invalid status 'Bad Request'
Content: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid URL</h2>
<hr><p>HTTP Error 400. The request URL is invalid.</p>
</BODY></HTML>

Request URL:

https://management.azure.com/subscriptions/212121212121/resourceGroups/rg-aca-reddog-quarkus/providers/Microsoft.CognitiveServices/ accounts/cog-openai-reddog7wwufb7rkg2oe-dev%0D/listKeys?api-version=2022-10-01

Could you please confirm if the cognitive service account name is valid ? AFAIK your resource name can only include alphanumeric characters and hyphens. You seems to have a % character in the name.

Note: I was able to run the az cognitiveservices account keys list -g MyRG -n MYCognitiveService CLi command just fine and it was able to list the keys successfully.

ezYakaEagle442 commented 1 year ago

@navba-MSFT Yes I do confirm 'cog-openai-reddog7wwufb7rkg2oe-dev' is the correct name of my service and does exist, it in Preview with special authorization to to use, I have asked the OpenAI Gate opening process and my subscription have been whitelisted, this is why I could successfully create this service

You mentionned cog-openai-reddog7wwufb7rkg2oe-dev%0D which %0D suggests a CR in Hexa code

ezYakaEagle442 commented 1 year ago

I have tested and this issue does not happen running CLI on Windows :

FOR /F %i IN ('az deployment group show --name openai -g rg-aca-reddog-quarkus --query properties.outputs.openAiCognitiveServiceName.value -o tsv') DO set openAiCognitiveServiceName=%i
az cognitiveservices account keys list --name %openAiCognitiveServiceName% -g rg-aca-reddog-quarkus

So this there is definitely a bug in CLI when running on Linux, it add a Carriage Return '0D' when running 'az deployment group show'

ezYakaEagle442 commented 1 year ago

also the first debug trace shows it : cli.knack.cli: Command arguments: ['cognitiveservices', 'account', 'keys', 'list', '--name', 'cog-openai-reddog7wwufb7rkg2oe-dev\r', '

Which code seems to be at https://github.com/microsoft/knack/blob/dev/knack/cli.py#L220

But where is the source code of AZ CLI for 'az deployment group show' ? I do not see it at https://github.com/Azure/azure-cli/blob/azure-cli-2.45.0/src/azure-cli-core/azure/cli/core/commands/arm.py

navba-MSFT commented 1 year ago

@ezYakaEagle442 Thanks for your reply. While I am looking at the issue in the background, Here is the code for az deployment group show :

https://github.com/Azure/azure-cli/blob/259eb96f0345f7323b9da3b114955d626476c0e1/src/azure-cli/azure/cli/command_modules/resource/custom.py#L1525

ezYakaEagle442 commented 1 year ago

there we ago it seems the issue is there indeed around https://github.com/Azure/azure-cli/blob/azure-cli-2.45.0/src/azure-cli/azure/cli/command_modules/resource/custom.py#L411

ezYakaEagle442 commented 1 year ago

trim '\r' is a workaround :

openAiCognitiveServiceName=$(az deployment group show --name openai -g rg-aca-reddog-quarkus --query properties.outputs.openAiCognitiveServiceName.value -o tsv | tr -d '\r')

PramodValavala-MSFT commented 1 year ago

@ezYakaEagle442 Since the problem seems to be in the output of the az deployment group show command, I am closing this issue as a duplicate of #25647