Skip to content

Commit 60daabc

Browse files
committed
better way to initialize subscriptionId
1 parent 55f14fa commit 60daabc

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADServicePrincipalCommand.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ public override void ExecuteCmdlet()
251251

252252
private void CreateSimpleServicePrincipal()
253253
{
254+
var subscriptionId = DefaultContext.Subscription?.Id;
254255
if (!this.IsParameterBound(c => c.StartDate))
255256
{
256257
DateTime currentTime = DateTime.UtcNow;
@@ -320,7 +321,6 @@ private void CreateSimpleServicePrincipal()
320321

321322
if (!SkipRoleAssignment())
322323
{
323-
var subscriptionId = DefaultContext.Subscription.Id;
324324
if (!this.IsParameterBound(c => c.Scope))
325325
{
326326
Scope = string.Format("/subscriptions/{0}", subscriptionId);
@@ -350,7 +350,6 @@ private void CreateSimpleServicePrincipal()
350350
return;
351351
}
352352

353-
var subscriptionId = DefaultContext.Subscription.Id;
354353
WriteWarning(string.Format("Assigning role '{0}' over scope '{1}' to the new service principal.", this.Role, this.Scope));
355354
FilterRoleAssignmentsOptions parameters = new FilterRoleAssignmentsOptions()
356355
{

0 commit comments

Comments
 (0)