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

[New azd-template] todo-java-postgresql-terraform #76

Closed
fangjian0423 opened this issue Dec 5, 2022 · 20 comments
Closed

[New azd-template] todo-java-postgresql-terraform #76

fangjian0423 opened this issue Dec 5, 2022 · 20 comments

Comments

@fangjian0423
Copy link
Contributor

fangjian0423 commented Dec 5, 2022

New azd-template Submission

Fill in the sections below to populate a new Gallery carry for your template. An example of a valid template object is given at the end for reference. All fields are mandatory unless explicitly identified as optional

1. Title

Short template name that will be used in card title on gallery

ToDo Application - Java PostgreSQL AppService Terraform

2. Description

1-2 sentence description of the architecture or solution that is defined by the template

A complete ToDo application that includes everything you need to build, deploy, and monitor an Azure solution. This application uses the Azure Developer CLI (azd) to get you up and running on Azure quickly, React.js for the Web application, Java for the API, Azure Database for PostgreSQL - Flexible Server for storage, and Azure Monitor for monitoring and logging.

3. Author Profile

A link to the contributor's GitHub profile (ideal) or other profile link (for identification.

https://github.com/fangjian0423

4. Author Name

The name to be shown in the grey button on the card - will be linked profile website above.

Jimmy Fang

5. Template Repo

The GitHub repo containing the template being contributed - must be a valid, complete template

https://github.com/fangjian0423/todo-java-postgresql-terraform

6. Link to PR where you made your repo azd compatible

To allow us to provide feedback on your template, please include a link to the PR where you added azd compatibility

It's a new project. Could you pls create a new issue if you want to provide feedback.

7. Standard Tags

One or more tags representing the template. Look at the currently available tags on the Gallery page and pick at least 1 tag for programming language used, and 1 tag for Azure services integrated

java, appservice, postgresql, monitor, passwordless, application insights, terraform

7. Additional Tags (optional)

Don't see a relevant standard tag for your template? Request these tags be added, and then used for your template. These could be new languages, services, or application domains.

spring

8. Architecture Diagram or Application Screenshot

Used as default image for template card - must be representative of solution being enabled. Submit image by adding it as file upload to this issue

image


Example Of Valid Template

{
  title: 'ToDo Application - Java PostgreSQL AppService',
  description:
    'Complete React.js ToDo application, Java for the API, Azure Database for PostgreSQL - Flexible Server for storage, and Azure Monitor for monitoring and logging.',
    preview: `todo-java-postgresql.png`,
  website: 'https://github.com/fangjian0423',
  author: 'Jimmy Fang',
  source: 'https://github.com/fangjian0423/todo-java-postgresql-terraform',
  tags: ['java', 'appservice', 'postgresql', 'monitor', 'passwordless', 'application insights', 'terraform']
}

Next Steps

Once submitted the issue will be reviewed - we plan to do reviews on a rolling basis at regular intervals. The process will involve checking that template information is complete, and the template is valid.

  • If we have questions or enhancements, we will add comments in issue thread (issue stays open)
  • If the contribution is approved, we'll update the gallery directly (issue will then be closed)
@weikanglim
Copy link
Contributor

@fangjian0423 Sorry for the delay, I'm starting to take a look at this template now.

@weikanglim
Copy link
Contributor

weikanglim commented Jan 26, 2023

