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
617 stars 240 forks source link

[Bug] "--area is not present in current organization" error during "az devops invoke --area Security" execution #1011

Open DariuszPorowski opened 4 years ago

DariuszPorowski commented 4 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Azure Cli Version: 2.70 Azure-Devops extension version: 0.18.0

Steps to reproduce the behavior: run: az devops invoke --organization "https://dev.azure.com/myorg" --area "Security" --resource "SecurityNamespaces" and see error: --area is not present in current organization

Expected behavior Results the same as using GET rest call: https://dev.azure.com/myorg/_apis/securitynamespaces?api-version=5.1

Debug logs cli.azure.cli.core.util : --area is not present in current organization --area is not present in current organization

Additional context Add any other context about the problem here.

jdholbrook81 commented 4 years ago

Also getting this trying to register a web hook:

az devops invoke --organization $organization --http-method POST --area hooks --resource subscriptions --in-file $webhookJsonPath

Result: --area is not present in current organization

tasb commented 3 years ago

I'm having the same issue too. Any update on this?

ashishonce commented 3 years ago

I see that command az devops invoke --organization "https://dev.azure.com/" --area "Security" --resource "SecurityNamespaces"

has two step process

first step : is invoking below API https://dev.azure.com/yourorg/_apis/ResourceAreas to get list of all resource areas, and only when provided area is found in the list

it proceeds with particular url for resource within that area. That will be like https://dev.azure.com/yourorg/_apis/securitynamespaces?api-version=5.1

I see that for the first request area name "Security" is not present and thus the logic fails citing that "Security" is not present in available areas.

I am not sure why this API https://dev.azure.com/yourorg/_apis/ResourceAreas will not return full list of Areas which is provided by az devops invoke --organization "https://dev.azure.com/yourorg"

you can verify this my running below command to check that when all areas are scanned separately, we do get "Security" as available area.

az devops invoke --organization "https://dev.azure.com/yourorg" --query "[?contains(area,'Security')]"

@narula0781 can we connect with API team for this bug? I will connect with the API team to know more around this.

rhatfield-bushel commented 2 years ago

So I ran into this issue, and "fixed" it locally, but could use some guidance on how to properly implement the fix in this repo.

So first, I don't code in python very often so I probably shouldn't be writing the fix.

There's two bugs here causing this behavior:

So, all the parts to fix this should be here. With a little guidance on this I could make a PR with a VERY basic fix, but I won't have the time to contribute any tests for this.

With the above fixes in place, I'm able to call this with the correct API resource and area:

az devops invoke \
  --organization "https://dev.azure.com/yourorg" \
  --area "Security" \
  --resource "SecurityNamespaces" \
  --api-version 6.1.1

I got the appropriate endpoint version from the az devops invoke details:

{
    "area": "Security",
    "id": "ce7b9f95-fde9-4be8-a86d-83b366f0b87a",
    "maxVersion": 6.1,
    "minVersion": 1.0,
    "releasedVersion": "6.0",
    "resourceName": "SecurityNamespaces",
    "resourceVersion": 1,
    "routeTemplate": "_apis/{resource}/{securityNamespaceId}"
}
tobylo commented 2 years ago

Any update on this? Also getting the same error when trying to invoke the securityroles area (to update/set permissions on an environment).

stevenoneill commented 2 years ago

Getting this error when trying to use --area Contribution. Any update?

kvakulo commented 2 years ago

Also hit by this error for --scope securityroles 😞

silverscout commented 1 year ago

@rhatfield-bushel this like I am getting this error on --area processes. I did your fix of updating the invoke.py file and it resolved the issue. Hopefully one day this will get merged in.

SaurabhSharma-MSFT commented 1 year ago

@gauravsaralMs Can you please look into this.

dimangulov commented 1 year ago

Also hit by this error for --scope securityroles

micwiec commented 9 months ago

Issue still exists

lukecalderon commented 8 months ago

Currently having the same issue with the following:

Command

az devops invoke --area "securityRoles" --resource "roleassignments" `
  --route-parameters scopeId="distributedtask.agentpoolrole" resource="$adoAgentPoolId" `
  --detect true `
  --http-method PUT `
  --api-version "7.2-preview" `
  --in-file agentPoolBody.json `
  -o json

Response

ERROR: --area is not present in current organization
Albert0sans commented 1 month ago

any updates?