title: Add Graph API via az ad app permission fails
body: <p>I'm attempting to add the Graph API via CLI 2.x. Here is the PowerShell script I'm running:</p>
  <pre class="lang-bsh prettyprint-override"><code>    #
      # (1) Register the app, replyUrl, enable implicitflow
      #
      Write-Host &quot; -  Create Application &quot; + $appName
      az ad app create --display-name &quot;$appName&quot; --reply-urls &quot;$replyUrl&quot; --oauth2-allow-implicit-flow true
  
      #
      # (2) get the app id into a variable
      #
      $appId=$(az ad app list --display-name $appName --query [].appId -o tsv)
  
      #
      # (3) API Permissions, add Graph API/Permission (delegated)     
      #
      Write-Host &quot; -  Add Graph API/Permission (delegated)&quot;
      az ad app permission add --id $appid --api 00000002-0000-0000-c000-000000000000 --api-permissions 311a71cc-e848-46a1-bdf8-97ff7156d8e6=Scope
      
      #
      # (4) Grant permissions based on the error/warning from the previous step     
      #
      Write-Host &quot; -  Grant permissions&quot;
      az ad app permission grant --id $appid --api 00000002-0000-0000-c000-000000000000
  </code></pre>
  <p>I pulled the <code>--api-permissions id</code> from this <a href="https://docs.microsoft.com/en-us/archive/blogs/aaddevsup/guid-table-for-windows-azure-active-directory-permissions" rel="nofollow noreferrer">link</a>.
  The script line <code>az ad app permission add</code> throws this error (or warning):</p>
  <blockquote>
  <p>az : Invoking <code>az ad app permission grant --id xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --api 00000002-0000-0000-c000-000000000000</code> is needed to make the change effective
  At C:\temp\CP\CreateAppRegistration.ps1:42 char:5
  az ad app permission add --id $appid --api 00000002-0000-0000-c00 ...
  CategoryInfo          : NotSpecified: (Invoking &quot;az ad...hange effective:String) [], RemoteException
  FullyQualifiedErrorId : NativeCommandError</p>
  </blockquote>
  <p>I then attempt to call the script in the error <code>az ad app permission grant</code> and get the following error:</p>
  <blockquote>
  <p>az : Operation failed with status: 'Not Found'. Details: 404 Client Error: Not Found for url:
  <a href="https://graph.windows.net/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/oauth2PermissionGrants?$filter=clientId%20eq%20%27e62c4745-cccc-cccc-cccc-71e5599261fc%27&amp;api-version=1.6" rel="nofollow noreferrer">https://graph.windows.net/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/oauth2PermissionGrants?$filter=clientId%20eq%20%27e62c4745-cccc-cccc-cccc-71e5599261fc%27&amp;api-version=1.6</a>
  At C:\temp\CP\CreateAppRegistration.ps1:45 char:5
  az ad app permission grant --id $appid --api 00000002-0000-0000-c ...
  CategoryInfo          : NotSpecified: (Operation faile...api-version=1.6:String) [], RemoteException
  FullyQualifiedErrorId : NativeCommandError</p>
  </blockquote>
  <p>Can someone help me understand if I need to execute the script (#4 above) per the error generated from #3 above??<br />
  Or why is #3 above returning an error/warning?</p>
  <p>I say warning because the Graph API does seem to get added but I'm not sure it's in the proper state per the error message.</p>
  <blockquote>
  <p><code>az ad app permission grant --id xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --api 00000002-0000-0000-c000-000000000000</code> is needed to make the change effective</p>
  </blockquote>