@fangjian0423 Getting an error with provisioning PostgreSQL that doesn't resolve after retrying. Do you know what might be happening?

 Error: creating Flexible Server (Subscription: "faa080af-****-40ad-9cce-e1a450ca5b57"
│ Resource Group Name: "rg-weilim-java-postgres-tf"
│ Server Name: "psqlf-yjjinjyynzkzm"): polling after Create: Code="InternalServerError" Message="An unexpected error occured while processing the request. Tracking ID: 'dfbf691a-5a54-4174-9a0d-aee7b7bdfd09'"
│
│   with module.postgresql.azurerm_postgresql_flexible_server.psqlServer,
│   on modules\postgresql\postgresql.tf line 35, in resource "azurerm_postgresql_flexible_server" "psqlServer":
│   35: resource "azurerm_postgresql_flexible_server" "psqlServer" {
│
╵

ERROR: deployment failed: error deploying infrastructure: template Deploy failed:  , err:failed running terraform apply:  (exit status 1)

@fangjian0423
Copy link
Contributor Author

fangjian0423 commented Jan 27, 2023

Hi @weikanglim , it seems this is an issue in postgresql, I find Azure/azure-dev#933 talking about it.

I run successfully after retrying 2 times (location is eastus2), and didn't get the error again in the subsequent trying. Could you pls try it again?

BTW, I meet another error(For the validation, I delete log analytics in terraform infra files):

module.loganalytics.azurerm_log_analytics_workspace.workspace: Creating...
╷
│ Error: performing CreateOrUpdate: workspaces.WorkspacesClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=<nil> Code="InvalidPolicyParameters" Message="A function or parameter in policy assignment 'acat-custom-policy-set-assignment' associated with the policy definition 'log-analytics-workspace-retention' could not be validated. Please either fix the policy or remove the policy assignment to unblock. If using template functions, try following the tips in: https://aka.ms/policy-avoiding-template-failures. The inner error is 'The template language function 'length' expects its parameter to be an array, object, or a string. The provided value is of type 'Integer'. Please see https://aka.ms/arm-template-expressions/#length for usage details.'."
│
│   with module.loganalytics.azurerm_log_analytics_workspace.workspace,
│   on modules/loganalytics/loganalytics.tf line 23, in resource "azurerm_log_analytics_workspace" "workspace":
│   23: resource "azurerm_log_analytics_workspace" "workspace" {
│

Do you get this error?

I get the same error when run azd up with todo-python-mongo-terraform template.

So I created an issue for this error: hashicorp/terraform-provider-azurerm#20197

@fangjian0423
Copy link
Contributor Author

@weikanglim Ignore the log analytics error, it's my subscription issue.

Please try more times to see postgresql could be created, thanks.

@weikanglim
Copy link
Contributor

weikanglim commented Jan 30, 2023

@fangjian0423 Thanks for the pointer. Choosing a different location than eastus2 did make it progress further.

I ended up hitting a different issue. This time it relates to local-exec, where it fails to execute on Windows, because the default interpreter isn't sh/bash. terraform doesn't provide native ability to conditionally specify scripts, but I did find this resource which hints at how we could solve this in a different manner. I would recommend creating a similar powershell script for Windows to bootstrap the AD roles. Alternatively, you could require in a shell interpreter to be present, but the user should not need to modify the terraform script to make it work. (Could be an env variable if you preferred). Note that in the up-and-coming azd feature for hooks, postprovision scripts can be specified per OS.

Related to that, it looks like the script would require psql to be present on the user's machine? Can you add this as a pre-req?

@fangjian0423
Copy link
Contributor Author

fangjian0423 commented Jan 31, 2023

@weikanglim I have updated the template.

  1. Modify local-exec to support Windows. Thanks for your provided terraform resource 😄
  2. Add PostgreSQL as a prerequisite in README

Could you please pull the newest code to try again?

Note that in the up-and-coming azd feature for hooks, postprovision scripts can be specified per OS.

Awesome, looking forward to see it in the coming version.

@rajeshkamal5050
Copy link
Contributor

rajeshkamal5050 commented Feb 6, 2023

@v-xuto can you do a dry-run on this template and update here for any issues/feedback?

@v-xuto
Copy link
Member

v-xuto commented Feb 10, 2023

@fangjian0423 We have tested the template todo-java-postgresql-terraform, we encountered the following issues:

@v-xuto
Copy link
Member

v-xuto commented Feb 15, 2023

@fangjian0423
About the issue #933 Can't deploy environment that includes a PostGreSQL flexible server in eastus2, we can't test this template in location eastus2, because our subscription Azure Data Developer Playground is not allowed to provision in Eastus2 for PostGreSQL flexible server.

Now, when executing azd pipeline config fails, we have filed a new issue fangjian0423/todo-java-postgresql-terraform#2. Please review.

@v-xuto
Copy link
Member

v-xuto commented Feb 22, 2023

@jongio We have finished testing this template, and there is only one issue(fangjian0423/todo-java-postgresql-terraform#3) now.
After discussing with the author, this issue should be a service issue (Azure Database for PostgreSQL - Flexible Server is not stable for the AAD admin setting in terraform), it's not a template issue.
Regarding this issue3, how should we deal with it?

@rajeshkamal5050
Copy link
Contributor

rajeshkamal5050 commented Feb 28, 2023

After discussing with the author, this issue should be a service issue (Azure Database for PostgreSQL - Flexible Server is not stable for the AAD admin setting in terraform), it's not a template issue.

@jongio @fangjian0423 call out in the template readme as a known issue on the service?

@jongio @weikanglim @wbreza please review.

@fangjian0423
Copy link
Contributor Author

The postgresql flexible server AAD admin setting in terraform is not stable. The error code is "InternalServerError", very confuse.

Retry can resolve it.

I will describe the case on readme Troubleshooting section.

@jongio
Copy link
Member

jongio commented Feb 28, 2023

@weikanglim - Where are we at with adding this to azure-dev repo?

@fangjian0423
Copy link
Contributor Author

hi @rajeshkamal5050 @jongio @weikanglim , any update about this template?

@wbreza
Copy link
Contributor

wbreza commented Mar 13, 2023

Are we considering adding this into azure/azure-dev repo to generate along side our official repos? If so we should open a PR with these changes.

@wbreza
Copy link
Contributor

wbreza commented Mar 13, 2023

I also ran into the AAD issue upon deployment. I would recommend we turn off AAD integration on the template if possible.

@fangjian0423
Copy link
Contributor Author

I would recommend we turn off AAD integration on the template if possible.

Thanks for your suggestion. I won't turn off it because this template want to promote Azure Active Directory Authentication with PostgreSQL Flexible Server.

@rajeshkamal5050
Copy link
Contributor

@savannahostrowski
Copy link
Contributor

Same here - all good to be from a personal GH.

@rajeshkamal5050
Copy link
Contributor

Closing this in favor of - Azure/azure-dev#1792

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

No branches or pull requests