-
Notifications
You must be signed in to change notification settings - Fork 183
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
Add debug flag to arm deployment command #1188
Conversation
I could also have used |
The following pipelines have been queued for testing: |
The following pipelines have been queued for testing: |
The following pipelines have been queued for testing: |
Hello @azure-sdk! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
@@ -385,7 +385,15 @@ foreach ($templateFile in $templateFiles) { | |||
|
|||
Log "Deploying template '$templateFile' to resource group '$($resourceGroup.ResourceGroupName)'" | |||
$deployment = Retry { | |||
New-AzResourceGroupDeployment -Name $BaseName -ResourceGroupName $resourceGroup.ResourceGroupName -TemplateFile $templateFile -TemplateParameterObject $templateFileParameters | |||
$lastDebugPreference = $DebugPreference | |||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't you simply pass -Debug
do this cmdlet? Doesn't that equate to the same thing without the need for the try/finally block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my testing, adding -Debug
sets $DebugPreference to "Inquire" for the rest of the script context. This does two undesired things: we don't want debug output for the rest of the script, and the Inquire setting requires manual confirmation, as opposed to "Continue".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems to suggest that it will set it to Continue in non-interactive mode. I'm not even sure what Inquire does.
It seems weird that it isn't scoped to just the one cmdlet call but if that is the case what you have works.
This is definitely an improvement does it also make sense to provide a link to the portal where we can see this deployment failure? Or is all that failure information included in the error message? |
All the failure information is included in the error, based on comparing what gets dumped out vs. what shows up in |
Yeah maybe that link to more info would be good. However we should set up an aka.ms link if we do that. |
|
There are some ARM deployment errors that do not surface adequate messages for debugging in the default error output. For example issues related to template validation (that can be a result of account quotas, invalid names, etc.): ``` WARNING: Attempt 1 failed: Exception calling "Invoke" with "0" argument(s): "The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: 07:13:02 - Error: Code=InvalidTemplateDeployment; Message=The template deployment 'benbp-foobar' is not valid according to the validation procedure. The tracking id is '182f1217-fa54-4fa8-bff3-ef74605e2fe9'. See inner errors for details. ``` By updating the `$DebugPreference` for the `New-AzResourceGroupDeployment` command, we print the inner error messages without having to plug correlation IDs into the ARM internal kusto to get the actual error. ``` DEBUG: ============================ HTTP RESPONSE ============================ Status Code: BadRequest Headers: Cache-Control : no-cache Pragma : no-cache x-ms-failure-cause : gateway x-ms-ratelimit-remaining-subscription-writes: 1199 x-ms-request-id : 11a8a92c-21ba-43dc-b504-84b92524c71b x-ms-correlation-request-id : 11a8a92c-21ba-43dc-b504-84b92524c71b x-ms-routing-request-id : EASTUS:20201110T225406Z:11a8a92c-21ba-43dc-b504-84b92524c71b Strict-Transport-Security : max-age=31536000; includeSubDomains X-Content-Type-Options : nosniff Date : Tue, 10 Nov 2020 22:54:06 GMT Body: { "error": { "code": "InvalidTemplateDeployment", "message": "The template deployment 'benbp-foobar' is not valid according to the validation procedure. The tracking id is '11a8a92c-21ba-43dc-b504-84b92524c71b'. See inner errors for details.", "details": [ { "code": "PreflightValidationCheckFailed", "message": "Preflight validation failed. Please refer to the details for the specific errors.", "details": [ { "code": "AccountNameInvalid", "target": "benbp-basenameprim", "message": "benbp-basenameprim is not a valid storage account name. Storage account name must be between 3 and 24 characters in length and use numbers and lower-case letters only." }, ``` An example full log with failures can be found here: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=614171&view=logs&j=011e1ec8-6569-5e69-4f06-baf193d1351e&t=5431112d-2b61-5a5f-7042-ef698f761043
There are some ARM deployment errors that do not surface adequate messages for debugging in the default error output. For example issues related to template validation (that can be a result of account quotas, invalid names, etc.):
By updating the
$DebugPreference
for theNew-AzResourceGroupDeployment
command, we print the inner error messages without having to plug correlation IDs into the ARM internal kusto to get the actual error.An example full log with failures can be found here: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=614171&view=logs&j=011e1ec8-6569-5e69-4f06-baf193d1351e&t=5431112d-2b61-5a5f-7042-ef698f761043