Azure / azure-devops-cli-extension

Azure DevOps Extension for Azure CLI
https://docs.microsoft.com/en-us/cli/azure/ext/azure-devops/?view=azure-cli-latest
MIT License
625 stars 241 forks source link

[Bug] az devops security group list fails on Azure DevOps Server 2020 on premise #1126

Open mrweiland opened 3 years ago

mrweiland commented 3 years ago

Describe the bug Connected to on-premise azure devops 2020 instance. When running az devops security group list i get API resource location 048aee0a-7072-4cde-ab73-7af77b1e0b4e is not registered on https://XXXXXX/labcollection.

I have connected with PAT token full access as my admin account.

About Azure DevOps Server 2020 Version Dev18.M170.6

To Reproduce azure-cli 2.23.0

core 2.23.0 telemetry 1.0.6

Extensions: azure-devops 0.18.0

Steps to reproduce the behavior:

  1. login using az login
  2. setup defaults..
  3. Run command....
  4. See error

Expected behavior Work with security settings with scripting.

Debug logs

C:\Users\xxx> az devops security group list --debug
cli.knack.cli: Command arguments: ['devops', 'security', 'group', 'list', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x030640B8>, <function OutputProducer.on_global_arguments at 0x031D1F10>, <function CLIQuery.on_global_arguments at 0x031F5B20>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'devops': ['azext_devops']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: Total (0)                 0.000         0         0
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name                  Load Time    Groups  Commands  Directory
cli.azure.cli.core: azure-devops              0.148        60       191  C:\Users\admtolb\.azure\cliextensions\azure-devops
cli.azure.cli.core: Total (1)                 0.148        60       191
cli.azure.cli.core: Loaded 60 groups, 191 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : devops security group list
cli.azure.cli.core: Command table: devops security group list
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x035FEFA0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\admtolb\.azure\commands\2021-05-11.10-58-33.devops_security_group_list.16200.log'.
az_command_data_logger: command args: devops security group list --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x03645100>, <function register_global_query_examples_argument.<locals>.register_query_examples at 0x03656778>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x036567C0>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x03656850>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x031D1F58>, <function CLIQuery.handle_query_parameter at 0x031F5B68>, <function register_global_query_examples_argument.<locals>.handle_example_parameter at 0x03645190>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x03656808>, <function DevCommandsLoader.post_parse_args at 0x0379E418>]
az_command_data_logger: extension name: azure-devops
az_command_data_logger: extension version: 0.18.0
cli.azext_devops.dev.common.git: GitDetect: Could not detect current remotes based on current working directory.
cli.azext_devops.dev.common.git: Command '['git', 'remote', '-v']' returned non-zero exit status 128.
Traceback (most recent call last):
  File "C:\Users\admtolb\.azure\cliextensions\azure-devops\azext_devops\dev\common\git.py", line 106, in get_git_remotes
    output = subprocess.check_output([_GIT_EXE, 'remote', '-v'], stderr=subprocess.STDOUT)
  File "subprocess.py", line 415, in check_output
  File "subprocess.py", line 516, in run
