azureautomation / runbooks

Sample Automation runbooks
MIT License
150 stars 128 forks source link

Runbook multiple issues #23

Open nicolaibaralmueller opened 6 years ago

nicolaibaralmueller commented 6 years ago

Error: Runbook "Enable-MultipleSolution" cannot find cmdlet Find-AzureRMResource.

When executing runbook Exception shows: The module AzureRM.OperationalInsights is not available. Please import from the gallery on the modules page. (The module AzureRM.OperationalInsights is not available. Please import from the gallery on the modules page.)

This Module has been imported correctly as shown in the guide.

Specific runbook error shows: Find-AzureRmResource : The term 'Find-AzureRmResource' is not recognized as the name of a cmdlet, function, script file, or operable program.

A little research shows me that the runbook "Enable-MultiSolution" needs the modules AzureRM.Profile.Netcore and AzureRM.Resources.Netcore which contains the function Find-AzureRMResource.

However, when importing AzureRM.Profile.Netcore the following error shows: Importing of module failed Error importing the module AzureRM.Profile.Netcore. Import failed with the following error: Orchestrator.Shared.AsyncModuleImport.ModuleImportException: While importing the module, an error occurred while processing the module content. Internal error message: The following error occurred while loading the extended type data file: , C:\Users\Client\Temp\MJMVYOUSHV\AzureRM.Profile.Netcore\Microsoft.Azure.Commands.Profile.types.ps1xml(85) : Error: Unable to find type [Microsoft.Azure.Commands.Profile.Models.AzureContextConverter]. .

I also tried deleting AzureRM.Resources, AzureRM.Profile & AzureRM.Automation which resets modules to version 1.0.3.

Starting Runbook now gives the following error: _Find-AzureRmResource : A parameter cannot be found that matches parameter name 'AzureRmContext'. At line:116 char:98

So I replaced -AzureRMContext with -DefaultProfile but then DefaultProfile is unknown.

I give up. This solution needs some reviewing and updating. Please advise. Followed the guide: https://docs.microsoft.com/en-us/azure/automation/automation-onboard-solutions

eamonoreilly commented 6 years ago

The Find-AzureRmResource has been deprecated with the latest Azure PowerShell release. I have updated the runbook to now use Get-AzureRMResource instead. Can you try again with this latest change as the first error is probably the reason for not finding the OperationalInsights module also. Thanks, Eamon

nicolaibaralmueller commented 6 years ago

Awesome. I will try that tomorrow morning and let you know how it went.

Mvh Nicolai

Den 3. jun. 2018 kl. 19.52 skrev eamonoreilly notifications@github.com<mailto:notifications@github.com>:

The Find-AzureRmResource has been deprecated with the latest Azure PowerShell release. I have updated the runbook to now use Get-AzureRMResource instead. Can you try again with this latest change as the first error is probably the reason for not finding the OperationalInsights module also. Thanks, Eamon

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/azureautomation/runbooks/issues/23#issuecomment-394179209, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Af53X8YW1hdURfkLJql4nRJy2Yu7ziYRks5t5CJogaJpZM4UTK_f.

nicolaibaralmueller commented 6 years ago

Hi Eamon,

I just updated all modules, deleted the old runbook and imported the new version.

So the how-to guide is not complete I think or I cannot figure out how to implement it.

We have several subscriptions and trying to implement update management on VMs in other subscriptions.

Are you able to help?

Kind regards, Nicolai

