Skip to content

Conversation

@CarlOchs
Copy link
Member

@CarlOchs CarlOchs commented Oct 27, 2025

Related command

az cognitiveservices account connection [create|update|show|list|delete]
az cognitiveservices account project [create|update|show|list|delete]
az cognitiveservices account project connection [create|update|show|list|delete]

Description

This PR adds support for the following Cognitive Services Account sub-resource types:

  • Projects
    • Manages the AI Foundry account Projects
  • Project Connections
    • Manages AI Foundry project connections, which are scoped to projects (unshared)
  • Connections (at Account level)
    • Manages AI Foundry account connections, which can be shared across multiple projects.

Testing Guide

rg="testazcli"
sub_id=fe96f029-0423-4766-93fb-bf2066356770
acct_name=test_aifoundry_azcli
proj_name=testproj
location="westus2"

# Setup for testing - Create an AI Foundry account with project management support
az cognitiveservices account create --kind AIServices --sku-name S0 --location $location -n $acct_name -g $rg --yes --assign-identity --allow-project-management true --custom-domain $acct_name

# Commands to test managing projects - create, list, show, update, delete
az cognitiveservices account project create --name $acct_name -g $rg --project-name $proj_name --location $location --display-name "Test Project" --description "This is a test project."
az cognitiveservices account project list --name $acct_name -g $rg
az cognitiveservices account project show --name $acct_name -g $rg --project-name $proj_name
az cognitiveservices account project update --name $acct_name -g $rg --project-name $proj_name --display-name "My Test Project" --description "My updated description"
az cognitiveservices account project show --name $acct_name -g $rg --project-name $proj_name

# Creating connections requires the connection information from a YAML or JSON file.  YAML is the existing format used by the `az ml` commands.
tmpconnfile=$(mktemp --suffix .yml)
cat > $tmpconnfile << EOL
name: just_api
type: api_key
api_base: this_is_a_target
api_key: "3232"
EOL

# Commands to test managing account-level connections - create, list, show, update, delete
az cognitiveservices account connection create --name $acct_name -g $rg --connection-name "conn001" --file $tmpconnfile
az cognitiveservices account connection list --name $acct_name -g $rg 
az cognitiveservices account connection show --name $acct_name -g $rg --connection-name "conn001"
az cognitiveservices account connection update --name $acct_name -g $rg --connection-name "conn001" --set properties.credentials.key="new_key_value"
az cognitiveservices account connection delete --name $acct_name -g $rg --connection-name "conn001"

# Commands to test managing project connections - create, list, show, update, delete
az cognitiveservices account project connection create --name $acct_name -g $rg --project-name $proj_name --connection-name "projconn001" --file $tmpconnfile
az cognitiveservices account project connection list --name $acct_name -g $rg --project-name $proj_name
az cognitiveservices account project connection show --name $acct_name -g $rg --project-name $proj_name --connection-name "projconn001"
az cognitiveservices account project connection update --name $acct_name -g $rg --project-name $proj_name --connection-name "projconn001" --set properties.credentials.key="new_key_value"
az cognitiveservices account project connection delete --name $acct_name -g $rg --project-name $proj_name --connection-name "projconn001"

# Cleanup - delete the project and account
az cognitiveservices account project delete --name $acct_name -g $rg --project-name $proj_name
az cognitiveservices account delete -n $acct_name -g $rg
rm $tmpconnfile

History Notes

[Cognitive Services] az cognitiveservices account connection: Add AI Foundry account connection management
[Cognitive Services] az cognitiveservices account project: Add AI Foundry account project management
[Cognitive Services] az cognitiveservices account project connection: Add AI Foundry account project connection management


This checklist is used to make sure that common guidelines for a pull request are followed.

Copilot AI review requested due to automatic review settings October 27, 2025 16:24
@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Oct 27, 2025

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

@azure-client-tools-bot-prd
Copy link

Hi @CarlOchs,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Oct 27, 2025

