Azure Terraform Parsing Error on Workspace ID

When using Terraform to deploy a solution to Azure and referencing a Log Analytics Workspace by ID you have copied and pasted the ID from the Azure Portal to prevent spelling mistakes but get a parsing error that tells you that a segment of the Workspace ID didn’t match. That error looks something like this:

 1Error: parsing "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/my-rg-name/providers/microsoft.operationalinsights/workspaces/my-log-analytics-workspace": parsing segment "staticResourceGroups": parsing the Workspace ID: the segment at position 2 didn't match
 2 3│ Expected a Workspace ID that matched:
 4 5│ > /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.OperationalInsights/workspaces/workspaceName
 6 7│ However this value was provided:
 8 9│ > /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/my-rg-name/providers/microsoft.operationalinsights/workspaces/my-log-analytics-workspace
1011│ The parsed Resource ID was missing a value for the segment at position 2
12│ (which should be the literal value "resourceGroups").

The value of the ID is case sensitive- in particular the static segments resourceGroups and Microsoft.OperationalInsights. If you copy from the portal you get an all lower-case string resourcegroups or microsoft.operationalinsights which is rejected by Terraform.

Update the Terraform code, replacing the segments with the expected case structure.