Azure / deployment-stacks

Contains Deployment Stacks CLI scripts and releases
MIT License
87 stars 6 forks source link

Actual deployment error not surfaced #78

Closed slavizh closed 1 year ago

slavizh commented 1 year ago

Describe the bug I have previously reported this with previous private preview but seems still present. When you are deploying deployment stacks and there is error the actual error is not surfaced. Instead we are getting something like this:

PS D:\dev\deployment-stacks\lz-analysis-services-monitoring> New-AzSubscriptionDeploymentStack -Name lz-analysis-services-monitoring -TemplateFile .\main.bicep -TemplateParameterFile .\main.parameters.json -Location 'West Europe' -OutVariable p -Verbose
VERBOSE: Using Bicep v0.13.1
VERBOSE: Performing the operation "Create" on target "lz-analysis-services-monitoring".
VERBOSE: 10:11:59 - Checking stack deployment status
VERBOSE: 10:12:04 - Checking stack deployment status
VERBOSE: 10:12:09 - Checking stack deployment status
VERBOSE: 10:12:14 - Checking stack deployment status
New-AzSubscriptionDeploymentStack: 10:12:19 - The deployment 'lz-analysis-services-monitoring' failed with error(s). Showing 3 out of 3 error(s).
Error: Code=DeploymentStackUpdateFailed; Message=One or more stages of the deploymentStack failed. Correlation id: '1d58bde5-82f0-4637-892b-07ca323cfb7b'

Error: Code=DeploymentFailed; Message=At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.

Error: Code=DeploymentFailed; Message=At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.

Id                          : /subscriptions/<subscription id>/providers/Microsoft.Resources/deploymentStacks/lz-analysis-services-monitoring
Name                        : lz-analysis-services-monitoring
ProvisioningState           : failed
Parameters                  : {Name: resourceGroups, Type: array, Value: {
                                "name": "test-analysisserv-rg",
                                "location": "West Europe",
                                "tags": {
                                  "purpose": "mon"
                                },
                                "alertsScope": {
                                  "logAnalyticsWorkspace": {
                                    "name": "some name",
                                    "resourceGroup": "some rg"
                                  }
                                },
                                "actionGroups": [
                                  {
                                    "name": "some name",
                                    "resourceGroup": "some rg"
                                  }
                                ],
                                "alertRules": {
                                  "memoryUsage": {
                                    "enabled": true,
                                    "frequencyInMinutes": 5,
                                    "timeWindowInMinutes": 5,
                                    "description": "test1"
                                  }
                                }
                              }}
ResourcesCleanupAction      : detach
ResourceGroupsCleanupAction : detach
DenySettingsMode            : none
Location                    : westeurope
CreationTime(UTC)           : 20.1.2023 г. 8:12:02
DeploymentId                : /subscriptions/<subscription id>/providers/Microsoft.Resources/deployments/lz-analysis-services-monitoring-2023-01-20-08-12-03-e9190
Resources                   : /subscriptions/<subscription id>/resourceGroups/KustoTest/providers/Microsoft.OperationalInsights/workspaces/ws007
                              /subscriptions/<subscription id>/resourceGroups/test-analysisserv-rg
Error                       : DeploymentFailed - At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.

I need to go to activity log for example (due to this issue #77) and check what it says there. There I can see the following: image

This gives me information what is causing the actual failure. Deployment stacks needs to surface the actual error as having to go in Portal to see it is not good experience. Even if you use deployment stacks in automation is not good experience as than you will need to build some logic that upon failure you will need to check the deployment and/or the activity log in order to present the actual error. In automation scenarios that will result in building additional code, maintaining it and additional time the pipeline needs to run in order to fetch that information.

To Reproduce Steps to reproduce the behavior:

  1. Start deployment stacks deployment that will fail.
  2. Check error in output and in portal

Expected behavior Actual error to be surfaced. If there are more than one errors all should be surfaced.

Screenshots If applicable, add screenshots to help explain your problem.

Repro Environment Host OS: Windows 11 Powershell Version: 7.3.1

Server Debugging Information Correlation ID: 1d58bde5-82f0-4637-892b-07ca323cfb7b Tenant ID: I can provide in private. Timestamp of issue (please include time zone): above, Eastern Europe time zone Data Center (eg, West Central US, West Europe): West Europe

Additional context Add any other context about the problem here.

slavizh commented 1 year ago

Here is how error looks if you deploy via New-Az*Deployment:

New-AzDeployment: 11:50:29 - The deployment 'lz-analysis-services-monitoring' failed with error(s). Showing 2 out of 2 error(s).
Status Message: Deployment template validation failed: 'The template resource '[items(parameters('analysisServiceMonitoring').alertRules)[copyIndex()].value.id]' at line '1' and column '8044' is not valid: The language expression property 'id' doesn't exist, available properties are 'enabled, frequencyInMinutes, timeWindowInMinutes, description'.. Please see https://aka.ms/arm-template-expressions for usage details.'. (Code:InvalidTemplate)

Status Message: At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details. (Code: DeploymentFailed)
 - {
  "error": {
    "code": "InvalidTemplate",
    "message": "Deployment template validation failed: 'The template resource '[items(parameters('analysisServiceMonitoring').alertRules)[copyIndex()].value.id]' at line '1' and column '8044' is not valid: The language expression property 'id' doesn't exist, available properties are 'enabled, frequencyInMinutes, timeWindowInMinutes, description'.. Please see https://aka.ms/arm-template-expressions for usage details.'.",
    "additionalInfo": [
      {
        "type": "TemplateViolation",
        "info": {
          "lineNumber": 1,
          "linePosition": 8044,
          "path": "properties.template.resources[0]"
        }
      }
    ]
  }
} (Code:BadRequest)

CorrelationId: 52840c04-f4f3-4146-afed-c4c7ca24f4f8

You can see what better structure it has and full information is surfaced.

azcloudfarmer commented 1 year ago

Hi @slavizh, thanks for the details, we've filed a fix for this one.

dantedallag commented 1 year ago

@slavizh I'm closing this one as we are bubbling up the underlying error now. Please open another issue if you continue to experience this.