Fra: eamonoreilly notifications@github.com Sendt: 3. juni 2018 19:53 Til: azureautomation/runbooks runbooks@noreply.github.com Cc: nicolaibaralmueller nbm@tmnet.dk; Author author@noreply.github.com Emne: Re: [azureautomation/runbooks] Runbook multiple issues (#23)

The Find-AzureRmResource has been deprecated with the latest Azure PowerShell release. I have updated the runbook to now use Get-AzureRMResource instead. Can you try again with this latest change as the first error is probably the reason for not finding the OperationalInsights module also. Thanks, Eamon

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/azureautomation/runbooks/issues/23#issuecomment-394179209, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Af53X8YW1hdURfkLJql4nRJy2Yu7ziYRks5t5CJogaJpZM4UTK_f.

nicolaibaralmueller commented 6 years ago

FYI:

Just deleted the VM from the workspace and ran the runbook again where the alreadyonboardedvm and resourcegroup was a different VM already onboarded to the VM.

This time only one error regarding monitoring agent: Cannot find monitoring agent on exiting machine tm-mgmt in resource group TM-Mangement (Cannot find monitoring agent on exiting machine tm-mgmt in resource group TM-Mangement)

The monitoring agent extension is however installed on the VM. Confusing.

Fra: eamonoreilly notifications@github.com Sendt: 3. juni 2018 19:53 Til: azureautomation/runbooks runbooks@noreply.github.com Cc: nicolaibaralmueller nbm@tmnet.dk; Author author@noreply.github.com Emne: Re: [azureautomation/runbooks] Runbook multiple issues (#23)

The Find-AzureRmResource has been deprecated with the latest Azure PowerShell release. I have updated the runbook to now use Get-AzureRMResource instead. Can you try again with this latest change as the first error is probably the reason for not finding the OperationalInsights module also. Thanks, Eamon

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/azureautomation/runbooks/issues/23#issuecomment-394179209, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Af53X8YW1hdURfkLJql4nRJy2Yu7ziYRks5t5CJogaJpZM4UTK_f.

eamonoreilly commented 6 years ago

Thanks for trying this out so quickly. I think I have identified the issue and have updated the runbook that you can import from the gallery. Please delete Enable-AutomationSolution and Enable-MultipleSolution runbooks from the Automation account and import Enable-MultipleSolution from the Runbook gallery (It will automatically import the Enable-AutomationSolution automatically if it is not in the Account). Sorry about the issue you were having with this. Thanks, Eamon

nicolaibaralmueller commented 6 years ago

Hi Eamon,

Thanks. The runbook now completes successfully. However, the solution does not work as expected.

The VM in the different subscription shows this message in VM update management: The solution cannot be enabled on this VM because the VM already has the management agent but the workspace associated with the agent cannot be found within the subscription: “subscriptionID”

The automation account shows that the VM has been connected to the workspace. Not showing in update management though. Only from the same subscription are shown.

Kind regards, Nicolai

Fra: eamonoreilly notifications@github.com Sendt: 5. juni 2018 03:31 Til: azureautomation/runbooks runbooks@noreply.github.com Cc: nicolaibaralmueller nbm@tmnet.dk; Author author@noreply.github.com Emne: Re: [azureautomation/runbooks] Runbook multiple issues (#23)

Thanks for trying this out so quickly. I think I have identified the issue and have updated the runbook that you can import from the gallery. Please delete Enable-AutomationSolution and Enable-MultipleSolution runbooks from the Automation account and import Enable-MultipleSolution from the Runbook gallery (It will automatically import the Enable-AutomationSolution automatically if it is not in the Account). Sorry about the issue you were having with this. Thanks, Eamon

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/azureautomation/runbooks/issues/23#issuecomment-394551473, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Af53X4u5VQkVwbuxsFV958618BtvSJgeks5t5d9igaJpZM4UTK_f.

nicolaibaralmueller commented 6 years ago

Hi again Eamon,

So after 20 minutes the VM showed up. The VM update management shows the error in the previous mail. I guess there is no way around that.

Thanks for the help so far.

Kind regards,

Nicolai

Fra: eamonoreilly notifications@github.com Sendt: 5. juni 2018 03:31 Til: azureautomation/runbooks runbooks@noreply.github.com Cc: nicolaibaralmueller nbm@tmnet.dk; Author author@noreply.github.com Emne: Re: [azureautomation/runbooks] Runbook multiple issues (#23)

Thanks for trying this out so quickly. I think I have identified the issue and have updated the runbook that you can import from the gallery. Please delete Enable-AutomationSolution and Enable-MultipleSolution runbooks from the Automation account and import Enable-MultipleSolution from the Runbook gallery (It will automatically import the Enable-AutomationSolution automatically if it is not in the Account). Sorry about the issue you were having with this. Thanks, Eamon

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/azureautomation/runbooks/issues/23#issuecomment-394551473, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Af53X4u5VQkVwbuxsFV958618BtvSJgeks5t5d9igaJpZM4UTK_f.

eamonoreilly commented 6 years ago

Thanks Nicolai. It is a known issue that if a VM is onboarded from a different subscription then you can't view it from the single VM and it is only available to be managed from the Automation account. We are looking at addressing this. Thanks for confirming the original issue is resolved. Eamon

nicolaibaralmueller commented 6 years ago

Hi Eamon, The runbook fails again. I did not update modules or the runbooks since last time.

The associated runbook Enable-AutomationSolution fails because it’s suddenly trying to install oms linux agent on a windows vm.

I have tried to uninstall the two runbooks, update automation account modules and import the runbooks again. Same error.

Azure has updated the modules again. I suspect, like last time, that the runbooks are incompatible with azure modules :-/

agentfailure enable-automationsolution enable-multisolution modules runbooks

The modules have been updated to newest versions since like described above.

eamonoreilly commented 6 years ago

Hi Nicolai, Could you check that an OSProfile is set on the Windows VM? I use the below code to see if it is a windows VM and it seems it is not present for the OSProfile.WindowsConfiguration so it is falling into the Linux path.

if ($NewVM.OSProfile.WindowsConfiguration -eq $null)
{
    $MMAExentsionName = "OmsAgentForLinux"
    $MMATemplateLinkUri = "https://wcusonboardingtemplate.blob.core.windows.net/onboardingtemplate/ArmTemplate/createMmaLinuxV3.json"
}
else 
{
    $MMAExentsionName = "MicrosoftMonitoringAgent"
    $MMATemplateLinkUri = "https://wcusonboardingtemplate.blob.core.windows.net/onboardingtemplate/ArmTemplate/createMmaWindowsV3.json"      
}

Could you run the below code in PowerShell and see if this setting is present on the VM? $NewVM = Get-AzureRmVM -ResourceGroupName -VMName $NewVM.OSProfile

Thanks, Eamon

eamonoreilly commented 6 years ago

Sorry - that should be $NewVM = Get-AzureRmVM -ResourceGroupName "vmresourcegroup" -VMName "vmname" $NewVM.OSProfile

nicolaibaralmueller commented 6 years ago

Hi Eamon,

Thanks for getting back so quick.

[cid:image002.jpg@01D4064C.F1F2CF50]

As seen above OSProfile looks to be nonexistent. Azure Portal shows Operating System = Windows.

The error is for all VMs.

Fra: eamonoreilly notifications@github.com Sendt: 15. juni 2018 14:53 Til: azureautomation/runbooks runbooks@noreply.github.com Cc: nicolaibaralmueller nbm@tmnet.dk; Author author@noreply.github.com Emne: Re: [azureautomation/runbooks] Runbook multiple issues (#23)

Sorry - that should be $NewVM = Get-AzureRmVM -ResourceGroupName "vmresourcegroup" -VMName "vmname" $NewVM.OSProfile

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/azureautomation/runbooks/issues/23#issuecomment-397611012, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Af53Xy2i98dXo6RKRYzPrkpCUHJbQ1biks5t864rgaJpZM4UTK_f.

eamonoreilly commented 6 years ago

Hi Nicolai, I updated this runbook to perform the OS check in a different way.

# Set up MMA agent information to onboard VM to the workspace
if ($NewVM.StorageProfile.OSDisk.OSType -eq "Linux")
{
    $MMAExentsionName = "OmsAgentForLinux"
    $MMATemplateLinkUri = "https://wcusonboardingtemplate.blob.core.windows.net/onboardingtemplate/ArmTemplate/createMmaLinuxV3.json"
}
elseif ($NewVM.StorageProfile.OSDisk.OSType -eq "Windows")  
{
    $MMAExentsionName = "MicrosoftMonitoringAgent"
    $MMATemplateLinkUri = "https://wcusonboardingtemplate.blob.core.windows.net/onboardingtemplate/ArmTemplate/createMmaWindowsV3.json"      
}
else
{
    Throw ("Could not determine OS of VM " + $NewVM.Name)
}

If you delete the runbooks and import again, it should hopefully work for this specific VM also. The updated changes are available in the runbook gallery as well as on https://github.com/azureautomation/runbooks/blob/master/Utility/ARM/Enable-AutomationSolution.ps1 Thanks, Eamon

nicolaibaralmueller commented 6 years ago

Hi Eamon,

It works. You are awesome. Quick responses and solutions. Thank you.

Have a great day, Nico

Fra: eamonoreilly notifications@github.com Sendt: 18. juni 2018 17:08 Til: azureautomation/runbooks runbooks@noreply.github.com Cc: nicolaibaralmueller nbm@tmnet.dk; Author author@noreply.github.com Emne: Re: [azureautomation/runbooks] Runbook multiple issues (#23)

Hi Nicolai, I updated this runbook to perform the OS check in a different way.

Set up MMA agent information to onboard VM to the workspace

if ($NewVM.StorageProfile.OSDisk.OSType -eq "Linux")

{

$MMAExentsionName = "OmsAgentForLinux"

$MMATemplateLinkUri = "https://wcusonboardingtemplate.blob.core.windows.net/onboardingtemplate/ArmTemplate/createMmaLinuxV3.json"

}

elseif ($NewVM.StorageProfile.OSDisk.OSType -eq "Windows")

{

$MMAExentsionName = "MicrosoftMonitoringAgent"

$MMATemplateLinkUri = "https://wcusonboardingtemplate.blob.core.windows.net/onboardingtemplate/ArmTemplate/createMmaWindowsV3.json"

}

else

{

Throw ("Could not determine OS of VM " + $NewVM.Name)

}

If you delete the runbooks and import again, it should hopefully work for this specific VM also. The updated changes are available in the runbook gallery as well as on https://github.com/azureautomation/runbooks/blob/master/Utility/ARM/Enable-AutomationSolution.ps1 Thanks, Eamon

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/azureautomation/runbooks/issues/23#issuecomment-398087179, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Af53X2J3uKPi3jSCvu12kXPG33qfbi-4ks5t98JPgaJpZM4UTK_f.