diff --git a/azure-cli.pyproj b/azure-cli.pyproj
index cadb46c8fae..051bc27c877 100644
--- a/azure-cli.pyproj
+++ b/azure-cli.pyproj
@@ -158,6 +158,29 @@
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+
+
+
+
+
+ Code
+
Code
@@ -635,6 +658,12 @@
+
+
+
+
+
+
@@ -814,6 +843,9 @@
+
+
+
diff --git a/src/command_modules/azure-cli-cognitiveservices/HISTORY.rst b/src/command_modules/azure-cli-cognitiveservices/HISTORY.rst
new file mode 100644
index 00000000000..59c2bcdedc2
--- /dev/null
+++ b/src/command_modules/azure-cli-cognitiveservices/HISTORY.rst
@@ -0,0 +1,9 @@
+.. :changelog:
+
+Release History
+===============
+
+Unreleased
+--------------------------
+* inital cognitive services CLI
+
diff --git a/src/command_modules/azure-cli-cognitiveservices/MANIFEST.in b/src/command_modules/azure-cli-cognitiveservices/MANIFEST.in
new file mode 100644
index 00000000000..bb37a2723da
--- /dev/null
+++ b/src/command_modules/azure-cli-cognitiveservices/MANIFEST.in
@@ -0,0 +1 @@
+include *.rst
diff --git a/src/command_modules/azure-cli-cognitiveservices/README.rst b/src/command_modules/azure-cli-cognitiveservices/README.rst
new file mode 100644
index 00000000000..11991a8b8ae
--- /dev/null
+++ b/src/command_modules/azure-cli-cognitiveservices/README.rst
@@ -0,0 +1,7 @@
+Microsoft Azure CLI 'cognitive services' Command Module
+=============================================
+
+This package is for the 'cognitive services' module.
+i.e. 'az cognitiveservices'
+
+
diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/__init__.py b/src/command_modules/azure-cli-cognitiveservices/azure/__init__.py
new file mode 100644
index 00000000000..73baee1e640
--- /dev/null
+++ b/src/command_modules/azure-cli-cognitiveservices/azure/__init__.py
@@ -0,0 +1,6 @@
+# --------------------------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# --------------------------------------------------------------------------------------------
+import pkg_resources
+pkg_resources.declare_namespace(__name__)
diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/__init__.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/__init__.py
new file mode 100644
index 00000000000..73baee1e640
--- /dev/null
+++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/__init__.py
@@ -0,0 +1,6 @@
+# --------------------------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# --------------------------------------------------------------------------------------------
+import pkg_resources
+pkg_resources.declare_namespace(__name__)
diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/__init__.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/__init__.py
new file mode 100644
index 00000000000..73baee1e640
--- /dev/null
+++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/__init__.py
@@ -0,0 +1,6 @@
+# --------------------------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# --------------------------------------------------------------------------------------------
+import pkg_resources
+pkg_resources.declare_namespace(__name__)
diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py
new file mode 100644
index 00000000000..6c8efe8cb7d
--- /dev/null
+++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/__init__.py
@@ -0,0 +1,13 @@
+# --------------------------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# --------------------------------------------------------------------------------------------
+import azure.cli.command_modules.cognitiveservices._help # pylint: disable=unused-import
+
+
+def load_params(_):
+ import azure.cli.command_modules.cognitiveservices._params # pylint: disable=redefined-outer-name
+
+
+def load_commands():
+ import azure.cli.command_modules.cognitiveservices.commands # pylint: disable=redefined-outer-name
diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py
new file mode 100644
index 00000000000..e8d12a17da3
--- /dev/null
+++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_client_factory.py
@@ -0,0 +1,19 @@
+# --------------------------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# --------------------------------------------------------------------------------------------
+# management client factories
+
+
+def get_cognitiveservices_management_client(_):
+ from azure.cli.core.commands.client_factory import get_mgmt_service_client
+ from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient
+ return get_mgmt_service_client(CognitiveServicesManagementClient, location='notused')
+
+
+def get_cognitiveservices_account_operations(kwargs):
+ return get_cognitiveservices_management_client(kwargs).cognitive_services_accounts
+
+
+def get_cognitiveservices_operations(kwargs):
+ return get_cognitiveservices_management_client(kwargs).accounts
diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py
new file mode 100644
index 00000000000..444543ef9dc
--- /dev/null
+++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_help.py
@@ -0,0 +1,63 @@
+# --------------------------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# --------------------------------------------------------------------------------------------
+
+from azure.cli.core.help_files import helps
+
+helps['cognitiveservices list'] = """
+ type: command
+ short-summary: list all the existing cognitive services accounts under a resource group or current azure subscription
+ examples:
+ - name: list all the cognitive services accounts in a resource group
+ text: az cognitiveservices list -g MyResourceGroup
+"""
+
+helps['cognitiveservices account'] = """
+ type: group
+ short-summary: Manage and update cognitive services accounts
+"""
+
+helps['cognitiveservices account delete'] = """
+ type: command
+ short-summary: Remove a cognitive services account.
+"""
+
+helps['cognitiveservices account create'] = """
+ type: command
+ short-summary: Create a cognitive services account.
+ examples:
+ - name: create a S0 face Api cognitive services account in West Europe without confirmation required
+ text: az cognitiveservices create -n myresource -g myResourceGroup --kind Face --sku S0 -l WestEurope --yes
+"""
+
+helps['cognitiveservices account show'] = """
+ type: command
+ short-summary: Get the details of a cognitive services account.
+"""
+
+helps['cognitiveservices account update'] = """
+ type: command
+ short-summary: Update the properties of a cognitive services account.
+"""
+
+helps['cognitiveservices account list-skus'] = """
+ type: command
+ short-summary: List the avaiable skus of a cognitive services account.
+"""
+
+
+helps['cognitiveservices account keys'] = """
+ type: group
+ short-summary: Manage the keys of a cognitive services account.
+"""
+
+helps['cognitiveservices account keys regenerate'] = """
+ type: command
+ short-summary: Regenerate the keys of a cognitive services account.
+"""
+
+helps['cognitiveservices account keys list'] = """
+ type: command
+ short-summary: List the keys of a cognitive services account.
+"""
diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py
new file mode 100644
index 00000000000..a2fe21f56ab
--- /dev/null
+++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/_params.py
@@ -0,0 +1,28 @@
+# --------------------------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# --------------------------------------------------------------------------------------------
+from azure.cli.core.commands import register_cli_argument, CliArgumentType
+
+from azure.cli.core.commands.parameters import (
+ tags_type,
+ resource_group_name_type,
+ get_resource_name_completion_list)
+
+name_arg_type = CliArgumentType(options_list=('--name', '-n'), metavar='NAME')
+
+register_cli_argument('cognitiveservices', 'account_name',
+ arg_type=name_arg_type, help='cognitive service account name',
+ completer=get_resource_name_completion_list(
+ 'Microsoft.CognitiveServices/accounts'))
+register_cli_argument('cognitiveservices', 'resource_group_name',
+ arg_type=resource_group_name_type)
+register_cli_argument('cognitiveservices', 'sku_name', options_list=('--sku',),
+ help='the Sku of cognitive services account')
+register_cli_argument('cognitiveservices', 'kind',
+ help='the API name of cognitive services account')
+register_cli_argument('cognitiveservices', 'tags', tags_type)
+register_cli_argument('cognitiveservices', 'key_name', required=True,
+ help='Key name to generate', choices=['key1', 'key2'])
+register_cli_argument('cognitiveservices account create', 'yes', action='store_true',
+ help='Do not prompt for terms confirmation')
diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py
new file mode 100644
index 00000000000..7de099d5743
--- /dev/null
+++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/commands.py
@@ -0,0 +1,30 @@
+# --------------------------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# --------------------------------------------------------------------------------------------
+from azure.cli.core.commands import cli_command
+from azure.cli.command_modules.cognitiveservices._client_factory import (
+ get_cognitiveservices_account_operations,
+ get_cognitiveservices_operations)
+
+mgmt_path = 'azure.mgmt.cognitiveservices.operations.cognitive_services_accounts_operations#'\
+ 'CognitiveServicesAccountsOperations.{}'
+custom_path = 'azure.cli.command_modules.cognitiveservices.custom#{}'
+
+cli_command(__name__, 'cognitiveservices account create', custom_path.format('create'),
+ get_cognitiveservices_account_operations)
+cli_command(__name__, 'cognitiveservices account delete', mgmt_path.format('delete'),
+ get_cognitiveservices_account_operations)
+cli_command(__name__, 'cognitiveservices account show', mgmt_path.format('get_properties'),
+ get_cognitiveservices_account_operations)
+cli_command(__name__, 'cognitiveservices list', custom_path.format('listresources'),
+ get_cognitiveservices_operations)
+cli_command(__name__, 'cognitiveservices account update', custom_path.format('update'),
+ get_cognitiveservices_account_operations)
+cli_command(__name__, 'cognitiveservices account keys regenerate',
+ mgmt_path.format('regenerate_key'),
+ get_cognitiveservices_account_operations)
+cli_command(__name__, 'cognitiveservices account keys list', mgmt_path.format('list_keys'),
+ get_cognitiveservices_account_operations)
+cli_command(__name__, 'cognitiveservices account list-skus', mgmt_path.format('list_skus'),
+ get_cognitiveservices_account_operations)
diff --git a/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py
new file mode 100644
index 00000000000..afe5e36b26c
--- /dev/null
+++ b/src/command_modules/azure-cli-cognitiveservices/azure/cli/command_modules/cognitiveservices/custom.py
@@ -0,0 +1,52 @@
+# --------------------------------------------------------------------------------------------
+# 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 CognitiveServicesAccountCreateParameters, Sku
+from azure.cli.core.prompting import prompt_y_n
+from azure.cli.core.util import CLIError
+
+import azure.cli.core.azlogging as azlogging
+logger = azlogging.get_az_logger(__name__)
+
+
+def listresources(client, resource_group_name=None):
+ if resource_group_name:
+ return client.list_by_resource_group(resource_group_name)
+ else:
+ return client.list()
+
+
+# pylint: disable=too-many-arguments
+def create(
+ client, resource_group_name, account_name, sku_name, kind, location, tags=None, yes=None):
+
+ terms = 'Notice\nMicrosoft will use data you send to the Cognitive'\
+ 'Services to improve Microsoft products and services.'\
+ 'For example we may use content that you provide to the Cognitive'\
+ 'Services to improve our underlying algorithms and models over time.'\
+ 'Where you send personal data to the Cognitive Services, you are responsible'\
+ 'for obtaining sufficient consent from the data subjects.'\
+ 'The General Privacy and Security Terms in the Online Services Terms '\
+ '(https://www.microsoft.com/en-us/Licensing/product-licensing/products.aspx) '\
+ 'do not apply to the Cognitive Services.'\
+ 'You must comply with use and display requirements for the Bing Search APIs.'\
+ '\n\nPlease refer to the Microsoft Cognitive Services section in the Online '\
+ 'Services Terms for details.'
+ hint = '\nPlease select'
+ if yes:
+ logger.warning(terms)
+ else:
+ logger.warning(terms)
+ option = prompt_y_n(hint)
+ if not option:
+ raise CLIError('Operation cancelled.')
+ sku = Sku(sku_name)
+ properties = {}
+ params = CognitiveServicesAccountCreateParameters(sku, kind, location, properties, tags)
+ return client.create(resource_group_name, account_name, params)
+
+
+def update(client, resource_group_name, account_name, sku_name=None, tags=None):
+ sku = Sku(sku_name)
+ return client.update(resource_group_name, account_name, sku, tags)
diff --git a/src/command_modules/azure-cli-cognitiveservices/setup.py b/src/command_modules/azure-cli-cognitiveservices/setup.py
new file mode 100644
index 00000000000..08543bb7e11
--- /dev/null
+++ b/src/command_modules/azure-cli-cognitiveservices/setup.py
@@ -0,0 +1,61 @@
+# --------------------------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# --------------------------------------------------------------------------------------------
+
+from codecs import open
+from setuptools import setup
+
+try:
+ from azure_bdist_wheel import cmdclass
+except ImportError:
+ from distutils import log as logger
+ logger.warn("Wheel is not available, disabling bdist_wheel hook")
+ cmdclass = {}
+
+VERSION = '0.1.0+dev'
+
+# The full list of classifiers is available at
+# https://pypi.python.org/pypi?%3Aaction=list_classifiers
+CLASSIFIERS = [
+ 'Development Status :: 4 - Beta',
+ 'Intended Audience :: Developers',
+ 'Intended Audience :: System Administrators',
+ 'Programming Language :: Python',
+ 'Programming Language :: Python :: 2',
+ 'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: 3.4',
+ 'Programming Language :: Python :: 3.5',
+ 'Programming Language :: Python :: 3.6',
+]
+
+DEPENDENCIES = [
+ 'azure-mgmt-cognitiveservices==1.0.0',
+ 'azure-cli-core',
+]
+
+with open('README.rst', 'r', encoding='utf-8') as f:
+ README = f.read()
+with open('HISTORY.rst', 'r', encoding='utf-8') as f:
+ HISTORY = f.read()
+
+setup(
+ name='azure-cli-cognitiveservices',
+ version=VERSION,
+ description='Microsoft Azure Command-Line Tools Cognitive Services Command Module',
+ long_description=README + '\n\n' + HISTORY,
+ license='MIT',
+ author='Microsoft Corporation',
+ author_email='azpycli@microsoft.com',
+ url='https://github.com/azure/azure-cli',
+ classifiers=CLASSIFIERS,
+ packages=[
+ 'azure',
+ 'azure.cli',
+ 'azure.cli.command_modules',
+ 'azure.cli.command_modules.cognitiveservices',
+ ],
+ install_requires=DEPENDENCIES,
+ cmdclass=cmdclass
+)
diff --git a/src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices_crud.yaml b/src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices_crud.yaml
new file mode 100644
index 00000000000..c09240f569e
--- /dev/null
+++ b/src/command_modules/azure-cli-cognitiveservices/tests/recordings/test_cognitiveservices_crud.yaml
@@ -0,0 +1,276 @@
+interactions:
+- request:
+ body: '{"location": "westus", "tags": {"use": "az-test"}}'
+ headers:
+ Accept: [application/json]
+ Accept-Encoding: ['gzip, deflate']
+ CommandName: [group create]
+ Connection: [keep-alive]
+ Content-Length: ['50']
+ Content-Type: [application/json; charset=utf-8]
+ User-Agent: [python/3.6.0 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7
+ msrest_azure/0.4.7 resourcemanagementclient/1.0.0rc1 Azure-SDK-For-Python
+ AZURECLI/2.0.3+dev]
+ accept-language: [en-US]
+ method: PUT
+ uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001?api-version=2016-09-01
+ response:
+ body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001","name":"clitest.rg000001","location":"westus","tags":{"use":"az-test"},"properties":{"provisioningState":"Succeeded"}}'}
+ headers:
+ cache-control: [no-cache]
+ content-length: ['326']
+ content-type: [application/json; charset=utf-8]
+ date: ['Tue, 02 May 2017 18:16:09 GMT']
+ expires: ['-1']
+ pragma: [no-cache]
+ strict-transport-security: [max-age=31536000; includeSubDomains]
+ x-ms-ratelimit-remaining-subscription-writes: ['1199']
+ status: {code: 201, message: Created}
+- request:
+ body: '{"sku": {"name": "S0"}, "kind": "Face", "location": "westeurope", "properties":
+ {}}'
+ headers:
+ Accept: [application/json]
+ Accept-Encoding: ['gzip, deflate']
+ CommandName: [cognitiveservices account create]
+ Connection: [keep-alive]
+ Content-Length: ['83']
+ Content-Type: [application/json; charset=utf-8]
+ User-Agent: [python/3.6.0 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7
+ msrest_azure/0.4.7 cognitiveservicesmanagementclient/2017-04-18 Azure-SDK-For-Python
+ AZURECLI/2.0.3+dev]
+ accept-language: [en-US]
+ method: PUT
+ uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002?api-version=2017-04-18
+ response:
+ body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","etag":"\"00007a03-0000-0000-0000-5908cceb0000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","internalId":"c56a9d85d19445db8be4236f26168205","dateCreated":"2017-05-02T18:16:11.361061Z","provisioningState":"Succeeded"}}'}
+ headers:
+ cache-control: [no-cache]
+ content-length: ['595']
+ content-type: [application/json; charset=utf-8]
+ date: ['Tue, 02 May 2017 18:16:12 GMT']
+ etag: ['"00007a03-0000-0000-0000-5908cceb0000"']
+ expires: ['-1']
+ pragma: [no-cache]
+ server: [Microsoft-IIS/8.5]
+ strict-transport-security: [max-age=31536000; includeSubDomains]
+ x-aspnet-version: [4.0.30319]
+ x-ms-ratelimit-remaining-subscription-writes: ['1199']
+ x-powered-by: [ASP.NET]
+ status: {code: 201, message: Created}
+- request:
+ body: null
+ headers:
+ Accept: [application/json]
+ Accept-Encoding: ['gzip, deflate']
+ CommandName: [cognitiveservices account show]
+ Connection: [keep-alive]
+ Content-Type: [application/json; charset=utf-8]
+ User-Agent: [python/3.6.0 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7
+ msrest_azure/0.4.7 cognitiveservicesmanagementclient/2017-04-18 Azure-SDK-For-Python
+ AZURECLI/2.0.3+dev]
+ accept-language: [en-US]
+ method: GET
+ uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002?api-version=2017-04-18
+ response:
+ body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","etag":"\"00007a03-0000-0000-0000-5908cceb0000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","internalId":"c56a9d85d19445db8be4236f26168205","dateCreated":"2017-05-02T18:16:11.361061Z","provisioningState":"Succeeded"}}'}
+ headers:
+ cache-control: [no-cache]
+ content-length: ['595']
+ content-type: [application/json; charset=utf-8]
+ date: ['Tue, 02 May 2017 18:16:13 GMT']
+ etag: ['"00007a03-0000-0000-0000-5908cceb0000"']
+ expires: ['-1']
+ pragma: [no-cache]
+ server: [Microsoft-IIS/8.5]
+ strict-transport-security: [max-age=31536000; includeSubDomains]
+ transfer-encoding: [chunked]
+ vary: [Accept-Encoding]
+ x-aspnet-version: [4.0.30319]
+ x-powered-by: [ASP.NET]
+ status: {code: 200, message: OK}
+- request:
+ body: 'b''b\''{"sku": {"name": "S0"}, "tags": {"tagname000003": "tagvalue000004"}}\'''''
+ headers:
+ Accept: [application/json]
+ Accept-Encoding: ['gzip, deflate']
+ CommandName: [cognitiveservices account update]
+ Connection: [keep-alive]
+ Content-Length: ['61']
+ Content-Type: [application/json; charset=utf-8]
+ User-Agent: [python/3.6.0 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7
+ msrest_azure/0.4.7 cognitiveservicesmanagementclient/2017-04-18 Azure-SDK-For-Python
+ AZURECLI/2.0.3+dev]
+ accept-language: [en-US]
+ method: PATCH
+ uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002?api-version=2017-04-18
+ response:
+ body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","tags":{"tagname000003":"tagvalue000004"},"etag":"\"00007c03-0000-0000-0000-5908ccef0000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","provisioningState":"Succeeded","internalId":"c56a9d85d19445db8be4236f26168205","dateCreated":"2017-05-02T18:16:11.361061Z"}}'}
+ headers:
+ cache-control: [no-cache]
+ content-length: ['630']
+ content-type: [application/json; charset=utf-8]
+ date: ['Tue, 02 May 2017 18:16:15 GMT']
+ etag: ['"00007c03-0000-0000-0000-5908ccef0000"']
+ expires: ['-1']
+ pragma: [no-cache]
+ server: [Microsoft-IIS/8.5]
+ strict-transport-security: [max-age=31536000; includeSubDomains]
+ transfer-encoding: [chunked]
+ vary: [Accept-Encoding]
+ x-aspnet-version: [4.0.30319]
+ x-ms-ratelimit-remaining-subscription-writes: ['1199']
+ x-powered-by: [ASP.NET]
+ status: {code: 200, message: OK}
+- request:
+ body: null
+ headers:
+ Accept: [application/json]
+ Accept-Encoding: ['gzip, deflate']
+ CommandName: [cognitiveservices account keys list]
+ Connection: [keep-alive]
+ Content-Length: ['0']
+ Content-Type: [application/json; charset=utf-8]
+ User-Agent: [python/3.6.0 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7
+ msrest_azure/0.4.7 cognitiveservicesmanagementclient/2017-04-18 Azure-SDK-For-Python
+ AZURECLI/2.0.3+dev]
+ accept-language: [en-US]
+ method: POST
+ uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002/listKeys?api-version=2017-04-18
+ response:
+ body: {string: '{"key1":"d29ffb312c8949e285e7f8b550b184db","key2":"ad0971db96c74b5fa792b498bad2363d"}'}
+ headers:
+ cache-control: [no-cache]
+ content-length: ['85']
+ content-type: [application/json; charset=utf-8]
+ date: ['Tue, 02 May 2017 18:16:17 GMT']
+ expires: ['-1']
+ pragma: [no-cache]
+ server: [Microsoft-IIS/8.5]
+ strict-transport-security: [max-age=31536000; includeSubDomains]
+ transfer-encoding: [chunked]
+ vary: [Accept-Encoding]
+ x-aspnet-version: [4.0.30319]
+ x-ms-ratelimit-remaining-subscription-writes: ['1199']
+ x-powered-by: [ASP.NET]
+ status: {code: 200, message: OK}
+- request:
+ body: '{"keyName": "Key1"}'
+ headers:
+ Accept: [application/json]
+ Accept-Encoding: ['gzip, deflate']
+ CommandName: [cognitiveservices account keys regenerate]
+ Connection: [keep-alive]
+ Content-Length: ['19']
+ Content-Type: [application/json; charset=utf-8]
+ User-Agent: [python/3.6.0 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7
+ msrest_azure/0.4.7 cognitiveservicesmanagementclient/2017-04-18 Azure-SDK-For-Python
+ AZURECLI/2.0.3+dev]
+ accept-language: [en-US]
+ method: POST
+ uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002/regenerateKey?api-version=2017-04-18
+ response:
+ body: {string: '{"key1":"ff544e6348384eb38ca3066e73a3ae6f","key2":"ad0971db96c74b5fa792b498bad2363d"}'}
+ headers:
+ cache-control: [no-cache]
+ content-length: ['85']
+ content-type: [application/json; charset=utf-8]
+ date: ['Tue, 02 May 2017 18:16:19 GMT']
+ expires: ['-1']
+ pragma: [no-cache]
+ server: [Microsoft-IIS/8.5]
+ strict-transport-security: [max-age=31536000; includeSubDomains]
+ transfer-encoding: [chunked]
+ vary: [Accept-Encoding]
+ x-aspnet-version: [4.0.30319]
+ x-ms-ratelimit-remaining-subscription-writes: ['1199']
+ x-powered-by: [ASP.NET]
+ status: {code: 200, message: OK}
+- request:
+ body: null
+ headers:
+ Accept: [application/json]
+ Accept-Encoding: ['gzip, deflate']
+ CommandName: [cognitiveservices list]
+ Connection: [keep-alive]
+ Content-Type: [application/json; charset=utf-8]
+ User-Agent: [python/3.6.0 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7
+ msrest_azure/0.4.7 cognitiveservicesmanagementclient/2017-04-18 Azure-SDK-For-Python
+ AZURECLI/2.0.3+dev]
+ accept-language: [en-US]
+ method: GET
+ uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts?api-version=2017-04-18
+ response:
+ body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002","name":"cog000002","type":"Microsoft.CognitiveServices/accounts","location":"westeurope","sku":{"name":"S0"},"kind":"Face","tags":{"tagname000003":"tagvalue000004"},"etag":"\"00008003-0000-0000-0000-5908ccf20000\"","properties":{"endpoint":"https://westeurope.api.cognitive.microsoft.com/face/v1.0","provisioningState":"Succeeded","internalId":"c56a9d85d19445db8be4236f26168205","dateCreated":"2017-05-02T18:16:11.361061Z"}}]}'}
+ headers:
+ cache-control: [no-cache]
+ content-length: ['642']
+ content-type: [application/json; charset=utf-8]
+ date: ['Tue, 02 May 2017 18:16:20 GMT']
+ expires: ['-1']
+ pragma: [no-cache]
+ server: [Microsoft-IIS/8.5]
+ strict-transport-security: [max-age=31536000; includeSubDomains]
+ transfer-encoding: [chunked]
+ vary: [Accept-Encoding]
+ x-aspnet-version: [4.0.30319]
+ x-powered-by: [ASP.NET]
+ status: {code: 200, message: OK}
+- request:
+ body: null
+ headers:
+ Accept: [application/json]
+ Accept-Encoding: ['gzip, deflate']
+ CommandName: [cognitiveservices account delete]
+ Connection: [keep-alive]
+ Content-Length: ['0']
+ Content-Type: [application/json; charset=utf-8]
+ User-Agent: [python/3.6.0 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7
+ msrest_azure/0.4.7 cognitiveservicesmanagementclient/2017-04-18 Azure-SDK-For-Python
+ AZURECLI/2.0.3+dev]
+ accept-language: [en-US]
+ method: DELETE
+ uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.CognitiveServices/accounts/cog000002?api-version=2017-04-18
+ response:
+ body: {string: ''}
+ headers:
+ cache-control: [no-cache]
+ content-length: ['0']
+ date: ['Tue, 02 May 2017 18:16:22 GMT']
+ expires: ['-1']
+ pragma: [no-cache]
+ server: [Microsoft-IIS/8.5]
+ strict-transport-security: [max-age=31536000; includeSubDomains]
+ x-aspnet-version: [4.0.30319]
+ x-ms-ratelimit-remaining-subscription-writes: ['1199']
+ x-powered-by: [ASP.NET]
+ status: {code: 200, message: OK}
+- request:
+ body: null
+ headers:
+ Accept: [application/json]
+ Accept-Encoding: ['gzip, deflate']
+ CommandName: [group delete]
+ Connection: [keep-alive]
+ Content-Length: ['0']
+ Content-Type: [application/json; charset=utf-8]
+ User-Agent: [python/3.6.0 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7
+ msrest_azure/0.4.7 resourcemanagementclient/1.0.0rc1 Azure-SDK-For-Python
+ AZURECLI/2.0.3+dev]
+ accept-language: [en-US]
+ method: DELETE
+ uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001?api-version=2016-09-01
+ response:
+ body: {string: ''}
+ headers:
+ cache-control: [no-cache]
+ content-length: ['0']
+ date: ['Tue, 02 May 2017 18:16:23 GMT']
+ expires: ['-1']
+ location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1DTElURVNUOjJFUkc0OTc2NzcxQUVFQjA5RjEwNTE4NDA0NUEyN0U5QzgxNEZCQXxGMUJCM0M4NENBODZDQjJGLVdFU1RVUyIsImpvYkxvY2F0aW9uIjoid2VzdHVzIn0?api-version=2016-09-01']
+ pragma: [no-cache]
+ retry-after: ['15']
+ strict-transport-security: [max-age=31536000; includeSubDomains]
+ x-ms-ratelimit-remaining-subscription-writes: ['1199']
+ status: {code: 202, message: Accepted}
+version: 1
diff --git a/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py b/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py
new file mode 100644
index 00000000000..55dc6ec1862
--- /dev/null
+++ b/src/command_modules/azure-cli-cognitiveservices/tests/test_cognitiveservices_command.py
@@ -0,0 +1,63 @@
+# --------------------------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# --------------------------------------------------------------------------------------------
+import os
+import time
+import unittest
+
+from azure.cli.testsdk import ScenarioTest, JMESPathCheck, ResourceGroupPreparer
+from azure.cli.core.util import CLIError
+
+
+class CognitiveServicesTests(ScenarioTest):
+ @ResourceGroupPreparer()
+ def test_cognitiveservices_crud(self, resource_group):
+ sname = self.create_random_name(prefix='cog', length=12)
+ resource_location = 'westeurope'
+
+ # test to create cognitive services account
+ self.cmd('az cognitiveservices account create -n {} -g {} --kind {} --sku {} -l {} --yes'.format(
+ sname, resource_group, 'Face', 'S0', resource_location), checks=[
+ JMESPathCheck('name', sname),
+ JMESPathCheck('location', resource_location),
+ JMESPathCheck('sku.name', 'S0'),
+ JMESPathCheck('provisioningState', 'Succeeded')])
+
+ # test to show the details of cognitive services account
+ self.cmd('az cognitiveservices account show -n {} -g {}'.format(
+ sname, resource_group), checks=[
+ JMESPathCheck('name', sname),
+ JMESPathCheck('resourceGroup', resource_group)])
+
+ # test to update the properties of cognitive servcies account
+ tagname = self.create_random_name(prefix='tagname', length=10)
+ tagvalue = self.create_random_name(prefix='tagvalue', length=10)
+ self.cmd('az cognitiveservices account update -n {} -g {} --sku {} --tags {}'.format(
+ sname, resource_group, 'S0', tagname + '=' + tagvalue), checks=[
+ JMESPathCheck('sku.name', 'S0'),
+ JMESPathCheck('tags', {tagname: tagvalue})])
+
+ # test to list keys of a cogntive services account
+ oldkeys = self.cmd('az cognitiveservices account keys list -n {} -g {}'.format(
+ sname, resource_group), checks=[
+ JMESPathCheck('length(key1)', 32),
+ JMESPathCheck('length(key2)', 32)]).get_output_in_json()
+
+ # test to regenerate the keys of a cognitive services account
+ newkeys = self.cmd('az cognitiveservices account keys regenerate -n {} -g {} --key-name key1'.format(
+ sname, resource_group)).get_output_in_json()
+ assert oldkeys != newkeys
+
+ # test to list cognitive service accounts under current resource group
+ self.cmd('az cognitiveservices list -g {}'.format(resource_group), checks=[
+ JMESPathCheck('length(@)', 1)])
+
+ # test to delete the cognitive services account
+ exitcode = self.cmd('az cognitiveservices account delete -n {} -g {}'.format(
+ sname, resource_group)).exit_code
+ assert exitcode == 0
+
+
+if __name__ == '__main__':
+ unittest.main()