Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,23 @@ def cf_models(cli_ctx, *_):

def cf_usages(cli_ctx, *_):
return get_cognitiveservices_management_client(cli_ctx).usages


def cf_projects(cli_ctx, *_):
return get_cognitiveservices_management_client(cli_ctx).projects


def cf_account_connections(cli_ctx, *_):
return get_cognitiveservices_management_client(cli_ctx).account_connections


def cf_account_capability_hosts(cli_ctx, *_):
return get_cognitiveservices_management_client(cli_ctx).account_capability_hosts


def cf_project_capability_hosts(cli_ctx, *_):
return get_cognitiveservices_management_client(cli_ctx).project_capability_hosts


def cf_project_connections(cli_ctx, *_):
return get_cognitiveservices_management_client(cli_ctx).project_connections
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,75 @@
- name: Show all usages for Azure Cognitive Services.
text: az cognitiveservices usage list -l centraluseuap
"""

helps['cognitiveservices account connection'] = """
type: group
short-summary: Manage Azure Cognitive Services connection and its more specific derivatives.
long-summary: >
Azure Cognitive Services connection provides a secure way to store authentication and configuration information needed to connect and
interact with the external resources.
"""

helps['cognitiveservices account connection list'] = """
type: command
short-summary: List all connections.
long-summary: >
The list of connections in an Azure AI Foundry account.
examples:
- name: List all connections in an Azure AI Foundry account
text: az cognitiveservices account connection list --resource-group my-resource-group --name my-cogsvc-account
- name: List all the connections in an Azure AI Foundry account using --query argument to execute a JMESPath query on the results of commands.
text: az cognitiveservices account connection list --query \"[].{Name:name}\" --output table --resource-group my-resource-group --name my-cogsvc-account
"""

helps['cognitiveservices account connection show'] = """
type: command
short-summary: Show details of a connection.
examples:
- name: Show details of a connection.
text: az cognitiveservices account connection show --resource-group my-resource-group --connection-name my-connection-name --name my-cogsvc-account
"""
helps['cognitiveservices account connection delete'] = """
type: command
short-summary: Delete a connection.
examples:
- name: Delete a connection.
text: az cognitiveservices account connection delete --resource-group my-resource-group --connection-name my-connection-name --name my-cogsvc-account
"""

helps['cognitiveservices account connection create'] = """
type: command
short-summary: Create a connection.
examples:
- name: Create a connection from a YAML specification file.
text: az cognitiveservices account connection create --file connection.yml --connection-name my-connection-name --resource-group my-resource-group --name my-cogsvc-account
"""

helps['cognitiveservices account connection update'] = """
type: command
short-summary: Update a connection.
examples:
- name: Update a connection API Key.
text: az cognitiveservices account connection update --resource-group my-resource-group --connection-name my-connection-name --name my-cogsvc-account --set properties.credentials.key=<new-key>
"""
helps['cognitiveservices account project'] = """
type: group
short-summary: Manage Azure Cognitive Services account projects.
long-summary: >
Projects let you organize your work, such as agents, evaluations, and files, as you build stateful apps and explore new ideas. It is a container for access management,
data upload and integration, and monitoring
"""
helps['cognitiveservices account project connection'] = """
type: group
short-summary: Manage Azure Cognitive Services connection associated with a project.
long-summary: >
Azure Cognitive Services connection provides a secure way to store authentication and configuration information needed to connect and
interact with the external resources.
"""
helps['cognitiveservices account project connection update'] = """
type: command
short-summary: Update a project connection.
examples:
- name: Update a connection API Key.
text: az cognitiveservices account project connection update --resource-group my-resource-group --connection-name my-connection-name --name my-cogsvc-account --project-name my-project --set properties.credentials.key=<new-key>
"""
134 changes: 134 additions & 0 deletions src/azure-cli/azure/cli/command_modules/cognitiveservices/_ml_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure.mgmt.cognitiveservices.models import ConnectionCategory

_ML_CONNECTION_TYPE_TO_COGNITIVE_SERVICES_CONNECTION_TYPE = {
"PythonFeed": ConnectionCategory.PYTHON_FEED,
"ContainerRegistry": ConnectionCategory.CONTAINER_REGISTRY,
"Git": ConnectionCategory.GIT,
"S3": ConnectionCategory.S3,
"Snowflake": ConnectionCategory.SNOWFLAKE,
"AzureSqlDb": ConnectionCategory.AZURE_SQL_DB,
"AzureSynapseAnalytics": ConnectionCategory.AZURE_SYNAPSE_ANALYTICS,
"AzureMySqlDb": ConnectionCategory.AZURE_MY_SQL_DB,
"AzurePostgresDb": ConnectionCategory.AZURE_POSTGRES_DB,
"ADLSGen2": ConnectionCategory.ADLS_GEN2,
"Redis": ConnectionCategory.REDIS,
"ApiKey": ConnectionCategory.API_KEY,
"AzureOpenAI": ConnectionCategory.AZURE_OPEN_AI,
"AzureOpenAi": ConnectionCategory.AZURE_OPEN_AI,
"AIServices": ConnectionCategory.AI_SERVICES,
"AiServices": ConnectionCategory.AI_SERVICES,
"CognitiveSearch": ConnectionCategory.COGNITIVE_SEARCH,
"CognitiveService": ConnectionCategory.COGNITIVE_SERVICE,
"CustomKeys": ConnectionCategory.CUSTOM_KEYS,
"AzureBlob": ConnectionCategory.AZURE_BLOB,
"AzureOneLake": ConnectionCategory.AZURE_ONE_LAKE,
"CosmosDb": ConnectionCategory.COSMOS_DB,
"CosmosDbMongoDbApi": ConnectionCategory.COSMOS_DB_MONGO_DB_API,
"AzureDataExplorer": ConnectionCategory.AZURE_DATA_EXPLORER,
"AzureMariaDb": ConnectionCategory.AZURE_MARIA_DB,
"AzureDatabricksDeltaLake": ConnectionCategory.AZURE_DATABRICKS_DELTA_LAKE,
"AzureSqlMi": ConnectionCategory.AZURE_SQL_MI,
"AzureTableStorage": ConnectionCategory.AZURE_TABLE_STORAGE,
"AmazonRdsForOracle": ConnectionCategory.AMAZON_RDS_FOR_ORACLE,
"AmazonRdsForSqlServer": ConnectionCategory.AMAZON_RDS_FOR_SQL_SERVER,
"AmazonRedshift": ConnectionCategory.AMAZON_REDSHIFT,
"Db2": ConnectionCategory.DB2,
"Drill": ConnectionCategory.DRILL,
"GoogleBigQuery": ConnectionCategory.GOOGLE_BIG_QUERY,
"Greenplum": ConnectionCategory.GREENPLUM,
"Hbase": ConnectionCategory.HBASE,
"Hive": ConnectionCategory.HIVE,
"Impala": ConnectionCategory.IMPALA,
"Informix": ConnectionCategory.INFORMIX,
"MariaDb": ConnectionCategory.MARIA_DB,
"MicrosoftAccess": ConnectionCategory.MICROSOFT_ACCESS,
"MySql": ConnectionCategory.MY_SQL,
"Netezza": ConnectionCategory.NETEZZA,
"Oracle": ConnectionCategory.ORACLE,
"Phoenix": ConnectionCategory.PHOENIX,
"PostgreSql": ConnectionCategory.POSTGRE_SQL,
"Presto": ConnectionCategory.PRESTO,
"SapOpenHub": ConnectionCategory.SAP_OPEN_HUB,
"SapBw": ConnectionCategory.SAP_BW,
"SapHana": ConnectionCategory.SAP_HANA,
"SapTable": ConnectionCategory.SAP_TABLE,
"Spark": ConnectionCategory.SPARK,
"SqlServer": ConnectionCategory.SQL_SERVER,
"Sybase": ConnectionCategory.SYBASE,
"Teradata": ConnectionCategory.TERADATA,
"Vertica": ConnectionCategory.VERTICA,
"Pinecone": ConnectionCategory.PINECONE,
"Cassandra": ConnectionCategory.CASSANDRA,
"Couchbase": ConnectionCategory.COUCHBASE,
"MongoDbV2": ConnectionCategory.MONGO_DB_V2,
"MongoDbAtlas": ConnectionCategory.MONGO_DB_ATLAS,
"AmazonS3Compatible": ConnectionCategory.AMAZON_S3_COMPATIBLE,
"FileServer": ConnectionCategory.FILE_SERVER,
"FtpServer": ConnectionCategory.FTP_SERVER,
"GoogleCloudStorage": ConnectionCategory.GOOGLE_CLOUD_STORAGE,
"Hdfs": ConnectionCategory.HDFS,
"OracleCloudStorage": ConnectionCategory.ORACLE_CLOUD_STORAGE,
"Sftp": ConnectionCategory.SFTP,
"GenericHttp": ConnectionCategory.GENERIC_HTTP,
"ODataRest": ConnectionCategory.O_DATA_REST,
"Odbc": ConnectionCategory.ODBC,
"GenericRest": ConnectionCategory.GENERIC_REST,
"AmazonMws": ConnectionCategory.AMAZON_MWS,
"Concur": ConnectionCategory.CONCUR,
"Dynamics": ConnectionCategory.DYNAMICS,
"DynamicsAx": ConnectionCategory.DYNAMICS_AX,
"DynamicsCrm": ConnectionCategory.DYNAMICS_CRM,
"GoogleAdWords": ConnectionCategory.GOOGLE_AD_WORDS,
"Hubspot": ConnectionCategory.HUBSPOT,
"Jira": ConnectionCategory.JIRA,
"Magento": ConnectionCategory.MAGENTO,
"Marketo": ConnectionCategory.MARKETO,
"Office365": ConnectionCategory.OFFICE365,
"Eloqua": ConnectionCategory.ELOQUA,
"Responsys": ConnectionCategory.RESPONSYS,
"OracleServiceCloud": ConnectionCategory.ORACLE_SERVICE_CLOUD,
"PayPal": ConnectionCategory.PAY_PAL,
"QuickBooks": ConnectionCategory.QUICK_BOOKS,
"Salesforce": ConnectionCategory.SALESFORCE,
"SalesforceServiceCloud": ConnectionCategory.SALESFORCE_SERVICE_CLOUD,
"SalesforceMarketingCloud": ConnectionCategory.SALESFORCE_MARKETING_CLOUD,
"SapCloudForCustomer": ConnectionCategory.SAP_CLOUD_FOR_CUSTOMER,
"SapEcc": ConnectionCategory.SAP_ECC,
"ServiceNow": ConnectionCategory.SERVICE_NOW,
"SharePointOnlineList": ConnectionCategory.SHARE_POINT_ONLINE_LIST,
"Shopify": ConnectionCategory.SHOPIFY,
"Square": ConnectionCategory.SQUARE,
"WebTable": ConnectionCategory.WEB_TABLE,
"Xero": ConnectionCategory.XERO,
"Zoho": ConnectionCategory.ZOHO,
"GenericContainerRegistry": ConnectionCategory.GENERIC_CONTAINER_REGISTRY,
"Elasticsearch": ConnectionCategory.ELASTICSEARCH,
"OpenAI": ConnectionCategory.OPEN_AI,
"OpenAi": ConnectionCategory.OPEN_AI,
"Serp": ConnectionCategory.SERP,
"BingLLMSearch": ConnectionCategory.BING_LLM_SEARCH,
"Serverless": ConnectionCategory.SERVERLESS,
"ManagedOnlineEndpoint": ConnectionCategory.MANAGED_ONLINE_ENDPOINT,
# The following are from azure.ai.ml.constants._common.ConnectionTypes
"Custom": ConnectionCategory.CUSTOM_KEYS,
"AzureDataLakeGen2": ConnectionCategory.ADLS_GEN2,
"AzureContentSafety": ConnectionCategory.COGNITIVE_SERVICE,
"AzureSpeechServices": ConnectionCategory.COGNITIVE_SERVICE,
"AzureAiSearch": ConnectionCategory.COGNITIVE_SEARCH,
"AzureAiServices": ConnectionCategory.AI_SERVICES,
}


def get_valid_mlconn_types():
return list(_ML_CONNECTION_TYPE_TO_COGNITIVE_SERVICES_CONNECTION_TYPE.keys())


def get_mapped_mlconn_type(ml_connection_type: str):
from . _utils import snake_to_camel
normalized_name = snake_to_camel(ml_connection_type)
return _ML_CONNECTION_TYPE_TO_COGNITIVE_SERVICES_CONNECTION_TYPE.get(normalized_name)
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ def _validate_subnet(cmd, namespace):
child_name_1=subnet)


def _validate_user_assigned_identity(cmd, namespace):
from azure.mgmt.core.tools import resource_id, is_valid_resource_id
from azure.cli.core.commands.client_factory import get_subscription_id
if namespace.user_assigned_identity:
identity = namespace.user_assigned_identity
if not is_valid_resource_id(identity):
namespace.user_assigned_identity = resource_id(
subscription=get_subscription_id(cmd.cli_ctx),
resource_group=namespace.resource_group_name,
namespace='Microsoft.ManagedIdentity',
type='userAssignedIdentities',
name=identity)


@Completer
def sku_name_completer(cmd, prefix, namespace, **kwargs): # pylint: disable=unused-argument
names = {x.name for x in _sku_filter(cmd, namespace)}
Expand Down Expand Up @@ -183,6 +197,9 @@ def load_arguments(self, _):

with self.argument_context('cognitiveservices account deployment') as c:
c.argument('deployment_name', help='Cognitive Services account deployment name')
c.argument('spillover_deployment_name',
options_list=['--spillover-deployment-name', '--spillover-name'],
help='The name of the standard deployment to use as a spillover when at capacity.')

with self.argument_context('cognitiveservices account deployment', arg_group='DeploymentModel') as c:
c.argument('model_name', help='Cognitive Services account deployment model name.')
Expand Down Expand Up @@ -214,3 +231,32 @@ def load_arguments(self, _):
with self.argument_context('cognitiveservices account commitment-plan', arg_group='Next CommitmentPeriod') as c:
c.argument('next_count', help='Cognitive Services account commitment plan next commitment period count.')
c.argument('next_tier', help='Cognitive Services account commitment plan next commitment period tier.')

with self.argument_context('cognitiveservices account project') as c:
c.argument('project_name', help='Cognitive Services account project name')
c.argument('location', arg_type=get_location_type(self.cli_ctx),
completer=location_completer)
c.argument('description', help='Description of the project.')
c.argument('display_name', help='Display name of the project.')

with self.argument_context('cognitiveservices account project', arg_group='Project Identity') as c:
c.argument("assign_identity",
options_list=['--include-system-identity', '--assign-identity'],
help=('Use with --user-assigned-identity to generate and assign a '
'system managed Azure Active Directory Identity for this project.'))
Comment on lines +245 to +246
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.
c.argument('user_assigned_identity',
help=('User assigned identity resource ID to use for the project. '
'If not specified, a system assigned identity will be used.'),
validator=_validate_user_assigned_identity)

with self.argument_context('cognitiveservices account project create') as c:
c.argument('description', help='Description of the project.')
c.argument('display_name', help='Display name of the project.')

with self.argument_context('cognitiveservices account project connection') as c:
c.argument('connection_name', help='Cognitive Services account connection name')
c.argument('file', help='Path to the connection file in JSON or YAML format.')

with self.argument_context('cognitiveservices account connection') as c:
c.argument('connection_name', help='Cognitive Services account connection name')
c.argument('file', help='Path to the connection file in JSON or YAML format.')
Loading