subprocess.CalledProcessError: Command '['git', 'remote', '-v']' returned non-zero exit status 128.
cli.azext_devops.dev.common.services: Detect: Url discovery took 0:00:00.064221
cli.azext_devops.dev.common._credentials: Getting credential: azdevops-cli:https://xxx/labcollection
keyring.backend: Loading KWallet
keyring.backend: Loading SecretService
keyring.backend: Loading Windows
keyring.backend: Loading chainer
keyring.backend: Loading macOS
cli.azext_devops.dev.common.credential_store: Keyring backend : keyring.backends.Windows.WinVaultKeyring (priority: 5)
cli.azext_devops.dev.common.services: PAT is present which can be used against this instance
cli.azure.cli.core: Current cloud config:
AzureCloud
cli.azext_devops.dev.common.services: az login is not present
cli.azext_devops.dev.common.services: There are no active accounts.
Traceback (most recent call last):
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/_profile.py", line 502, in get_current_account_user
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/_profile.py", line 511, in get_subscription
knack.util.CLIError: Please run 'az login' to setup account.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\admtolb\.azure\cliextensions\azure-devops\azext_devops\dev\common\services.py", line 61, in _get_credentials
    token_from_az_login = get_token_from_az_logins(organization, pat_token_present)
  File "C:\Users\admtolb\.azure\cliextensions\azure-devops\azext_devops\dev\common\services.py", line 118, in get_token_from_az_logins
    dummy_user = profile.get_current_account_user()     # noqa: F841
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/_profile.py", line 504, in get_current_account_user
knack.util.CLIError: There are no active accounts.
cli.azext_devops.dev.common._credentials: Getting credential: azdevops-cli:https://xxxx/labcollection
cli.azext_devops.dev.common.credential_store: Keyring backend : keyring.backends.Windows.WinVaultKeyring (priority: 5)
cli.azext_devops.dev.common.services: Creating connection with personal access token.
msrest.universal_http.requests: Configuring retry: max_retries=3, backoff_factor=0.8, max_backoff=90
cli.azext_devops.dev.common.telemetry: Azure devops telemetry enabled.
cli.azext_devops.dev.common.telemetry: Logging telemetry to azure devops server.
msrest.universal_http.requests: Configuring retry: max_retries=3, backoff_factor=0.8, max_backoff=90
msrest.universal_http.requests: Configuring retry: max_retries=3, backoff_factor=0.8, max_backoff=90
azext_devops.devops_sdk._file_cache: Loading cache file: C:\Users\admtolb\.azure-devops\python-sdk\cache\options.json
azext_devops.devops_sdk._file_cache: Loading cache file: C:\Users\admtolb\.azure-devops\python-sdk\cache\resources.json
azext_devops.devops_sdk._file_cache: attempting to read file C:\Users\admtolb\.azure-devops\python-sdk\cache\options.json as utf-8-sig
azext_devops.devops_sdk.client: File cache hit for options on: https://xxx/labcollection
azext_devops.devops_sdk._file_cache: attempting to read file C:\Users\admtolb\.azure-devops\python-sdk\cache\resources.json as utf-8-sig
azext_devops.devops_sdk.client: Route template: _apis/{area}/{resource}
azext_devops.devops_sdk.connection: File cache miss for resources on: https://xxx/labcollection
azext_devops.devops_sdk.client: Api version '5.0-preview.1'
azext_devops.devops_sdk.client: Route template: _apis/{resource}/{areaId}
azext_devops.devops_sdk.client: POST https://agile.xxxx.xx/labcollection/_apis/CustomerIntelligence/Events
azext_devops.devops_sdk.client: Api version '5.0-preview.1'
azext_devops.devops_sdk.client: Request content: [{'area': 'AzureDevopsCli', 'feature': 'devops', 'properties': {'Command': 'security group list', 'Args': 'scope', 'ShellType': 'cmd', 'IsInteractive': 'True', 'OutputType': 'json', 'OrgPresentInCommand': False, 'ProjectPresentInCommand': False, 'RepoPresentInCommand': False, 'OrgPickedFromGit': False, 'ProjectPickedFromGit': False, 'RepoPickedFromGit': False, 'OrgPickedFromConfig': True, 'ProjectPickedFromConfig': True}}]
azext_devops.devops_sdk.client: GET https://agile.xxx.xx/labcollection/_apis/ResourceAreas
msrest.universal_http: Configuring redirects: allow=True, max=30
azext_devops.devops_sdk.client: Request content: None
msrest.universal_http: Configuring request: timeout=100, verify=True, cert=None
msrest.universal_http: Configuring redirects: allow=True, max=30
msrest.universal_http: Configuring proxies: ''
msrest.universal_http: Configuring request: timeout=100, verify=True, cert=None
msrest.universal_http: Evaluate proxies against ENV settings: True
msrest.universal_http: Configuring proxies: ''
urllib3.connectionpool: Starting new HTTPS connection (1): xxxl:443
msrest.universal_http: Evaluate proxies against ENV settings: True
urllib3.connectionpool: Starting new HTTPS connection (1):xxx:443
urllib3.connectionpool: https://xx3 "POST /labcollection/_apis/CustomerIntelligence/Events HTTP/1.1" 204 0
urllib3.connectionpool: https://xxx3 "GET /labcollection/_apis/ResourceAreas HTTP/1.1" 200 143
azext_devops.devops_sdk.client: Response content: b'{"count":0,"value":[]}'
msrest.universal_http.requests: Configuring retry: max_retries=3, backoff_factor=0.8, max_backoff=90
msrest.universal_http.requests: Configuring retry: max_retries=3, backoff_factor=0.8, max_backoff=90
azext_devops.devops_sdk.client: Route template: _apis/{resource}/{*projectId}
azext_devops.devops_sdk.client: Api version '5.0'
azext_devops.devops_sdk.client: GET https://xxxxbcollection/_apis/projects/AgileProcess_Lab
azext_devops.devops_sdk.client: Request content: None
msrest.universal_http: Configuring redirects: allow=True, max=30
msrest.universal_http: Configuring request: timeout=100, verify=True, cert=None
msrest.universal_http: Configuring proxies: ''
msrest.universal_http: Evaluate proxies against ENV settings: True
urllib3.connectionpool: Starting new HTTPS connection (1): agile.xxxx:443
urllib3.connectionpool: https://agile.xxxx:443 "GET /labcollection/_apis/projects/AgileProcess_Lab HTTP/1.1" 200 510
azext_devops.devops_sdk.client: Response content: b'{"id":"010b645d-fe70-4199-985c-94fea92bbd83","name":"AgileProcess_Lab","description":"Labbprojekt f\xc3\xb6r Agila processmallen","url":"https://agile.xxxx/LabCollection/_apis/projects/010b645d-fe70-4199-985c-94fea92bbd83","state":"wellFormed","revision":78,"_links":{"self":{"href":"https://agile.xxxx/LabCollection/_apis/projects/010b645d-fe70-4199-985c-94fea92bbd83"},"collection":{"href":"https://agile.xxxx/_apis/projectCollections/c8fde1c4-124b-46b6-a04f-66c34f89e017"},"web":{"href":"https://agile.xxxx/LabCollection/AgileProcess_Lab"}},"visibility":"private","defaultTeam":{"id":"eaa2a2dd-7a26-42b1-b5fa-b1eea00c70ff","name":"AgileProcess_Lab Team","url":"https://agile.xxxx/LabCollection/_apis/projects/010b645d-fe70-4199-985c-94fea92bbd83/teams/eaa2a2dd-7a26-42b1-b5fa-b1eea00c70ff"},"lastUpdateTime":"2021-04-30T07:11:15.3Z"}'
cli.azext_devops.dev.common.exception_handler: handling value error
cli.azure.cli.core.util: azure.cli.core.util.handle_exception is called with an exception:
cli.azure.cli.core.util: Traceback (most recent call last):
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 691, in _run_job
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 328, in __call__
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "C:\Users\admtolb\.azure\cliextensions\azure-devops\azext_devops\dev\team\security_group.py", line 47, in list_groups
    scope_descriptor = get_descriptor_from_storage_key(project_id, client)
  File "C:\Users\admtolb\.azure\cliextensions\azure-devops\azext_devops\dev\team\security_group.py", line 227, in get_descriptor_from_storage_key
    descriptor = client.get_descriptor(storage_key)
  File "C:\Users\admtolb\.azure\cliextensions\azure-devops\azext_devops\devops_sdk\v5_0\graph\graph_client.py", line 22, in get_descriptor
    response = self._send(http_method='GET',
  File "C:\Users\admtolb\.azure\cliextensions\azure-devops\azext_devops\devops_sdk\client.py", line 60, in _send
    request = self._create_request_message(http_method=http_method,
  File "C:\Users\admtolb\.azure\cliextensions\azure-devops\azext_devops\devops_sdk\client.py", line 107, in _create_request_message
    raise ValueError('API resource location ' + location_id + ' is not registered on '
ValueError: API resource location 048aee0a-7072-4cde-ab73-7af77b1e0b4e is not registered on https://agile.xxxx/labcollection.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 231, in invoke
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 657, in execute
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 712, in _run_job
  File "C:\Users\admtolb\.azure\cliextensions\azure-devops\azext_devops\dev\common\exception_handler.py", line 26, in azure_devops_exception_handler
    raise CLIError(ex)
knack.util.CLIError: API resource location 048aee0a-7072-4cde-ab73-7af77b1e0b4e is not registered on https://agile.xxxx/labcollection.

cli.azure.cli.core.azclierror: API resource location 048aee0a-7072-4cde-ab73-7af77b1e0b4e is not registered on https://agile.xxxx/labcollection.
az_command_data_logger: API resource location 048aee0a-7072-4cde-ab73-7af77b1e0b4e is not registered on https://agile.xxxx/labcollection.
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x03600100>]
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 1.167 seconds (init: 0.183, invoke: 0.984)
telemetry.save: Save telemetry record of length 3030 in cache
telemetry.check: Negative: The 
Nighteyez07 commented 2 years ago

This issue still exists 6 months later with Azure DevOps Server Update 1.1 with no resolution. Any attempted operation against the security scope returns message of API resource location 048aee0a-7072-4cde-ab73-7af77b1e0b4e is not registered on {URL}