Skip to content

Fix prompting for missing infrastructure values - #1202

Merged
ellismg merged 3 commits into
Azure:mainfrom
ellismg:ellismg/parameters-file-in-memory
Nov 24, 2022
Merged

Fix prompting for missing infrastructure values#1202
ellismg merged 3 commits into
Azure:mainfrom
ellismg:ellismg/parameters-file-in-memory

Conversation

@ellismg

@ellismg ellismg commented Nov 22, 2022

Copy link
Copy Markdown
Member

Our logic to prompt the user for missing infrastructure values was
broken because we did not tell the spinner we wanted to interact with
the user, so the spinner would prevent the prompt UI from being shown.

The logic we had for trying to save these values was totally broken
and in practice would end up generating files that the ARM control
plane would reject.

We now save these values in the newly added Config object on the
environment, using infra.prameters.<parameterName> as the key name.

As part of this work, we no longer materialize the full
.parameters.json file to disk, we no longer need to do this now that
we are using the SDK directly.

Fixes #1176
Fixes #1191

@ghost ghost assigned ellismg Nov 22, 2022
@ellismg
ellismg force-pushed the ellismg/parameters-file-in-memory branch 3 times, most recently from 41d2fbf to ff4562b Compare November 23, 2022 01:21
@ellismg
ellismg force-pushed the ellismg/parameters-file-in-memory branch from ff4562b to 7a506db Compare November 23, 2022 01:36
Comment thread cli/azd/pkg/infra/provisioning/bicep/bicep_provider.go Outdated
Comment thread cli/azd/pkg/infra/provisioning/bicep/bicep_provider.go Outdated
Comment thread cli/azd/pkg/tools/azcli/deployments.go
Our logic to prompt the user for missing infrastructure values was
broken because we did not tell the spinner we wanted to interact with
the user, so the spinner would prevent the prompt UI from being shown.

The logic we had for trying to save these values was totally broken
and in practice would end up generating files that the ARM control
plane would reject.

We now save these values in the newly added `Config` object on the
environment, using `infra.prameters.<parameterName>` as the key name.

As part of this work, we no longer materialize the full
`.parameters.json` file to disk, we no longer need to do this now that
we are using the SDK directly.

Fixes Azure#1176
Fixes Azure#1191
@ellismg
ellismg force-pushed the ellismg/parameters-file-in-memory branch from 7a506db to 694212e Compare November 24, 2022 02:06
@ellismg ellismg changed the title WIP: Do not persist configured settings to disk Do not persist configured settings to disk Nov 24, 2022
@ellismg ellismg changed the title Do not persist configured settings to disk Fix prompting for missing infrastructure values Nov 24, 2022
@ellismg
ellismg marked this pull request as ready for review November 24, 2022 02:21
@azure-sdk

Copy link
Copy Markdown
Collaborator

Azure Dev CLI Install Instructions

Install scripts

MacOS/Linux

May elevate using sudo on some platforms and configurations

bash:

curl -fsSL https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/1202/uninstall-azd.sh | bash;
curl -fsSL https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/1202/install-azd.sh | bash -s -- --base-url https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/1202 --version '' --verbose

pwsh:

Invoke-RestMethod 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/1202/uninstall-azd.ps1' -OutFile uninstall-azd.ps1; ./uninstall-azd.ps1
Invoke-RestMethod 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/1202/install-azd.ps1' -OutFile install-azd.ps1; ./install-azd.ps1 -BaseUrl 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/1202' -Version '' -Verbose

Windows

powershell -c "Set-ExecutionPolicy Bypass Process; irm 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/1202/uninstall-azd.ps1' > uninstall-azd.ps1; ./uninstall-azd.ps1;"
powershell -c "Set-ExecutionPolicy Bypass Process; irm 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/1202/install-azd.ps1' > install-azd.ps1; ./install-azd.ps1 -BaseUrl 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/1202' -Version '' -Verbose;"

Standalone Binary

Container

docker run -it azdevcliextacr.azurecr.io/azure-dev:pr-1202

@ellismg
ellismg merged commit b6c8218 into Azure:main Nov 24, 2022
ellismg added a commit to ellismg/azure-dev that referenced this pull request Nov 29, 2022
In Azure#1202 we added a `config.json` file in the environment, which we
use to persist configured values for required infrastructure
parameters which are not set in `.parameters.json` files.

As part of that logic, we made it so that the constructor of the
environment would validate that a `config.json` file was present in
the environment and if not, fail (similar to the check it already did
for the .env file).

This worked for new environments, since `.Save()` will always write an
empty `config.json` file. But for existing environments, the read of
the config.json would fail, with ErrNotExists, which would be wrapped
up and returned to the caller. The caller would use the ErrNotExists
to mean "the environment doesn't exist" and so it would prompt the
user to see if they wanted to create it.

Rework the constructor such that we return ErrNotExists when the
directory for the environment doesn't exist, instead of using the
existence of the `.env` file to mean anything and add some unit tests
for these cases.
ellismg added a commit that referenced this pull request Nov 29, 2022
In #1202 we added a `config.json` file in the environment, which we
use to persist configured values for required infrastructure
parameters which are not set in `.parameters.json` files.

As part of that logic, we made it so that the constructor of the
environment would validate that a `config.json` file was present in
the environment and if not, fail (similar to the check it already did
for the .env file).

This worked for new environments, since `.Save()` will always write an
empty `config.json` file. But for existing environments, the read of
the config.json would fail, with ErrNotExists, which would be wrapped
up and returned to the caller. The caller would use the ErrNotExists
to mean "the environment doesn't exist" and so it would prompt the
user to see if they wanted to create it.

Rework the constructor such that we return ErrNotExists when the
directory for the environment doesn't exist, instead of using the
existence of the `.env` file to mean anything and add some unit tests
for these cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prompting for parameters during provisioning is not working AZD hanging while waiting for user to input mandatory parameters without default values

3 participants