{"id":3577,"date":"2021-04-25T15:23:52","date_gmt":"2021-04-25T14:23:52","guid":{"rendered":"https:\/\/www.lieben.nu\/liebensraum\/?p=3577"},"modified":"2021-04-25T15:23:52","modified_gmt":"2021-04-25T14:23:52","slug":"deploying-a-service-principal-to-csp-child-tenants","status":"publish","type":"post","link":"https:\/\/lieben.nu\/liebensraum\/2021\/04\/deploying-a-service-principal-to-csp-child-tenants\/","title":{"rendered":"Deploying a service principal to (CSP) child tenants"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2021\/04\/oauth2permissiongrant-for-SPN-in-csp-child-tenants.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1439\" height=\"275\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2021\/04\/oauth2permissiongrant-for-SPN-in-csp-child-tenants.png\" alt=\"\" class=\"wp-image-3578\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2021\/04\/oauth2permissiongrant-for-SPN-in-csp-child-tenants.png 1439w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2021\/04\/oauth2permissiongrant-for-SPN-in-csp-child-tenants-300x57.png 300w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2021\/04\/oauth2permissiongrant-for-SPN-in-csp-child-tenants-1024x196.png 1024w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2021\/04\/oauth2permissiongrant-for-SPN-in-csp-child-tenants-768x147.png 768w\" sizes=\"auto, (max-width: 1439px) 100vw, 1439px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Cloud Solution Providers, or sometimes other types of Managed Service Providers often have to manage a large number of tenants. Ideally, they do their &#8216;Infrastructure As Code&#8217;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using various API&#8217;s to manage tenants is best done using a Service Principal instead of a user (MFA, lifecycle, etc). <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Recently, I was tasked to provide a deployment method of a Service Principal (multi-tenant) to all child tenants of an MSP, including programmatically granting various Graph API permissions. The Graph endpoint for this (oauth2PermissionGrants) is still in Beta, but the other methods I wrote about in the <a href=\"https:\/\/www.lieben.nu\/liebensraum\/2018\/04\/how-to-grant-oauth2-permissions-to-an-azure-ad-application-using-powershell-unattended-silently\/\" data-type=\"post\" data-id=\"2824\">past <\/a>are not as reliable so we&#8217;re using the Beta endpoint.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The linked example script creates an SPN and grants AuditLog.Read.All. If you&#8217;re an MSP\/CSP, you&#8217;ll probably want to capture the tenant ID&#8217;s you&#8217;re installing into, so you can easily administer these tenants centrally using your main multi-tenant SPN.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Moving forwards, you won&#8217;t need an admin user \/ service account in the tenants you manage anymore, at least for the API&#8217;s that support SPN&#8217;s.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/gitlab.com\/Lieben\/assortedFunctions\/-\/blob\/master\/add-servicePrincipalToAllCSPChildTenants.ps1\">https:\/\/gitlab.com\/Lieben\/assortedFunctions\/-\/blob\/master\/add-servicePrincipalToAllCSPChildTenants.ps1<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note: to completely remove module dependencies \/ login, check my <a href=\"https:\/\/www.lieben.nu\/liebensraum\/2020\/04\/calling-graph-and-other-apis-silently-for-an-mfa-enabled-account\/\" data-type=\"post\" data-id=\"3412\">independent token function.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cloud Solution Providers, or sometimes other types of Managed Service Providers often have to manage a large number of tenants. Ideally, they do their &#8216;Infrastructure As Code&#8217;. Using various API&#8217;s to manage tenants is best done using a Service Principal instead of a user (MFA, lifecycle, etc). Recently, I was tasked to provide a deployment &hellip; <a href=\"https:\/\/lieben.nu\/liebensraum\/2021\/04\/deploying-a-service-principal-to-csp-child-tenants\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Deploying a service principal to (CSP) child tenants<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[4,7,9,39],"tags":[],"class_list":["post-3577","post","type-post","status-publish","format-standard","hentry","category-automation","category-azuread","category-csp","category-powershell"],"_links":{"self":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts\/3577","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/comments?post=3577"}],"version-history":[{"count":0,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts\/3577\/revisions"}],"wp:attachment":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/media?parent=3577"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/categories?post=3577"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/tags?post=3577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}