Azure / azure-cli

Azure Command-Line Interface
MIT License
4.02k stars 3k forks source link

az ad sp reset-credentials --name parameter not resolving as expected #1600

Closed JargoonPard closed 7 years ago

JargoonPard commented 7 years ago

I tried to use the az ad sp reset-credentials --name command to reset the credentials on an existing service principal.

I first ran az ad sp list to find the service principal details that I was after, it returned the following for the service principal I was interested in:

    "appId": "appid-redacted",
    "displayName": "AzureContainerService",
    "objectId": "objectid-redacted",
    "objectType": "ServicePrincipal",
    "servicePrincipalNames": [
      "appid-redacted"
    ]
  }

I then ran az ad sp reset-credentials --name "appid-redacted" because that was the only value shown in the collection of servicePrincipalNames. This resulted in the following error: can't find an application matching 'appid-redacted'

I also tried running the command again using the value AzureContainerService resulting in the same error.

Note I have replaced the actual guids with appid-redacted.

paulmey commented 7 years ago

I have the same issue. Looks like the code tries to look up by identifierUris. Why not just filter by appId like in the rest of the az ad sp commands? ... /applications?api-version=1.6&$filter=appId+eq+'d1d54911-161d-4296-8ffe-b6912fee5a10' seems to work fine

yugangw-msft commented 7 years ago

i should fix it soon along with #1596. The background is the reset-credentials pairs with create-for-rbac , and both have the assumption that the name is supposed to be app-id-uri, but this concept appears not well accepted, so time to adjust it.