Robert D. Crane, regarding the failure to delete the Azure Monitor Workspace, this is happening because this workspace is being managed by another resource/resource group. This generally happens when one resource is created as part of another resource creation. In the posted error, it seems that the resource group "MA_azmonsen_australiasoutheast_managed" was created as part of "Azure Monitor Workspace" creation. You can verify that by
- Go to the "Azure Monitor Workspace" instance
- Select "Properties" in the resource menu
- Look for "Default ingestion settings". This will contain resource Id of the DCR and DCE. This Id would be of the following pattern:
............./resourceGroups/MA_azmon-workspace_eastus_managed/...
In this case, the "MA_azmon-workspace_eastus_managed" is the new resource group created as part of "Azure Monitor Workspace Creation", and it is called as 'managed resource group' as it is managed by another resource. To delete anything from that resource group, the Azure Monitor Workspace itself needs to be deleted.
- If you have data flowing into this workspace, you can leave the managed resource group and DCRs as is. As mentioned in my reply earlier, if you are not using Prometheus (which requires "Azure Monitor Workspace") and do not have data in this workspace, you can safely delete the workspace which will also delete the managed resource group as well as DCRs that needs to be deleted.
Regarding the new error obtained when running the script, I see that the failure is happening with New-AzRoleAssignment cmdlet which was not happening earlier. I would suggest using Get-AzContext and Remove-AzContext in the PowerShell window to login again to ensure that a fresh session is used.
Hope this helps.