⚠️AzureCLI-BreakingChangeTest
⚠️cognitiveservices
rule cmd_name rule_message suggest_message
⚠️ 1011 - SubgroupAdd cognitiveservices account connection sub group cognitiveservices account connection added
⚠️ 1006 - ParaAdd cognitiveservices account deployment create cmd cognitiveservices account deployment create added parameter spillover_deployment_name
⚠️ 1011 - SubgroupAdd cognitiveservices account project sub group cognitiveservices account project added

@yonzhan
Copy link
Collaborator

yonzhan commented Oct 27, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive support for managing AI Foundry resources within Azure Cognitive Services accounts, including projects, account-level connections, and project-scoped connections. The implementation upgrades the SDK version and introduces new command groups to handle these resources through the Azure CLI.

Key Changes

  • Upgraded azure-mgmt-cognitiveservices from 13.7.0 to 14.1.0 to access new API features
  • Added three command groups: account project, account connection, and account project connection
  • Implemented connection loading utilities that support both YAML and JSON formats

Reviewed Changes

Copilot reviewed 54 out of 55 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
setup.py, requirements.*.txt SDK version update to 14.1.0
custom.py Core logic for project and connection CRUD operations
commands.py Command registration for new resource types
_utils.py Connection parsing and identity composition utilities
_ml_utils.py ML connection type mapping for compatibility
_params.py Parameter definitions and validators
_help.py Documentation for new commands
_client_factory.py Client factory methods for new operations
test_.py, input_data/ Test files and fixtures
linter_exclusions.yml Test coverage exclusion configuration
Comments suppressed due to low confidence (1)

src/azure-cli/azure/cli/command_modules/cognitiveservices/_ml_utils.py:1

  • Remove the space between the period and underscore in the import statement. Should be from ._ml_utils import
from azure.cli.core.azclierror import FileOperationError, InvalidArgumentValueError

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

'cognitiveservices account project connection', project_connections_type,
client_factory=cf_project_connections) as g:
g.custom_command('create', 'project_connection_create')
g.command('delete', 'delete')
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The delete command for project connections should include confirmation=True to prompt users before removing resources, as deletions are destructive operations.

Copilot uses AI. Check for mistakes.
'cognitiveservices account project', projects_type,
client_factory=cf_projects) as g:
g.custom_command('create', 'project_create')
g.command('delete', 'begin_delete')
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The delete command for projects should include confirmation=True to prompt users before removing resources, as deletions are destructive operations.

Copilot uses AI. Check for mistakes.
'cognitiveservices account connection', account_connections_type,
client_factory=cf_account_connections) as g:
g.custom_command('create', 'account_connection_create')
g.command('delete', 'delete')
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The delete command for account connections should include confirmation=True to prompt users before removing resources, as deletions are destructive operations.

Copilot uses AI. Check for mistakes.
Comment on lines +245 to +246
help=('Use with --user-assigned-identity to generate and assign a '
'system managed Azure Active Directory Identity for this project.'))
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The help text starts with 'Use' which is not in the active voice first person. Consider rephrasing to start with an active first-person verb like 'Generate' or 'Assign'.

Copilot uses AI. Check for mistakes.

class CognitiveServicesProjectConnectionsTests(ScenarioTest):

INPUT_DATA_PATH=os.path.join(TEST_DIR, 'input_data', 'connections')
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class attribute INPUT_DATA_PATH should use lowercase with underscores according to Python naming conventions (should be input_data_path).

Copilot uses AI. Check for mistakes.
@kairu-ms
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

kairu-ms
kairu-ms previously approved these changes Oct 28, 2025
@CarlOchs
Copy link
Member Author

@kairu-ms Thanks for the review - I had to re-generate all the recording files to get the tests to not fail. I'm not exactly sure why yet, but it fixed it.

Will we be able to get this PR into the release coinciding with Ignite?

@CarlOchs
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 32336 in repo Azure/azure-cli

@yonzhan
Copy link
Collaborator

yonzhan commented Oct 30, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@yonzhan
Copy link
Collaborator

yonzhan commented Nov 1, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@kairu-ms
Copy link
Contributor

kairu-ms commented Nov 3, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@yonzhan
Copy link
Collaborator

yonzhan commented Nov 4, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

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 Cognitive Services az cognitiveservices

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants