Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azd init(easy-init) project name resolution handling for Environment variables with a . #3183

Open
bmallen1 opened this issue Jan 8, 2024 · 11 comments · May be fixed by #4403
Open

azd init(easy-init) project name resolution handling for Environment variables with a . #3183

bmallen1 opened this issue Jan 8, 2024 · 11 comments · May be fixed by #4403
Assignees
Milestone

Comments

@bmallen1
Copy link

bmallen1 commented Jan 8, 2024

Output from azd version
azd version 1.5.1 (commit 3856d1e)

Describe the bug
Issuing debug command with a log file parameter to capture terminal output to file. The log file shows incomplete output. The error captured at the end of the log is
ERROR: deployment failed: failing invoking action 'provision', error deploying infrastructure: resolving bicep parameters file: substituting environment variables inside parameter file: missing closing brace

To Reproduce
azd provision --debug > "log.txt"

Expected behavior
The issued command should capture all terminal output to the specified file.

Environment
Information on your environment:
* IDE and version : Windows 2010, Visual Studio 2022

Additional context
This primary issue is the non-captured log output. I'm trying to use this command to capture details about the error I'm receiving, noted below, "missing closing brace", which is the secondary issue I'm facing. I've linted all of my bicep and parameter.json files, and double checked parameters for a missing brace to no avail.

Full log.txt output:

Provisioning Azure resources (azd provision)
Provisioning Azure resources can take some time.

|       | 
|=      | 
|       | 
|=      | 
Subscription: Dev Subscription (***************************************)
Location: West US 3

|       | 
|=      | 

ERROR: deployment failed: failing invoking action 'provision', error deploying infrastructure: resolving bicep parameters file: substituting environment variables inside parameter file: missing closing brace
@rajeshkamal5050
Copy link
Contributor

@bmallen1 thanks for reporting.

Could you share the sample app/repo which you are using to provision?

@hemarina @v-xuto

@bmallen1
Copy link
Author

bmallen1 commented Jan 8, 2024

Greetings--I used azd init on an existing dotnet 7 Dapr-enabled microservices backend API application. I then further enhanced the generated bicep templates with the additional infrastructure the application required including managed identity, cosmosDb, using an existing vnet, keyvault and ACR. I can provide additional details as necessary, however I do not have a sample repo at this time.

This scenario is likely out of scope for any meaningful debugging attempts, but any feedback to aid in my quest is appreciated. The error I received is also perplexing and is what prompted my attempt to capture the full log.

I've linted the main.parameters.json file that azd init generated--even after enhancing the file with additional attributes. When I attempt to run azd up or azd provision and subsequently azd env get-values I can see additional environment variables added based on attributes in the parameter file for most of the attributes in the parameters attribute.

@rajeshkamal5050
Copy link
Contributor

@bmallen1 seems similar substituting environment variables inside parameter file: missing closing brace error can you check Azure/bicep#10612 and its cause?

@hemarina
Copy link
Contributor

hemarina commented Jan 10, 2024

@bmallen1 seems similar substituting environment variables inside parameter file: missing closing brace error can you check Azure/bicep#10612 and its cause?

I was not able to reproduce this on other templates. The output will stop and return an error message when it encounters error. Dash on environment variable name is very likely the cause of this error. Feel free to let us know if removing dash is not working. We will add a log print on error message to print out failed substitute parameters.

@rudiv
Copy link

rudiv commented Mar 7, 2024

On a project also initialised using azd init (in a folder name of Company.Project) I've encountered this.

Environment variables with a . are also not supported, and this is created in the .azure/{env}/.env file as SERVICE_COMPANY.PROJECT_RESOURCE_EXISTS. This needs the . removing in the .env file as well as main.parameters.json and then everything works OK.

It seems like the automatic project name resolution needs updating to exclude any special characters.

@rajeshkamal5050 rajeshkamal5050 changed the title Debug logs are incomplete, substituting environment variables: missing closing brace azd init(easy-init) project name resolution handling for Environment variables with a . Mar 7, 2024
@rajeshkamal5050
Copy link
Contributor

@weikanglim assuming it is a small fix, adding it to the next milestone. Please feel free to adjust.

@rajeshkamal5050 rajeshkamal5050 modified the milestones: Backlog, March 2024 Mar 7, 2024
@kdcllc
Copy link

kdcllc commented Mar 11, 2024

On a project also initialised using azd init (in a folder name of Company.Project) I've encountered this.

Environment variables with a . are also not supported, and this is created in the .azure/{env}/.env file as SERVICE_COMPANY.PROJECT_RESOURCE_EXISTS. This needs the . removing in the .env file as well as main.parameters.json and then everything works OK.

It seems like the automatic project name resolution needs updating to exclude any special characters.

@rudiv thank you for pointing out the issue with the . here is the parameter file that cause the issue for me https://github.com/cyclotron-azure/url-shortener/blob/fec9817b0bb7da4c95718f54d55102ba43914027/infra/main.parameters.json#L12

kdcllc added a commit to cyclotron-azure/url-shortener that referenced this issue Mar 11, 2024
kdcllc added a commit to cyclotron-azure/url-shortener that referenced this issue Mar 11, 2024
* fix issue with azd init template Azure/azure-dev#3183

* add static webapp bicep

* refactoring code

* adding rest calls to the product

* upgrading auth for blazor app

* deploying the app manually
@rajeshkamal5050 rajeshkamal5050 modified the milestones: March 2024, On Deck Mar 20, 2024
@godefroi
Copy link

I can confirm that the workaround described by @kdcllc works.

@brandonh-msft
Copy link
Member

Any update on this? ran into it with azd 1.10.1 (commit 31409a33266fb4a5fdbb644bc83988e725d6c7c9) today and spent far too much time trying to figure out where I was going wrong

@weikanglim
Copy link
Contributor

weikanglim commented Oct 3, 2024

Hi 👋 @brandonh-msft , I'm proposing a fix with #4403 to provide a naming translation:

App.Project (directory name) -> app-project (service name)

This automatically prevents the issue from occurring due to . characters not being included. I hope this is acceptable from a .NET developer lens with PascalCase and dotted-namespaces.

The motivation behind this proposal is that we have azd commands like azd deploy. In my mind, azd deploy app-project is perhaps slightly easier to use than azd deploy App.Project. We're also hoping to reserve the . characters for future uses in azd. Nothing is set in stone -- this is currently just a proposed plan and only affects the default naming translation in azd init, so please let us know if you feel strongly otherwise.

@brandonh-msft
Copy link
Member

brandonh-msft commented Oct 3, 2024

my only concern is the "invisibility" of this requirement (which harkens back to my aversion to CLIs in the first place, but I digress - that ship has clearly sailed).
In other words, .NET devs are going to find out that they can't use the actual name of their project (e.g. App.Project) .... how?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants