From f5b34d8d58e1bdf40595369f93073047e7d08925 Mon Sep 17 00:00:00 2001 From: Hamood <8771696+abdale@users.noreply.github.com> Date: Thu, 8 Jun 2023 18:39:30 -0400 Subject: [PATCH] Added PowersShell method for creating service principal (#320) * Update DataManagementAnalytics-ServicePrincipal.md * Update docs/DataManagementAnalytics-ServicePrincipal.md Co-authored-by: Marvin Buss <34542414+marvinbuss@users.noreply.github.com> * Update docs/DataManagementAnalytics-ServicePrincipal.md Co-authored-by: Marvin Buss <34542414+marvinbuss@users.noreply.github.com> * Update docs/DataManagementAnalytics-ServicePrincipal.md Co-authored-by: Marvin Buss <34542414+marvinbuss@users.noreply.github.com> * Update DataManagementAnalytics-ServicePrincipal.md Using the right markdown for notes * Update docs/DataManagementAnalytics-ServicePrincipal.md Co-authored-by: Marvin Buss <34542414+marvinbuss@users.noreply.github.com> --------- Co-authored-by: Marvin Buss <34542414+marvinbuss@users.noreply.github.com> --- docs/DataManagementAnalytics-ServicePrincipal.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/DataManagementAnalytics-ServicePrincipal.md b/docs/DataManagementAnalytics-ServicePrincipal.md index 4270398..da2294d 100644 --- a/docs/DataManagementAnalytics-ServicePrincipal.md +++ b/docs/DataManagementAnalytics-ServicePrincipal.md @@ -32,6 +32,20 @@ This will generate the following JSON output: > **Note:** Take note of the output. It will be required for the next steps. +**Azure PowerShell:** + +```powershell +# Ensure you are in the right subscription +Set-AzContext -Subscription "{SubscriptionId or SubscriptionName}" + +# Create service principal +$sp = New-AzADServicePrincipal -DisplayName {name} +$sp.PasswordCredentials.SecretText +``` +The returned object contains the generated password. Make sure that you store this value somewhere secure to authenticate with the service principal. + +> **Note:** Beginning with Az PowerShell module version 7.x, `New-AzADServicePrincipal` no longer assigns the Contributor role to the service principal by default. Follow steps below to grant it the `Contributor` role. + ## Adding additional role assigments For automation purposes, one more role assignments is required for the service principal.