{"id":530,"date":"2018-07-21T13:00:26","date_gmt":"2018-07-21T13:00:26","guid":{"rendered":"http:\/\/www.ciraltos.com\/?p=530"},"modified":"2018-07-21T13:03:01","modified_gmt":"2018-07-21T13:03:01","slug":"authentication-and-azure-automation-runbooks","status":"publish","type":"post","link":"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/","title":{"rendered":"Authentication and Azure Automation Runbooks"},"content":{"rendered":"<p><img decoding=\"async\" loading=\"lazy\" class=\"alignleft wp-image-359 size-thumbnail\" src=\"\/wp-content\/uploads\/2017\/11\/PowerShellDSC-150x150.png\" alt=\"AzureAutomation\" width=\"150\" height=\"150\" \/>Recently I ran into an issue with Authentication and Azure Automation child runbooks. The goal was to call a PowerShell child runbook following the documentation <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/automation\/automation-child-runbooks\" target=\"_blank\" rel=\"noopener\">here<\/a>. I was using the cmdlet method, starting the runbook with the Start-AzureRmAutomationRunbook command. Trying to call the child runbook from the parent, I get the error:<!--more--><\/p>\n<p>&nbsp;<\/p>\n<p>Start-AzureRmAutomationRunbook : Object reference not set to an instance of an object.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-532\" src=\"\/wp-content\/uploads\/2018\/07\/image006.png\" alt=\"\" width=\"689\" height=\"343\" srcset=\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2018\/07\/image006.png 689w, https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2018\/07\/image006-300x149.png 300w\" sizes=\"(max-width: 689px) 100vw, 689px\" \/><\/p>\n<p>Further testing showed I could run the command interactively in PowerShell, so the command was correct. The problem was that the parent runbook has to authenticate to the Azure Automation account before it can call a child runbook. At the time of this writing, that fact was not indicated in the article above. The article <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/automation\/automation-first-runbook-textual\" target=\"_blank\" rel=\"noopener\">here<\/a>\u00a0gives direction in Step 5 on running a child PowerShell Workflow runbook. Although I wasn\u2019t using PowerShell Workflow, the process is the same. Adding this to the beginning of my parent runbook did the trick:<\/p>\n<pre>$Conn = Get-AutomationConnection -Name AzureRunAsConnection\r\nConnect-AzureRmAccount -ServicePrincipal -Tenant $Conn.TenantID `\r\n-ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint<\/pre>\n<p>The parent runbook authenticats to Azure Automation with the Azure run as account when this is added to the start of the parent runbook. Once authenticated, the runbook has permission to call child runbooks in the Automation account. Now runbooks are running as they should.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I ran into an issue with Authentication and Azure Automation child runbooks. The goal was to call a PowerShell child runbook following the documentation here. I was using the cmdlet method, starting the runbook with the Start-AzureRmAutomationRunbook command. Trying to call the child runbook from the parent, I get the error:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[2,170],"tags":[210,245,244,246,20,243,231],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Authentication and Azure Automation Runbooks - ciraltos<\/title>\n<meta name=\"description\" content=\"Trying to call the child runbook from the parent, I get the error: Object reference not set to an instance of an object.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Authentication and Azure Automation Runbooks - ciraltos\" \/>\n<meta property=\"og:description\" content=\"Trying to call the child runbook from the parent, I get the error: Object reference not set to an instance of an object.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/\" \/>\n<meta property=\"og:site_name\" content=\"ciraltos\" \/>\n<meta property=\"article:published_time\" content=\"2018-07-21T13:00:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-07-21T13:03:01+00:00\" \/>\n<meta name=\"author\" content=\"Travis Roberts\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ciraltos\" \/>\n<meta name=\"twitter:site\" content=\"@ciraltos\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Travis Roberts\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/\"},\"author\":{\"name\":\"Travis Roberts\",\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a\"},\"headline\":\"Authentication and Azure Automation Runbooks\",\"datePublished\":\"2018-07-21T13:00:26+00:00\",\"dateModified\":\"2018-07-21T13:03:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/\"},\"wordCount\":205,\"commentCount\":1,\"publisher\":{\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a\"},\"keywords\":[\"Azure Automation\",\"connect-azurermaccount\",\"get-automationconnection\",\"object referenced is not an instance of an object\",\"Powershell\",\"runas\",\"Runbook\"],\"articleSection\":[\"Azure\",\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/\",\"url\":\"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/\",\"name\":\"Authentication and Azure Automation Runbooks - ciraltos\",\"isPartOf\":{\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#website\"},\"datePublished\":\"2018-07-21T13:00:26+00:00\",\"dateModified\":\"2018-07-21T13:03:01+00:00\",\"description\":\"Trying to call the child runbook from the parent, I get the error: Object reference not set to an instance of an object.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/www.ciraltos.com\/staging2\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Authentication and Azure Automation Runbooks\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#website\",\"url\":\"http:\/\/www.ciraltos.com\/staging2\/\",\"name\":\"ciraltos\",\"description\":\"cloud, technology and trends\",\"publisher\":{\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.ciraltos.com\/staging2\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a\",\"name\":\"Travis Roberts\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/Logo-1.png\",\"contentUrl\":\"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/Logo-1.png\",\"width\":5657,\"height\":3563,\"caption\":\"Travis Roberts\"},\"logo\":{\"@id\":\"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/www.ciraltos.com\",\"https:\/\/twitter.com\/ciraltos\"],\"url\":\"https:\/\/www.ciraltos.com\/staging2\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Authentication and Azure Automation Runbooks - ciraltos","description":"Trying to call the child runbook from the parent, I get the error: Object reference not set to an instance of an object.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/","og_locale":"en_US","og_type":"article","og_title":"Authentication and Azure Automation Runbooks - ciraltos","og_description":"Trying to call the child runbook from the parent, I get the error: Object reference not set to an instance of an object.","og_url":"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/","og_site_name":"ciraltos","article_published_time":"2018-07-21T13:00:26+00:00","article_modified_time":"2018-07-21T13:03:01+00:00","author":"Travis Roberts","twitter_card":"summary_large_image","twitter_creator":"@ciraltos","twitter_site":"@ciraltos","twitter_misc":{"Written by":"Travis Roberts","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/#article","isPartOf":{"@id":"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/"},"author":{"name":"Travis Roberts","@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a"},"headline":"Authentication and Azure Automation Runbooks","datePublished":"2018-07-21T13:00:26+00:00","dateModified":"2018-07-21T13:03:01+00:00","mainEntityOfPage":{"@id":"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/"},"wordCount":205,"commentCount":1,"publisher":{"@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a"},"keywords":["Azure Automation","connect-azurermaccount","get-automationconnection","object referenced is not an instance of an object","Powershell","runas","Runbook"],"articleSection":["Azure","PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/","url":"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/","name":"Authentication and Azure Automation Runbooks - ciraltos","isPartOf":{"@id":"http:\/\/www.ciraltos.com\/staging2\/#website"},"datePublished":"2018-07-21T13:00:26+00:00","dateModified":"2018-07-21T13:03:01+00:00","description":"Trying to call the child runbook from the parent, I get the error: Object reference not set to an instance of an object.","breadcrumb":{"@id":"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.ciraltos.com\/staging2\/authentication-and-azure-automation-runbooks\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.ciraltos.com\/staging2\/"},{"@type":"ListItem","position":2,"name":"Authentication and Azure Automation Runbooks"}]},{"@type":"WebSite","@id":"http:\/\/www.ciraltos.com\/staging2\/#website","url":"http:\/\/www.ciraltos.com\/staging2\/","name":"ciraltos","description":"cloud, technology and trends","publisher":{"@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.ciraltos.com\/staging2\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/25391996d6cddfecd4d257162b7e373a","name":"Travis Roberts","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/image\/","url":"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/Logo-1.png","contentUrl":"https:\/\/www.ciraltos.com\/staging2\/wp-content\/uploads\/2023\/03\/Logo-1.png","width":5657,"height":3563,"caption":"Travis Roberts"},"logo":{"@id":"http:\/\/www.ciraltos.com\/staging2\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/www.ciraltos.com","https:\/\/twitter.com\/ciraltos"],"url":"https:\/\/www.ciraltos.com\/staging2\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/posts\/530"}],"collection":[{"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/comments?post=530"}],"version-history":[{"count":6,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/posts\/530\/revisions"}],"predecessor-version":[{"id":538,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/posts\/530\/revisions\/538"}],"wp:attachment":[{"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/media?parent=530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/categories?post=530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ciraltos.com\/staging2\/wp-json\/wp\/v2\/tags?post=530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}