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

Migrating App Insights to Workspace-based Resource forces replacement so we lose all data #20968

Closed
1 task done
LordA98 opened this issue Mar 15, 2023 · 4 comments
Closed
1 task done

Comments

@LordA98
Copy link

LordA98 commented Mar 15, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Hi,

The classic App Insights resource is being deprecated in February 2024. The recommendation is to move to a workspace-based app insights instead.

Doing this via Terraform forces the resource to be destroyed and recreated, which means we lose all of the data (logs) we already have. This is fine for non-prod environments but not prod.

It works fine via the portal, but importing the state is proving difficult.

Any suggestions? Has anyone else encountered the same issue?

Thanks,
Alex

Terraform Version

1.4.0

AzureRM Provider Version

3.47.0

Affected Resource(s)/Data Source(s)

azurerm_application_insights

Terraform Configuration Files

resource "azurerm_application_insights" "apps" {
  name                = "XXX"
  resource_group_name = "XXX"
  location            = "XXX"
  application_type    = "Node.JS"
  tags                = {}
  workspace_id        = "id of existing workspace"
}

# I have omitted our actual variable names etc as I assume you'll be able to fill these in.

Debug Output/Panic Output

There is no error output, it just behaves differently than expected (the Azure portal does not force a replacement or reset the data).

As this is small, I have pasted it here, rather than in a Gist:

+ workspace_id = "RESOURCE/URL/HERE" # forces replacement

Expected Behaviour

Connect to workspace without replacing the entire resource (like the Azure portal does).

Actual Behaviour

Recreates resource so we lose our logs / data from the app insights resource.

Steps to Reproduce

Try to connect an existing app insights resource to an existing workspace.

Important Factoids

No response

References

No response

@myc2h6o
Copy link
Contributor

myc2h6o commented Mar 17, 2023

Hi @LordA98 thanks for raising the issue! The ForceNew was added by #15621 in order to resolve a service side mismatch as mentioned in #15576. I'll be looking into this further to see if we could have a better solution so that the update by Terraform.
As a temporary mitigation, you could try updating the workspace id on Azure Portal/CLI and do a terraform refresh to refresh the state file.

@LordA98
Copy link
Author

LordA98 commented Mar 17, 2023

Thank you! I'll take a look at the refresh command

@catriona-m
Copy link
Member

Thanks @LordA98, it looks like this may be resolved by #21029 so I am going to close this now. If there is still an issue however, feel free to re-open this. Thanks!

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants