From 1f50b77f029187b1677bbd58f5840e4bfd01b582 Mon Sep 17 00:00:00 2001 From: Leandro Wajswajn Pereyra Date: Thu, 21 Feb 2019 23:25:20 -0300 Subject: [PATCH 1/6] Replaced sync call with an async call and wait loop --- .../Automation/Common/AutomationPSClientDSC.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Automation/Automation/Common/AutomationPSClientDSC.cs b/src/Automation/Automation/Common/AutomationPSClientDSC.cs index cd5542abc8d0..2f05fb8a4937 100644 --- a/src/Automation/Automation/Common/AutomationPSClientDSC.cs +++ b/src/Automation/Automation/Common/AutomationPSClientDSC.cs @@ -983,7 +983,22 @@ public CompilationJob StartCompilationJob(string resourceGroupName, string autom }; - var job = this.automationManagementClient.DscCompilationJob.Create(resourceGroupName, automationAccountName, Guid.NewGuid().ToString(), createJobParameters); + string jobId = Guid.NewGuid().ToString(); + + var jobTask = this.automationManagementClient.DscCompilationJob.CreateAsync(resourceGroupName, automationAccountName, jobId, createJobParameters).GetAwaiter(); + DscCompilationJob job = null; + + while (!jobTask.IsCompleted && job == null) { + System.Threading.Thread.Sleep(1000); + + try + { + job = this.automationManagementClient.DscCompilationJob.Get(resourceGroupName, automationAccountName, jobId); + } + catch { + job = null; + } + } return new Model.CompilationJob(resourceGroupName, automationAccountName, job); } From a06b8170ad0b3be133bc33bbd763693af6b900e1 Mon Sep 17 00:00:00 2001 From: Leandro Wajswajn Pereyra Date: Fri, 22 Feb 2019 21:35:07 -0300 Subject: [PATCH 2/6] Switching 'while' loop by 'do-while' --- src/Automation/Automation/Common/AutomationPSClientDSC.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Automation/Automation/Common/AutomationPSClientDSC.cs b/src/Automation/Automation/Common/AutomationPSClientDSC.cs index 2f05fb8a4937..24419ba91c18 100644 --- a/src/Automation/Automation/Common/AutomationPSClientDSC.cs +++ b/src/Automation/Automation/Common/AutomationPSClientDSC.cs @@ -988,17 +988,19 @@ public CompilationJob StartCompilationJob(string resourceGroupName, string autom var jobTask = this.automationManagementClient.DscCompilationJob.CreateAsync(resourceGroupName, automationAccountName, jobId, createJobParameters).GetAwaiter(); DscCompilationJob job = null; - while (!jobTask.IsCompleted && job == null) { + do + { System.Threading.Thread.Sleep(1000); try { job = this.automationManagementClient.DscCompilationJob.Get(resourceGroupName, automationAccountName, jobId); } - catch { + catch + { job = null; } - } + } while (job == null); return new Model.CompilationJob(resourceGroupName, automationAccountName, job); } From 2ed7007be7c2c41264f5327eb91e2ac6abad631e Mon Sep 17 00:00:00 2001 From: Leandro Wajswajn Pereyra Date: Fri, 22 Feb 2019 21:53:10 -0300 Subject: [PATCH 3/6] Updated changelog --- src/Automation/Automation/ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Automation/Automation/ChangeLog.md b/src/Automation/Automation/ChangeLog.md index 3756c69cd573..8d7b07e45d58 100644 --- a/src/Automation/Automation/ChangeLog.md +++ b/src/Automation/Automation/ChangeLog.md @@ -21,6 +21,7 @@ * Update help for Import-AzAutomationDscNodeConfiguration * Added configuration name validation to Import-AzAutomationDscConfiguration cmdlet * Improved error handling for Import-AzAutomationDscConfiguration cmdlet +* Changed behavior for Start-AzAutomationDscCompilationJob to just start the job instead of waiting for its completion. ## Version 1.1.0 * Added support for Python 2 runbooks From 6536fe92d65e7b5e65d52b02aaa46a85d4eea496 Mon Sep 17 00:00:00 2001 From: Leandro Wajswajn Pereyra Date: Fri, 22 Feb 2019 21:53:26 -0300 Subject: [PATCH 4/6] Added breaking change warning --- .../Automation/Cmdlet/StartAzureAutomationDscCompilationJob.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Automation/Automation/Cmdlet/StartAzureAutomationDscCompilationJob.cs b/src/Automation/Automation/Cmdlet/StartAzureAutomationDscCompilationJob.cs index 5a83c735d57c..bfad3ec9b6fe 100644 --- a/src/Automation/Automation/Cmdlet/StartAzureAutomationDscCompilationJob.cs +++ b/src/Automation/Automation/Cmdlet/StartAzureAutomationDscCompilationJob.cs @@ -14,6 +14,7 @@ using Microsoft.Azure.Commands.Automation.Model; using Microsoft.Azure.Commands.Automation.Properties; +using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; using System; using System.Collections; using System.Globalization; @@ -25,6 +26,7 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet /// /// starts azure automation compilation job /// + [GenericBreakingChange("Behavior changed", ChangeDescription = "Cmdlet returns control to pipeline before compilation job has completed. Refer to https://docs.microsoft.com/en-us/azure/automation/automation-dsc-compile#compiling-a-dsc-configuration-with-windows-powershell")] [Cmdlet("Start", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "AutomationDscCompilationJob", SupportsShouldProcess = true)] [OutputType(typeof(CompilationJob))] public class StartAzureAutomationDscCompilationJob : AzureAutomationBaseCmdlet From d7cd17462f62a7a1518865895bc8e8a8b37e20f7 Mon Sep 17 00:00:00 2001 From: Leandro Wajswajn Pereyra Date: Sat, 23 Feb 2019 12:54:18 -0300 Subject: [PATCH 5/6] Added reference to issues in changelog --- src/Automation/Automation/ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Automation/Automation/ChangeLog.md b/src/Automation/Automation/ChangeLog.md index 8d7b07e45d58..9a3712ee4190 100644 --- a/src/Automation/Automation/ChangeLog.md +++ b/src/Automation/Automation/ChangeLog.md @@ -22,6 +22,7 @@ * Added configuration name validation to Import-AzAutomationDscConfiguration cmdlet * Improved error handling for Import-AzAutomationDscConfiguration cmdlet * Changed behavior for Start-AzAutomationDscCompilationJob to just start the job instead of waiting for its completion. + - Fix for issue https://github.com/Azure/azure-powershell/issues/8347 ## Version 1.1.0 * Added support for Python 2 runbooks From 917fe3d1a7e8c9f32d067784757421001790324e Mon Sep 17 00:00:00 2001 From: Leandro Wajswajn Pereyra Date: Wed, 13 Mar 2019 20:29:38 -0300 Subject: [PATCH 6/6] Removed breaking change attribute --- .../Automation/Cmdlet/StartAzureAutomationDscCompilationJob.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Automation/Automation/Cmdlet/StartAzureAutomationDscCompilationJob.cs b/src/Automation/Automation/Cmdlet/StartAzureAutomationDscCompilationJob.cs index bfad3ec9b6fe..c7d0fa897954 100644 --- a/src/Automation/Automation/Cmdlet/StartAzureAutomationDscCompilationJob.cs +++ b/src/Automation/Automation/Cmdlet/StartAzureAutomationDscCompilationJob.cs @@ -26,7 +26,6 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet /// /// starts azure automation compilation job /// - [GenericBreakingChange("Behavior changed", ChangeDescription = "Cmdlet returns control to pipeline before compilation job has completed. Refer to https://docs.microsoft.com/en-us/azure/automation/automation-dsc-compile#compiling-a-dsc-configuration-with-windows-powershell")] [Cmdlet("Start", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "AutomationDscCompilationJob", SupportsShouldProcess = true)] [OutputType(typeof(CompilationJob))] public class StartAzureAutomationDscCompilationJob : AzureAutomationBaseCmdlet