Skip to content
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

Start-AzAutomationDscCompilationJob hangs if the compilation job fails #8347

Closed
janegilring opened this issue Jan 18, 2019 · 17 comments
Closed
Assignees
Labels
Automation automation-dsc must also have the "Automation" label Service Attention This issue is responsible by Azure service team.

Comments

@janegilring
Copy link

Description

When compiling a PowerShell DSC configuration using Start-AzAutomationDscCompilationJob in PowerShell Core, the compilation job hangs. It is not possible to abort by using Ctrl + C, you will have to close and re-open PowerShell Core.

Script/Steps for Reproduction

Connect-AzAccount
Set-AzContext -SubscriptionId 1f732d91-23e3-40c5-b17e-123456789

Import-Module Az.Automation

$PSDefaultParameterValues = @{
  "*AzAutomation*:ResourceGroupName" = 'West-Europe-Management'
  "*AzAutomation*:AutomationAccountName" = 'Automation-West-Europe'
}

# HybridFileServers
$SourcePath = 'C:\temp\HybridFileServer.ps1'
Import-AzAutomationDscConfiguration -SourcePath $SourcePath -Force -Published -Tags @{Source='Git'}

# HybridFileServers
$ConfigurationData = Import-PowerShellDataFile -Path 'C:\temp\HybridFileServers.psd1'
$CompilationJob = Start-AzAutomationDscCompilationJob -ConfigurationName HybridFileServer -ConfigurationData $ConfigurationData

Module Version

