diff --git a/src/azure-cli/azure/cli/command_modules/synapse/manual/_client_factory.py b/src/azure-cli/azure/cli/command_modules/synapse/manual/_client_factory.py index dc75c1cd046..e862ac32eb5 100644 --- a/src/azure-cli/azure/cli/command_modules/synapse/manual/_client_factory.py +++ b/src/azure-cli/azure/cli/command_modules/synapse/manual/_client_factory.py @@ -256,5 +256,9 @@ def cf_synapse_sql_script(cli_ctx, workspace_name): return cf_synapse_client_artifacts_factory(cli_ctx, workspace_name).sql_script +def cf_synapse_client_azure_ad_only_authentications_factory(cli_ctx, *_): + return cf_synapse(cli_ctx).azure_ad_only_authentications + + def cf_synapse_link_connection(cli_ctx, workspace_name): return cf_synapse_client_artifacts_factory(cli_ctx, workspace_name).link_connection diff --git a/src/azure-cli/azure/cli/command_modules/synapse/manual/_help.py b/src/azure-cli/azure/cli/command_modules/synapse/manual/_help.py index 2b38f7345f7..5c5357c89c5 100644 --- a/src/azure-cli/azure/cli/command_modules/synapse/manual/_help.py +++ b/src/azure-cli/azure/cli/command_modules/synapse/manual/_help.py @@ -2273,6 +2273,41 @@ --file 'path/test.sql' """ +helps['synapse ad-only-auth'] = """ +type: group +short-summary: Manage Azure Active Directly only Authentication settings for this Synapse workspace. +""" + +helps['synapse ad-only-auth get'] = """ +type: command +short-summary: Get a specific Azure Active Directly only Authentication property. +examples: + - name: Get a specific Azure Active Directly only Authentication property. + text: |- + az synapse ad-only-auth get --workspace-name testsynapseworkspace \\ + -g testrg +""" + +helps['synapse ad-only-auth enable'] = """ +type: command +short-summary: Enable Azure Active Directly only Authentication for this Synapse workspace. +examples: + - name: Enable Azure Active Directly only Authentication for this Synapse workspace. + text: |- + az synapse ad-only-auth enable --workspace-name testsynapseworkspace \\ + -g testresourcegroup +""" + +helps['synapse ad-only-auth disable'] = """ +type: command +short-summary: Disable Azure Active Directly only Authentication for this Synapse workspace. +examples: + - name: Disable Azure Active Directly only Authentication for this Synapse workspace. + text: |- + az synapse ad-only-auth disable --workspace-name testsynapseworkspace \\ + -g testresourcegroup +""" + helps['synapse link-connection'] = """ type: group short-summary: Manage Synapse's link connection. diff --git a/src/azure-cli/azure/cli/command_modules/synapse/manual/_params.py b/src/azure-cli/azure/cli/command_modules/synapse/manual/_params.py index 56527cd638f..bf777adc6b1 100644 --- a/src/azure-cli/azure/cli/command_modules/synapse/manual/_params.py +++ b/src/azure-cli/azure/cli/command_modules/synapse/manual/_params.py @@ -1101,6 +1101,11 @@ def load_arguments(self, _): c.argument('output_folder', type=str, help='The name of the output folder') c.argument('script_name', arg_type=name_type, help='The name of the KQL script.') + for scope in ['enable', 'disable']: + with self.argument_context('synapse ad-only-auth ' + scope) as c: + c.argument('workspace_name', arg_type=workspace_name_arg_type, help='The name of the workspace') + c.argument('resource_group_name', resource_group_name_type) + # synapse link connections with self.argument_context('synapse link-connection list') as c: c.argument('workspace_name', arg_type=workspace_name_arg_type) diff --git a/src/azure-cli/azure/cli/command_modules/synapse/manual/commands.py b/src/azure-cli/azure/cli/command_modules/synapse/manual/commands.py index 2eac338bd01..e0ed9f9e631 100644 --- a/src/azure-cli/azure/cli/command_modules/synapse/manual/commands.py +++ b/src/azure-cli/azure/cli/command_modules/synapse/manual/commands.py @@ -32,6 +32,7 @@ def load_command_table(self, _): from ._client_factory import cf_kusto_pool from ._client_factory import cf_kusto_script from ._client_factory import cf_kusto_scripts + from ._client_factory import cf_synapse_client_azure_ad_only_authentications_factory def get_custom_sdk(custom_module, client_factory): return CliCommandType( @@ -207,6 +208,10 @@ def get_custom_sdk(custom_module, client_factory): client_factory=cf_kusto_script, ) + synapse_adonlyauthentications_sdk = CliCommandType( + operations_tmpl='azure.mgmt.synapse.operations#AzureADOnlyAuthenticationsOperations.{}', + client_factory=cf_synapse_client_azure_ad_only_authentications_factory, + ) synapse_link_connection_sdk = CliCommandType( operations_tmpl='azure.synapse.artifacts.operations#linkconnectionOperations.{}', client_factory=None, @@ -583,6 +588,13 @@ def get_custom_sdk(custom_module, client_factory): g.custom_command('export', 'synapse_kusto_script_export') g.custom_wait_command('wait', 'synapse_kusto_script_show') + with self.command_group('synapse ad-only-auth', command_type=synapse_adonlyauthentications_sdk, + custom_command_type=get_custom_sdk('adonlyauthentications', cf_synapse_client_azure_ad_only_authentications_factory), + client_factory=cf_synapse_client_azure_ad_only_authentications_factory) as g: + g.custom_command('enable', 'synapse_enable_adonly_auth') + g.custom_command('disable', 'synapse_disable_adonly_auth') + g.command('get', 'list') + with self.command_group('synapse link-connection', synapse_link_connection_sdk, custom_command_type=get_custom_sdk('artifacts', None)) as g: g.custom_command('list', 'list_link_connection') diff --git a/src/azure-cli/azure/cli/command_modules/synapse/manual/operations/adonlyauthentications.py b/src/azure-cli/azure/cli/command_modules/synapse/manual/operations/adonlyauthentications.py new file mode 100644 index 00000000000..6ca08b91c99 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/synapse/manual/operations/adonlyauthentications.py @@ -0,0 +1,21 @@ +# -------------------------------------------------------------------------------------------- +# 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.synapse.models import AzureADOnlyAuthentication + + +def synapse_enable_adonly_auth(client, resource_group_name, workspace_name): + azure_ad_only_authentication_name = "default" + azure_ad_only_authentication_info = AzureADOnlyAuthentication(azure_ad_only_authentication=True) + + return client.begin_create(resource_group_name, workspace_name, + azure_ad_only_authentication_name, azure_ad_only_authentication_info) + + +def synapse_disable_adonly_auth(client, resource_group_name, workspace_name): + azure_ad_only_authentication_name = "default" + azure_ad_only_authentication_info = AzureADOnlyAuthentication(azure_ad_only_authentication=False) + + return client.begin_create(resource_group_name, workspace_name, + azure_ad_only_authentication_name, azure_ad_only_authentication_info) diff --git a/src/azure-cli/azure/cli/command_modules/synapse/tests/latest/recordings/test_ad_only_auth.yaml b/src/azure-cli/azure/cli/command_modules/synapse/tests/latest/recordings/test_ad_only_auth.yaml new file mode 100644 index 00000000000..24362eafc65 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/synapse/tests/latest/recordings/test_ad_only_auth.yaml @@ -0,0 +1,668 @@ +interactions: +- request: + body: '{"location": "eastus", "identity": {"type": "SystemAssigned"}, "properties": + {"defaultDataLakeStorage": {"accountUrl": "https://adlsgen2000002.dfs.core.windows.net", + "filesystem": "testfilesystem"}, "sqlAdministratorLoginPassword": "Pswd1000004", + "sqlAdministratorLogin": "cliuser1"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - synapse workspace create + Connection: + - keep-alive + Content-Length: + - '284' + Content-Type: + - application/json + ParameterSetName: + - --name --resource-group --storage-account --file-system --sql-admin-login-user + --sql-admin-login-password --location + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-synapse/2.1.0b2 Python/3.8.9 (Windows-10-10.0.19041-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003?api-version=2021-06-01 + response: + body: + string: '{"properties":{"defaultDataLakeStorage":{"createManagedPrivateEndpoint":false,"accountUrl":"https://adlsgen2000002.dfs.core.windows.net","filesystem":"testfilesystem"},"encryption":{"doubleEncryptionEnabled":false},"provisioningState":"Provisioning","connectivityEndpoints":{"web":"https://web.azuresynapse.net?workspace=%2fsubscriptions%2f051ddeca-1ed6-4d8b-ba6f-1ff561e5f3b3%2fresourceGroups%2fsynapse-cli000001%2fproviders%2fMicrosoft.Synapse%2fworkspaces%2fclitest000003","dev":"https://clitest000003.dev.azuresynapse.net","sqlOnDemand":"clitest000003-ondemand.sql.azuresynapse.net","sql":"clitest000003.sql.azuresynapse.net"},"managedResourceGroupName":"synapseworkspace-managedrg-5da050b3-8cfd-4522-9867-dd28c67017ca","privateEndpointConnections":[],"workspaceUID":"9c658053-3fbd-4c83-901a-0bacd4fed030","extraProperties":{"WorkspaceType":"Normal"},"publicNetworkAccess":"Enabled","cspWorkspaceAdminProperties":{"initialWorkspaceAdminObjectId":"6a33200f-2b27-4fda-8567-b0c70d532441"},"trustedServiceBypassEnabled":false},"type":"Microsoft.Synapse/workspaces","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003","location":"eastus","name":"clitest000003","identity":{"type":"SystemAssigned","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","principalId":"111e6cda-ab18-438a-bce4-ce612b0d6756"}}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/operationStatuses/ae57c513-2fd5-4b25-a31e-847cc2ce1eec?api-version=2021-06-01 + cache-control: + - no-cache + content-length: + - '1393' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 13 Jul 2022 07:07:16 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - synapse workspace create + Connection: + - keep-alive + ParameterSetName: + - --name --resource-group --storage-account --file-system --sql-admin-login-user + --sql-admin-login-password --location + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-synapse/2.1.0b2 Python/3.8.9 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/operationStatuses/ae57c513-2fd5-4b25-a31e-847cc2ce1eec?api-version=2021-06-01 + response: + body: + string: '{"status":"InProgress"}' + headers: + cache-control: + - no-cache + content-length: + - '23' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 13 Jul 2022 07:07:47 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - synapse workspace create + Connection: + - keep-alive + ParameterSetName: + - --name --resource-group --storage-account --file-system --sql-admin-login-user + --sql-admin-login-password --location + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-synapse/2.1.0b2 Python/3.8.9 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/operationStatuses/ae57c513-2fd5-4b25-a31e-847cc2ce1eec?api-version=2021-06-01 + response: + body: + string: '{"status":"InProgress"}' + headers: + cache-control: + - no-cache + content-length: + - '23' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 13 Jul 2022 07:08:18 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - synapse workspace create + Connection: + - keep-alive + ParameterSetName: + - --name --resource-group --storage-account --file-system --sql-admin-login-user + --sql-admin-login-password --location + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-synapse/2.1.0b2 Python/3.8.9 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/operationStatuses/ae57c513-2fd5-4b25-a31e-847cc2ce1eec?api-version=2021-06-01 + response: + body: + string: '{"status":"InProgress"}' + headers: + cache-control: + - no-cache + content-length: + - '23' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 13 Jul 2022 07:08:49 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - synapse workspace create + Connection: + - keep-alive + ParameterSetName: + - --name --resource-group --storage-account --file-system --sql-admin-login-user + --sql-admin-login-password --location + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-synapse/2.1.0b2 Python/3.8.9 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/operationStatuses/ae57c513-2fd5-4b25-a31e-847cc2ce1eec?api-version=2021-06-01 + response: + body: + string: '{"status":"InProgress"}' + headers: + cache-control: + - no-cache + content-length: + - '23' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 13 Jul 2022 07:09:19 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - synapse workspace create + Connection: + - keep-alive + ParameterSetName: + - --name --resource-group --storage-account --file-system --sql-admin-login-user + --sql-admin-login-password --location + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-synapse/2.1.0b2 Python/3.8.9 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/operationStatuses/ae57c513-2fd5-4b25-a31e-847cc2ce1eec?api-version=2021-06-01 + response: + body: + string: '{"status":"Succeeded"}' + headers: + cache-control: + - no-cache + content-length: + - '22' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 13 Jul 2022 07:09:50 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - synapse workspace create + Connection: + - keep-alive + ParameterSetName: + - --name --resource-group --storage-account --file-system --sql-admin-login-user + --sql-admin-login-password --location + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-synapse/2.1.0b2 Python/3.8.9 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003?api-version=2021-06-01 + response: + body: + string: '{"properties":{"defaultDataLakeStorage":{"createManagedPrivateEndpoint":false,"accountUrl":"https://adlsgen2000002.dfs.core.windows.net","filesystem":"testfilesystem"},"encryption":{"doubleEncryptionEnabled":false},"provisioningState":"Succeeded","connectivityEndpoints":{"web":"https://web.azuresynapse.net?workspace=%2fsubscriptions%2f051ddeca-1ed6-4d8b-ba6f-1ff561e5f3b3%2fresourceGroups%2fsynapse-cli000001%2fproviders%2fMicrosoft.Synapse%2fworkspaces%2fclitest000003","dev":"https://clitest000003.dev.azuresynapse.net","sqlOnDemand":"clitest000003-ondemand.sql.azuresynapse.net","sql":"clitest000003.sql.azuresynapse.net"},"managedResourceGroupName":"synapseworkspace-managedrg-5da050b3-8cfd-4522-9867-dd28c67017ca","sqlAdministratorLogin":"cliuser1","privateEndpointConnections":[],"workspaceUID":"9c658053-3fbd-4c83-901a-0bacd4fed030","extraProperties":{"WorkspaceType":"Normal","IsScopeEnabled":false},"publicNetworkAccess":"Enabled","cspWorkspaceAdminProperties":{"initialWorkspaceAdminObjectId":"6a33200f-2b27-4fda-8567-b0c70d532441"},"trustedServiceBypassEnabled":false},"type":"Microsoft.Synapse/workspaces","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003","location":"eastus","name":"clitest000003","identity":{"type":"SystemAssigned","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","principalId":"111e6cda-ab18-438a-bce4-ce612b0d6756"}}' + headers: + cache-control: + - no-cache + content-length: + - '1448' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 13 Jul 2022 07:09:51 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - synapse ad-only-auth get + Connection: + - keep-alive + ParameterSetName: + - --resource-group --workspace-name + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-synapse/2.1.0b2 Python/3.8.9 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/azureADOnlyAuthentications?api-version=2021-06-01 + response: + body: + string: '{"value":[{"properties":{"azureADOnlyAuthentication":false,"creationDate":"2022-07-13T07:07:16.3133333Z","state":"Consistent"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/azureADOnlyAuthentications/default","name":"default","type":"Microsoft.Synapse/workspaces/azureADOnlyAuthentications"}]}' + headers: + cache-control: + - no-cache + content-length: + - '391' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 13 Jul 2022 07:09:53 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"properties": {"azureADOnlyAuthentication": false}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - synapse ad-only-auth disable + Connection: + - keep-alive + Content-Length: + - '52' + Content-Type: + - application/json + ParameterSetName: + - --resource-group --workspace-name + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-synapse/2.1.0b2 Python/3.8.9 (Windows-10-10.0.19041-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/azureADOnlyAuthentications/default?api-version=2021-06-01 + response: + body: + string: '{"properties":{"azureADOnlyAuthentication":false,"creationDate":"2022-07-13T07:09:58.1Z","state":"Updating"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/azureADOnlyAuthentications/default","name":"default","type":"Microsoft.Synapse/workspaces/azureADOnlyAuthentications"}' + headers: + access-control-allow-headers: + - Location + access-control-expose-headers: + - Location + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/operationStatuses/e54ded64-935b-47d9-a08d-ab5d99fe2e5d?api-version=2021-06-01 + cache-control: + - no-cache + content-length: + - '371' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 13 Jul 2022 07:09:57 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/operationResults/e54ded64-935b-47d9-a08d-ab5d99fe2e5d?api-version=2021-06-01 + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - synapse ad-only-auth disable + Connection: + - keep-alive + ParameterSetName: + - --resource-group --workspace-name + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-synapse/2.1.0b2 Python/3.8.9 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/operationStatuses/e54ded64-935b-47d9-a08d-ab5d99fe2e5d?api-version=2021-06-01 + response: + body: + string: '{"status":"Succeeded"}' + headers: + cache-control: + - no-cache + content-length: + - '22' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 13 Jul 2022 07:10:29 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - synapse ad-only-auth disable + Connection: + - keep-alive + ParameterSetName: + - --resource-group --workspace-name + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-synapse/2.1.0b2 Python/3.8.9 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/operationResults/e54ded64-935b-47d9-a08d-ab5d99fe2e5d?api-version=2021-06-01 + response: + body: + string: '{"properties":{"azureADOnlyAuthentication":false,"creationDate":"2022-07-13T07:10:12.6733333Z","state":"Consistent"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/azureADOnlyAuthentications/default","name":"default","type":"Microsoft.Synapse/workspaces/azureADOnlyAuthentications"}' + headers: + cache-control: + - no-cache + content-length: + - '379' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 13 Jul 2022 07:10:30 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"properties": {"azureADOnlyAuthentication": true}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - synapse ad-only-auth enable + Connection: + - keep-alive + Content-Length: + - '51' + Content-Type: + - application/json + ParameterSetName: + - --resource-group --workspace-name + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-synapse/2.1.0b2 Python/3.8.9 (Windows-10-10.0.19041-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/azureADOnlyAuthentications/default?api-version=2021-06-01 + response: + body: + string: '{"properties":{"azureADOnlyAuthentication":true,"creationDate":"2022-07-13T07:10:32.3866667Z","state":"Updating"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/azureADOnlyAuthentications/default","name":"default","type":"Microsoft.Synapse/workspaces/azureADOnlyAuthentications"}' + headers: + access-control-allow-headers: + - Location + access-control-expose-headers: + - Location + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/operationStatuses/7fe6d354-bfb3-4ca0-9d6b-08ad192d7b25?api-version=2021-06-01 + cache-control: + - no-cache + content-length: + - '376' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 13 Jul 2022 07:10:32 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/operationResults/7fe6d354-bfb3-4ca0-9d6b-08ad192d7b25?api-version=2021-06-01 + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1198' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - synapse ad-only-auth enable + Connection: + - keep-alive + ParameterSetName: + - --resource-group --workspace-name + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-synapse/2.1.0b2 Python/3.8.9 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/operationStatuses/7fe6d354-bfb3-4ca0-9d6b-08ad192d7b25?api-version=2021-06-01 + response: + body: + string: '{"status":"Succeeded"}' + headers: + cache-control: + - no-cache + content-length: + - '22' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 13 Jul 2022 07:11:02 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - synapse ad-only-auth enable + Connection: + - keep-alive + ParameterSetName: + - --resource-group --workspace-name + User-Agent: + - AZURECLI/2.37.0 azsdk-python-mgmt-synapse/2.1.0b2 Python/3.8.9 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/operationResults/7fe6d354-bfb3-4ca0-9d6b-08ad192d7b25?api-version=2021-06-01 + response: + body: + string: '{"properties":{"azureADOnlyAuthentication":true,"creationDate":"2022-07-13T07:10:46.26Z","state":"Consistent"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/synapse-cli000001/providers/Microsoft.Synapse/workspaces/clitest000003/azureADOnlyAuthentications/default","name":"default","type":"Microsoft.Synapse/workspaces/azureADOnlyAuthentications"}' + headers: + cache-control: + - no-cache + content-length: + - '373' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 13 Jul 2022 07:11:02 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/synapse/tests/latest/test_synapse_scenario.py b/src/azure-cli/azure/cli/command_modules/synapse/tests/latest/test_synapse_scenario.py index e90785530d5..ce93842f053 100644 --- a/src/azure-cli/azure/cli/command_modules/synapse/tests/latest/test_synapse_scenario.py +++ b/src/azure-cli/azure/cli/command_modules/synapse/tests/latest/test_synapse_scenario.py @@ -2987,6 +2987,36 @@ def test_sqlscript(self): 'az synapse sql-script show --workspace-name {workspace} --name {name}', expect_failure=True) + @ResourceGroupPreparer(name_prefix='synapse-cli', random_name_length=16) + @StorageAccountPreparer(name_prefix='adlsgen2', length=16, location=location, key='storage-account') + def test_ad_only_auth(self): + self.kwargs.update({ + }) + + # create a workspace + self._create_workspace() + + self.cmd( + 'az synapse ad-only-auth get --resource-group {rg} --workspace-name {workspace}', + checks=[ + self.check('[0].type', 'Microsoft.Synapse/workspaces/azureADOnlyAuthentications') + ] + ) + + self.cmd( + 'az synapse ad-only-auth disable --resource-group {rg} --workspace-name {workspace}', + checks=[ + self.check('azureAdOnlyAuthentication', False) + ] + ) + + self.cmd( + 'az synapse ad-only-auth enable --resource-group {rg} --workspace-name {workspace}', + checks=[ + self.check('azureAdOnlyAuthentication', True) + ] + ) + @record_only() def test_link_connection(self): self.kwargs.update({