Azure / azure-dev

A developer CLI that reduces the time it takes for you to get started on Azure. The Azure Developer CLI (azd) provides a set of developer-friendly commands that map to key stages in your workflow - code, build, deploy, monitor, repeat.
https://aka.ms/azd
MIT License
408 stars 196 forks source link

[AspireDeployment] Initializing an Aspire project without 'Subscription', 'Location' will send an incorrect Prompt request on RefreshEnvironment #3953

Open anvillan opened 5 months ago

anvillan commented 5 months ago

After running azd init on a brand new Aspire Application, executing RefreshEnvironmentAsync() on it will cause azd vs-sever to send a Prompt request -asking for missing 'Subscription' and 'Location'- though its content is not correct, as it does not adhere to VS IDE Prompt request JSON definition.

From debugging the code, the request sent from azd vs-server has the form of:

{ "type":"select", "options":{ "message":"Select an Azure Subscription to use:", "help":"", "choices":[ {"value":" 1. <Sub_Name> (<Sub_ID>)"}, {"value":" 2. ...} .... ] } }

But VS IDE defines another schema. Look at https://devdiv.visualstudio.com/DevDiv/_git/WebTools?path=/docs/Aspire/AzdHttpPrompting.md&version=GBmain&_a=contents.

{ "id": "myId", "kind": "select", "displayName": "MyLabel", "description": "My help description", "defaultValue": "Value1", "required": true, "choices": [ { "value": "Value1", "description": "Value1 description" }, { "value": "Value2" }, { "value": "Value3" } ]

For starters, there is no type field, but kind.

Repro steps:

  1. Launch VS and create a new Aspire starter Application project.
  2. Create a new environment with azd command for the project.
    • Right-click solution/AppHost project > Open folder in file explorer
    • In the opened folder, right-click any place > open in terminal
    • Runing 'azd init', select 'Use code in the current directory' > Confirm and continue initializing my app, type a new environment name, and press Enter
  3. Right click on the AppHost project -> Publish.
  4. Prompt request is sent, but VS IDE cannot parse it correctly, presenting an empty dialog.

Original Bug: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2057823

rajeshkamal5050 commented 5 months ago

@ellismg @weikanglim can you triage this?

ellismg commented 5 months ago

I'll take a look - I suspect this is in an issue with when we initialize the bicep provider - but it does seem bad that we are sending an incorrect shape in our API request.

Thanks for the detailed repo steps here, @anvillan!