Get-Module -ListAvailable -Name Az*
ModuleType Version    Name                                PSEdition ExportedCommands
---------- -------    ----                                --------- ----------------
Script     1.0.0      Az.Accounts                         Core,Desk {Disable-AzDataCollection, Disable-AzContextAuto...
Script     1.0.0      Az.Aks                              Core,Desk {Get-AzAks, New-AzAks, Remove-AzAks, Import-AzAk...
Script     1.0.0      Az.AnalysisServices                 Core,Desk {Resume-AzAnalysisServicesServer, Suspend-AzAnal...
Script     1.0.0      Az.ApiManagement                    Core,Desk {Add-AzApiManagementRegion, Get-AzApiManagementS...
Script     1.0.0      Az.ApplicationInsights              Core,Desk {Get-AzApplicationInsights, New-AzApplicationIns...
Script     1.0.0      Az.Automation                       Core,Desk {Get-AzAutomationHybridWorkerGroup, Remove-AzAut...
Script     1.0.0      Az.Batch                            Core,Desk {Remove-AzBatchAccount, Get-AzBatchAccount, Get-...
Script     1.0.0      Az.Billing                          Core,Desk {Get-AzBillingInvoice, Get-AzBillingPeriod, Get-...
Script     1.0.0      Az.Cdn                              Core,Desk {Get-AzCdnProfile, Get-AzCdnProfileSsoUrl, New-A...
Script     1.0.0      Az.CognitiveServices                Core,Desk {Get-AzCognitiveServicesAccount, Get-AzCognitive...
Script     1.0.0      Az.Compute                          Core,Desk {Remove-AzAvailabilitySet, Get-AzAvailabilitySet...
Script     1.0.0      Az.ContainerInstance                Core,Desk {New-AzContainerGroup, Get-AzContainerGroup, Rem...
Script     1.0.0      Az.ContainerRegistry                Core,Desk {New-AzContainerRegistry, Get-AzContainerRegistr...
Script     1.0.0      Az.DataFactory                      Core,Desk {Set-AzDataFactoryV2, Update-AzDataFactoryV2, Ge...
Script     1.0.0      Az.DataLakeAnalytics                Core,Desk {Get-AzDataLakeAnalyticsDataSource, New-AzDataLa...
Script     1.0.0      Az.DataLakeStore                    Core,Desk {Get-AzDataLakeStoreTrustedIdProvider, Remove-Az...
Script     1.0.0      Az.DevTestLabs                      Core,Desk {Get-AzDtlAllowedVMSizesPolicy, Get-AzDtlAutoShu...
Script     1.0.0      Az.Dns                              Core,Desk {Get-AzDnsRecordSet, New-AzDnsRecordConfig, Remo...
Script     1.0.0      Az.EventGrid                        Core,Desk {New-AzEventGridTopic, Get-AzEventGridTopic, Set...
Script     1.0.0      Az.EventHub                         Core,Desk {New-AzEventHubNamespace, Get-AzEventHubNamespac...
Script     1.0.0      Az.HDInsight                        Core,Desk {Get-AzHDInsightJob, New-AzHDInsightSqoopJobDefi...
Script     1.0.0      Az.IotHub                           Core,Desk {Add-AzIotHubKey, Get-AzIotHubEventHubConsumerGr...
Script     1.0.0      Az.KeyVault                         Core,Desk {Add-AzKeyVaultCertificate, Update-AzKeyVaultCer...
Script     1.0.0      Az.LogicApp                         Core,Desk {Get-AzIntegrationAccountAgreement, Get-AzIntegr...
Script     1.0.0      Az.MachineLearning                  Core,Desk {Move-AzMlCommitmentAssociation, Get-AzMlCommitm...
Script     1.0.0      Az.MarketplaceOrdering              Core,Desk {Get-AzMarketplaceTerms, Set-AzMarketplaceTerms}
Script     1.0.0      Az.Media                            Core,Desk {Sync-AzMediaServiceStorageKeys, Set-AzMediaServ...
Script     1.0.0      Az.Monitor                          Core,Desk {Get-AzMetricDefinition, Get-AzMetric, Remove-Az...
Script     1.0.0      Az.Network                          Core,Desk {Add-AzApplicationGatewayAuthenticationCertifica...
Script     1.0.0      Az.NotificationHubs                 Core,Desk {Get-AzNotificationHub, Get-AzNotificationHubAut...
Script     1.0.0      Az.OperationalInsights              Core,Desk {New-AzOperationalInsightsAzureActivityLogDataSo...
Script     1.0.0      Az.PolicyInsights                   Core,Desk {Get-AzPolicyEvent, Get-AzPolicyState, Get-AzPol...
Script     1.0.0      Az.PowerBIEmbedded                  Core,Desk {Remove-AzPowerBIWorkspaceCollection, Get-AzPowe...
Script     1.0.0      Az.RecoveryServices                 Core,Desk {Get-AzRecoveryServicesBackupProperty, Get-AzRec...
Script     1.0.0      Az.RedisCache                       Core,Desk {Remove-AzRedisCachePatchSchedule, New-AzRedisCa...
Script     1.0.0      Az.Relay                            Core,Desk {New-AzRelayNamespace, Get-AzRelayNamespace, Set...
Script     1.0.0      Az.Resources                        Core,Desk {Get-AzProviderOperation, Remove-AzRoleAssignmen...
Script     1.0.0      Az.ServiceBus                       Core,Desk {New-AzServiceBusNamespace, Get-AzServiceBusName...
Script     1.0.0      Az.ServiceFabric                    Core,Desk {Add-AzServiceFabricApplicationCertificate, Add-...
Script     1.0.0      Az.SignalR                          Core,Desk {New-AzSignalR, Get-AzSignalR, Get-AzSignalRKey,...
Script     1.0.0      Az.Sql                              Core,Desk {Get-AzSqlDatabaseTransparentDataEncryption, Get...
Script     1.0.0      Az.Storage                          Core,Desk {Get-AzStorageAccount, Get-AzStorageAccountKey, ...
Script     1.0.0      Az.StreamAnalytics                  Core,Desk {Get-AzStreamAnalyticsFunction, Get-AzStreamAnal...
Script     1.0.0      Az.TrafficManager                   Core,Desk {Add-AzTrafficManagerCustomHeaderToEndpoint, Rem...
Script     1.0.0      Az.Websites                         Core,Desk {Get-AzAppServicePlan, Set-AzAppServicePlan, New...

Environment Data

$PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.1.0
PSEdition                      Core
GitCommitId                    6.1.0
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Debug Output

PS C:\Users\janring> $CompilationJob = Start-AzAutomationDscCompilationJob -ConfigurationName HybridFileServer -ConfigurationData $ConfigurationData
DEBUG: 09:18:14 - StartAzureAutomationDscCompilationJob begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 09:18:14 - using account id 'jan.egil.ring@******.com'...

Note: At this point, the DSC configuration compilation jobs is suspended in the portal, but hangs in PowerShell Core.

@janegilring
Copy link
Author

The issue is also present in Windows PowerShell, not just PowerShell Core.

@markcowl
Copy link
Member

@janegilring Is this occurring for a particular compilat_on job, or for any compilation job?_

@markcowl markcowl added More Info 🏷️ Automation Service Attention This issue is responsible by Azure service team. labels Jan 18, 2019
@markcowl
Copy link
Member

@vrdmr can you take a look?

@janegilring
Copy link
Author

@markcowl Any compilation jobs which ends in a Suspended state.

@jordanbean1
Copy link

I see the same issue. This defeats the purpose of having the while loop afterwards that can check for status (as shown in the example: https://docs.microsoft.com/en-us/azure/automation/automation-dsc-compile#compiling-a-dsc-configuration-with-windows-powershell)

@vrdmr vrdmr added the automation-dsc must also have the "Automation" label label Feb 20, 2019
@vrdmr vrdmr assigned mgreenegit, GaneshMSAzure and avkaur and unassigned vrdmr Feb 20, 2019
@vrdmr
Copy link
Member

vrdmr commented Feb 20, 2019

@avkaur can you take a look?

@mgreenegit
Copy link
Member

Thank you for the ping @vrdmr, and thank you for submitting this, @janegilring. We will take a look. This only happens when the job reaches a suspended compilation, correct?

@janegilring
Copy link
Author

@mgreenegit Yes, that is correct.

@mgreenegit
Copy link
Member

@avkaur can you ack you will take this?

@lwajswaj
Copy link
Contributor

lwajswaj commented Feb 22, 2019

hey @mgreenegit, I've just looked into this issue. I'm able to repro it. The issue is the code is making a synchronous call to create the compilation job but that call doesn't end till the job completes, as the job gets suspended, then it never completes and that's why the behavior.

Based on the cmdlet name, this cmdlet is only expected to start the job and return with job information to monitor further as this link explains; so, adjusting the code to use an async call would fix this and give this expected behavior. However, current behavior for this cmdlet is totally different and this change might be a breaking change as people are used to have control back only once the DSC configuration is compiled (also, not sure if I'm going to further the grammar here but documentation for the cmdlet says "compiles an APS Desired State Configuration (DSC) configuration in Azure Automation".

So, question is, what should it be done? Restore the cmdlet to its original expectation and notify the breaking change OR adjust it to work properly with this limitation avoiding to introduce changes to its current behavior. Thoughts? (Personal vote is to restore it to its original spirit by doing an async call and returning job information for monitoring as the cmdlet verb is "Start")

@janegilring
Copy link
Author

My vote: Restore the cmdlet to its original expectation and notify the breaking change, as I have existing scripts/runbooks which relies on this behavior.

@jordanbean1
Copy link

I agree that we should restore the cmdlet to its original expectation. The docs clearly show this was the intention and I would wager many people have implemented the code as the example shows.

@jordanbean1
Copy link

More importantly, though, there is no way for us to work around this behavior now since it causes our PowerShell window to hang.

@mgreenegit
Copy link
Member

@nitinbps and @avkaur for input.

@lwajswaj
Copy link
Contributor

Just in case, I agree with @jordanbean1 and @janegilring as all the documentation points that use case instead of the currently implemented. My PR creates that behavior.

MiYanni added a commit that referenced this issue May 14, 2019
Fix Start-AzAutomationDscCompilationJob (Issue #8347)
@andyw248
Copy link

Looks like this was fixed by community member lwajswaj. Thank you!

@janegilring
Copy link
Author

Awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Automation automation-dsc must also have the "Automation" label Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

10 participants