Closed sebassem closed 1 year ago
Thanks @sebassem for raising, for now can you add this to the Deploy-ALZMGDiagnosticSettings.ps1
script as a workaround and also feel free to PR into this repo?
Select-AzSubscription -SubscriptionId '<Management Sub ID Here>'
Register-AzResourceProvider -ProviderNamespace 'Microsoft.Insights'
Wrap this in some logic to check if it is already assigned or not before trying to register
@sebassem let us know if you want to add this in a PR or not, as if not we will find someone to get it done :)
cc: @oZakari
@sebassem let us know if you want to add this in a PR or not, as if not we will find someone to get it done :)
cc: @oZakari
Yes Will submit one shortly
Jumping in on this one, struggling whole morning :(.
We are having a new tenant, experienced problems from here - referenced #470 and #565, waited out a couple of hours, but I still can't get past this step:
New-AzManagementGroupDeployment: /home/vsts/work/1/s/pipeline-scripts/Deploy-ALZMGDiagnosticSettings.ps1:25
Line |
25 | New-AzManagementGroupDeployment @inputObject
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| 10:37:12 - The deployment
| 'alz-MGDiagnosticSettings-20230801T1008197137Z' failed with error(s).
| Showing 2 out of 2 error(s). Status Message:
| (Code:InvalidAuthenticationToken) Status Message: At least one resource
| deployment operation failed. Please list deployment operations for
| details. Please see https://aka.ms/arm-deployment-operations for usage
| details. (Code: DeploymentFailed) - { "code":
| "InvalidAuthenticationToken", "message": "" } (Code:Conflict)
| CorrelationId: d3c179ab-0978-4715-897a-4f856329646a
Whole log here:
2023-08-01T10:36:16.4222411Z ##[section]Starting: Custom Management Group Diagnostic Settings
2023-08-01T10:36:16.4226832Z ==============================================================================
2023-08-01T10:36:16.4226952Z Task : Azure PowerShell
2023-08-01T10:36:16.4227034Z Description : Run a PowerShell script within an Azure environment
2023-08-01T10:36:16.4227125Z Version : 5.225.1
2023-08-01T10:36:16.4227183Z Author : Microsoft Corporation
2023-08-01T10:36:16.4227251Z Help : https://aka.ms/azurepowershelltroubleshooting
2023-08-01T10:36:16.4227347Z ==============================================================================
2023-08-01T10:36:16.8686276Z Generating script.
2023-08-01T10:36:16.8760634Z [command]/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command . '/home/vsts/work/_temp/c1bab709-7425-4692-b44c-f0437ab6fc35.ps1'
2023-08-01T10:36:16.8831350Z File saved!
2023-08-01T10:36:17.5035969Z ##[command]Import-Module -Name /usr/share/az_9.3.0/Az.Accounts/2.12.4/Az.Accounts.psd1 -Global
2023-08-01T10:36:18.3233241Z ##[command]Clear-AzContext -Scope Process
2023-08-01T10:36:18.4845149Z ##[command]Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
2023-08-01T10:36:18.5515519Z ##[command]Connect-AzAccount -ServicePrincipal -Tenant REDACTED -Credential System.Management.Automation.PSCredential -Environment AzureCloud @processScope
2023-08-01T10:36:24.9195910Z [33;1mVERBOSE: Using Bicep v0.19.5[0m
2023-08-01T10:36:28.6177600Z [33;1mWARNING: /home/vsts/work/1/s/upstream-releases/v0.16.0/infra-as-code/bicep/modules/mgDiagSettings/mgDiagSettings.bicep(1,1) : Info Bicep Linter Configuration: Custom bicepconfig.json file found (/home/vsts/work/1/s/upstream-releases/v0.16.0/infra-as-code/bicep/bicepconfig.json).
2023-08-01T10:36:28.6179265Z /home/vsts/work/1/s/upstream-releases/v0.16.0/infra-as-code/bicep/modules/mgDiagSettings/mgDiagSettings.bicep(15,59) : Warning use-recent-api-versions: Use more recent API version for 'Microsoft.Insights/diagnosticSettings'. '2021-05-01-preview' is 822 days old, should be no more than 730 days old, or the most recent. Acceptable versions: 2016-09-01 [https://aka.ms/bicep/linter/use-recent-api-versions]
2023-08-01T10:36:28.6180572Z /home/vsts/work/1/s/upstream-releases/v0.16.0/infra-as-code/bicep/orchestration/mgDiagSettingsAll/mgDiagSettingsAll.bicep(1,1) : Info Bicep Linter Configuration: Custom bicepconfig.json file found (/home/vsts/work/1/s/upstream-releases/v0.16.0/infra-as-code/bicep/bicepconfig.json).
2023-08-01T10:36:28.6227819Z /home/vsts/work/1/s/upstream-releases/v0.16.0/infra-as-code/bicep/CRML/customerUsageAttribution/cuaIdManagementGroup.bicep(1,1) : Info Bicep Linter Configuration: Custom bicepconfig.json file found (/home/vsts/work/1/s/upstream-releases/v0.16.0/infra-as-code/bicep/bicepconfig.json).[0m
2023-08-01T10:36:28.6431082Z [33;1mVERBOSE: [0m
2023-08-01T10:36:31.0216693Z [33;1mVERBOSE: 10:36:31 - Template is valid.[0m
2023-08-01T10:36:32.0903148Z [33;1mVERBOSE: 10:36:32 - Create template deployment 'alz-MGDiagnosticSettings-20230801T1008197137Z'[0m
2023-08-01T10:36:32.0917702Z [33;1mVERBOSE: 10:36:32 - Checking deployment status in 5 seconds[0m
2023-08-01T10:36:42.9017865Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw-decommissioned' provisioning status is running[0m
2023-08-01T10:36:42.9019971Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Insights/diagnosticSettings 'toLa' provisioning status is succeeded[0m
2023-08-01T10:36:42.9027795Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw-platform' provisioning status is running[0m
2023-08-01T10:36:42.9029178Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Insights/diagnosticSettings 'toLa' provisioning status is succeeded[0m
2023-08-01T10:36:42.9030190Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is running[0m
2023-08-01T10:36:42.9037384Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw-landingzones-corp' provisioning status is running[0m
2023-08-01T10:36:42.9037912Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is running[0m
2023-08-01T10:36:42.9038962Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Insights/diagnosticSettings 'toLa' provisioning status is succeeded[0m
2023-08-01T10:36:42.9039473Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw-landingzones' provisioning status is running[0m
2023-08-01T10:36:42.9039974Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is running[0m
2023-08-01T10:36:42.9040448Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Insights/diagnosticSettings 'toLa' provisioning status is succeeded[0m
2023-08-01T10:36:42.9041298Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw-platform-connectivity' provisioning status is running[0m
2023-08-01T10:36:42.9041865Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is running[0m
2023-08-01T10:36:42.9042328Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw' provisioning status is running[0m
2023-08-01T10:36:42.9042762Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Insights/diagnosticSettings 'toLa' provisioning status is succeeded[0m
2023-08-01T10:36:42.9043245Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is running[0m
2023-08-01T10:36:42.9043724Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw-sandbox' provisioning status is running[0m
2023-08-01T10:36:42.9045185Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is running[0m
2023-08-01T10:36:42.9045700Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Insights/diagnosticSettings 'toLa' provisioning status is succeeded[0m
2023-08-01T10:36:42.9053630Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw-landingzones-online' provisioning status is running[0m
2023-08-01T10:36:42.9055334Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is running[0m
2023-08-01T10:36:42.9055933Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Insights/diagnosticSettings 'toLa' provisioning status is succeeded[0m
2023-08-01T10:36:42.9058313Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw-platform-identity' provisioning status is running[0m
2023-08-01T10:36:42.9058955Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is running[0m
2023-08-01T10:36:42.9059448Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Insights/diagnosticSettings 'toLa' provisioning status is succeeded[0m
2023-08-01T10:36:42.9059930Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw-platform-management' provisioning status is running[0m
2023-08-01T10:36:42.9060453Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is running[0m
2023-08-01T10:36:42.9060921Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Insights/diagnosticSettings 'toLa' provisioning status is succeeded[0m
2023-08-01T10:36:42.9061427Z [33;1mVERBOSE: 10:36:42 - Resource Microsoft.Resources/deployments 'pid-f49c8dfb-c0ce-4ee0-b316-5e4844474dd0-lvjmfv5dzfznm' provisioning status is running[0m
2023-08-01T10:36:43.0353191Z [33;1mVERBOSE: 10:36:43 - Checking deployment status in 8 seconds[0m
2023-08-01T10:36:57.0322647Z [33;1mVERBOSE: 10:36:57 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is running[0m
2023-08-01T10:36:57.0323808Z [33;1mVERBOSE: 10:36:57 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is succeeded[0m
2023-08-01T10:36:57.0324932Z [33;1mVERBOSE: 10:36:57 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is succeeded[0m
2023-08-01T10:36:57.0325583Z [33;1mVERBOSE: 10:36:57 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is succeeded[0m
2023-08-01T10:36:57.0326283Z [33;1mVERBOSE: 10:36:57 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is succeeded[0m
2023-08-01T10:36:57.0326833Z [33;1mVERBOSE: 10:36:57 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is succeeded[0m
2023-08-01T10:36:57.0327327Z [33;1mVERBOSE: 10:36:57 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is succeeded[0m
2023-08-01T10:36:57.0327797Z [33;1mVERBOSE: 10:36:57 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is succeeded[0m
2023-08-01T10:36:57.0328283Z [33;1mVERBOSE: 10:36:57 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is succeeded[0m
2023-08-01T10:36:57.0328770Z [33;1mVERBOSE: 10:36:57 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is succeeded[0m
2023-08-01T10:36:57.0329236Z [33;1mVERBOSE: 10:36:57 - Resource Microsoft.Resources/deployments 'pid-f49c8dfb-c0ce-4ee0-b316-5e4844474dd0-lvjmfv5dzfznm' provisioning status is succeeded[0m
2023-08-01T10:36:57.1405637Z [33;1mVERBOSE: 10:36:57 - Checking deployment status in 10 seconds[0m
2023-08-01T10:37:12.3815611Z [33;1mVERBOSE: 10:37:12 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw-decommissioned' provisioning status is succeeded[0m
2023-08-01T10:37:12.3817411Z [33;1mVERBOSE: 10:37:12 - Resource Microsoft.Resources/deployments 'pid-5d17f1c2-f17b-4426-9712-0cd2652c4435-lvjmfv5dzfznm' provisioning status is succeeded[0m
2023-08-01T10:37:12.3818405Z [33;1mVERBOSE: 10:37:12 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw-platform' provisioning status is succeeded[0m
2023-08-01T10:37:12.3842840Z [33;1mVERBOSE: 10:37:12 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw-landingzones-corp' provisioning status is succeeded[0m
2023-08-01T10:37:12.3848480Z [33;1mVERBOSE: 10:37:12 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw-landingzones' provisioning status is succeeded[0m
2023-08-01T10:37:12.3849366Z [33;1mVERBOSE: 10:37:12 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw' provisioning status is succeeded[0m
2023-08-01T10:37:12.3850008Z [33;1mVERBOSE: 10:37:12 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw-sandbox' provisioning status is succeeded[0m
2023-08-01T10:37:12.3850661Z [33;1mVERBOSE: 10:37:12 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw-landingzones-online' provisioning status is succeeded[0m
2023-08-01T10:37:12.3852884Z [33;1mVERBOSE: 10:37:12 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw-platform-identity' provisioning status is succeeded[0m
2023-08-01T10:37:12.3853603Z [33;1mVERBOSE: 10:37:12 - Resource Microsoft.Resources/deployments 'mg-diag-set-rbw-platform-management' provisioning status is succeeded[0m
2023-08-01T10:37:12.6682234Z [31;1mNew-AzManagementGroupDeployment: [0m/home/vsts/work/1/s/pipeline-scripts/Deploy-ALZMGDiagnosticSettings.ps1:25
2023-08-01T10:37:12.6686450Z [36;1mLine |
2023-08-01T10:37:12.6687378Z [36;1m 25 | [0m [36;1mNew-AzManagementGroupDeployment @inputObject[0m
2023-08-01T10:37:12.6687685Z [36;1m | [31;1m ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2023-08-01T10:37:12.6687985Z [31;1m[36;1m | [31;1m10:37:12 - The deployment
2023-08-01T10:37:12.6688328Z [36;1m | [31;1m'alz-MGDiagnosticSettings-20230801T1008197137Z' failed with error(s).
2023-08-01T10:37:12.6688614Z [36;1m | [31;1mShowing 2 out of 2 error(s). Status Message:
2023-08-01T10:37:12.6688946Z [36;1m | [31;1m(Code:InvalidAuthenticationToken) Status Message: At least one resource
2023-08-01T10:37:12.6722259Z [36;1m | [31;1mdeployment operation failed. Please list deployment operations for
2023-08-01T10:37:12.6722771Z [36;1m | [31;1mdetails. Please see https://aka.ms/arm-deployment-operations for usage
2023-08-01T10:37:12.6723116Z [36;1m | [31;1mdetails. (Code: DeploymentFailed) - { "code":
2023-08-01T10:37:12.6723446Z [36;1m | [31;1m"InvalidAuthenticationToken", "message": "" } (Code:Conflict)
2023-08-01T10:37:12.6725757Z [36;1m | [31;1mCorrelationId: d3c179ab-0978-4715-897a-4f856329646a
2023-08-01T10:37:12.6726016Z [0m
2023-08-01T10:37:12.7779959Z ##[error]PowerShell exited with code '1'.
2023-08-01T10:37:12.7804143Z ##[section]Finishing: Custom Management Group Diagnostic Settings
Found this in deployment log:
{
"code": "DeploymentFailed",
"target": "/providers/Microsoft.Management/managementGroups/rbw-platform-identity/providers/Microsoft.Resources/deployments/mg-diag-set-rbw-platform-identity",
"message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.",
"details": [
{
"code": "InvalidAuthenticationToken",
"target": "/providers/Microsoft.Management/managementGroups/rbw-platform-identity/providers/Microsoft.Resources/deployments/mg-diag-set-rbw-platform-identity",
"message": ""
}
]
}
So, I figured out maybe I need to register Microsoft.Management provider as well:
Register-AzResourceProvider -ProviderNamespace 'Microsoft.Management'
So, this did the trick! :) Just FYI, maybe this needs to be added to the script as well.
Describe the bug
Deploying the accelerator with a customer on new subscriptions, we got an error that the Microsoft.Insights provider is not registered on the subscription. Maybe adding a `Register-AzResourceProvider command in the Deploy-ALZMGDiagnosticSettings.ps1 script would prevent issues proactively.
To Reproduce
Steps to reproduce the behaviour:
Expected behaviour
The pipeline completes without errors.
Screenshots 📷
Correlation ID
A correlation ID really helps us investigate your issue further. Please provide one if possible. Details on how to find a correlation ID can be found here: Correlation ID and support
Additional context
We are using the Azure Devops pipelines