microsoft / PubSec-Info-Assistant

Information Assistant, built with Azure OpenAI Service, Industry Accelerator
MIT License
344 stars 777 forks source link

Deployment Failure With Release V1.2 With Fresh Clone Code #886

Open ravikhunt opened 1 month ago

ravikhunt commented 1 month ago

Summary: Upon deploying the fresh latest clone of release V1.2, the deployment fails with errors indicating that the Storage Account and Key Vault are not found. This is occurring despite it being a fresh deployment with no prior state file, where Terraform should ideally create a new resource group along with all other associated services.

Steps to Reproduce:

  1. Clone the project repository.
  2. Checkout to the latest release V1.2.
  3. Initiate the deployment process.
  4. The deployment ends up with errors related to missing resources (e.g., Storage Account, Key Vault not found).

Expected Behavior: For a fresh deployment, without an existing state file, Terraform should create a new resource group along with all necessary services such as Storage Account and Key Vault, without referencing or expecting existing resources.

Actual Behavior: The deployment fails with errors suggesting that the required resources (Storage Account, Key Vault) are not found, preventing a successful deployment.

Error Message: (Screenshot attached ) Image

bjakems commented 1 month ago

Hi Ravi,

Please try the deployment again after deleting all of these terraform artifacts. I've seen this issue before, but never have experienced it after all of these TF artifacts from a previous deployment are removed. Image

ravikhunt commented 1 month ago

Hello Actually I have tried deployment many times, this is the issue because of fresh new deployment with latest version. Because very first time when we cloned there is no TF states files or nothings Even, screenshot may be of third forth time very first time there was no file and still same error, if with every time deployed if any TF related file will was removed and tried. But it wad giving same error.

Based on the error try to looking at Keyvault resources and Sotrage Resources, in terraform files also looks same that try to look for existing resources, bt as it’s fresh new deployment it will never find that resource

OR you can also try with very fresh resources without any single TF or TF states related files.

Please let me know your thoughts

bjakems commented 1 month ago

Please try to create a new Codespace and attempt the deployment from there. Also, examine the TF plan to see if Terraform is attempting to reuse or create the resources. Since it's a net new environment, the Storage Account and Key Vault should be marked as create in the TF plan.

ravikhunt commented 1 month ago

HI bjakems

I cloned New codespace and tried to attempt the deployment from there It is hitting with the same error, and here is some of the content from the TF plan files

Image

What I feel maybe is from this 5 on main.tf file there is no depends_on = [ module.kvModule ] for 3 modules which give an error, functions, and storage

When I have taken a look at the old version V1.1.1 KV module is on depends_on = [ module.kvModule ] for the

// Function App module "functions" { source = "./core/host/functions" depends_on = [ module.kvModule ] }

The above is my understanding and findings, could you please let me know your thoughts on this

attila-kocsis commented 1 month ago

Hi Ravi,

Please try the deployment again after deleting all of these terraform artifacts. I've seen this issue before, but never have experienced it after all of these TF artifacts from a previous deployment are removed. Image

This solved the issue for me, thanks @bjakems

bjakems commented 1 month ago

@ravikhunt are you using the latest code in the main branch with no changes? Version 1.2 introduces managed identity instead of using secrets in Key Vault where possible. Additionally, Terraform will automatically build its own dependency chain and depends_on is not required if the module accesses the other resources data in its arguments. What values have you configured in your local.env file (please do NOT include any Subscription IDs, keys, secrets, etc)?