Closed ezYakaEagle442 closed 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
route to CXP team
@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.
@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
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'
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
@ezYakaEagle442 Thanks for your reply. While I am looking at the issue in the background, Here is the code for az deployment group show
:
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
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')
@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
Related command
az cognitiveservices account keys list
Describe the bug
az cognitiveservices account keys list dies not returns the keys
To Reproduce
Expected behavior
Environment summary
VSCode/Terminal/WSL2/Ubuntu2204
Additional context
see :