Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Authentication.Abstractions/AzureSubscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public static class Property
Default = "Default",
StorageAccount = "StorageAccount",
Environment = "Environment",
Account = "Account";
Account = "Account",
SubscriptionPolices = "SubscriptionPolices";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,26 @@ public static void SetManagedByTenants(this IAzureSubscription subscription, par
subscription.SetOrAppendProperty(AzureSubscription.Property.ManagedByTenants, tenants);
}

/// <summary>
/// Get the subscription polices associated with this subscription
/// </summary>
/// <param name="subscription">The subscription to check</param>
/// <returns>The subscription polices</returns>
public static string GetSubscriptionPolicies(this IAzureSubscription subscription)
{
return subscription.GetProperty(AzureSubscription.Property.SubscriptionPolices);
}

/// <summary>
/// Set the subscription polices associated with this subscription
/// </summary>
/// <param name="subscription">The subscription to set</param>
/// <param name="subscriptionPolicies">The subscription polices associated with the subscription</param>
public static void SetSubscriptionPolicies(this IAzureSubscription subscription, string subscriptionPolicies)
{
subscription.SetOrAppendProperty(AzureSubscription.Property.SubscriptionPolices, subscriptionPolicies);
}

/// <summary>
/// Copy the properties from the given subscription
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
using Newtonsoft.Json;

namespace Microsoft.Azure.Internal.Subscriptions.Models.Utilities
{
Expand All @@ -29,6 +30,7 @@ public static AzureSubscription ToAzureSubscription(this Subscription other, IAz
subscription.SetEnvironment(environment != null ? environment.Name : EnvironmentName.AzureCloud);
subscription.SetHomeTenant(other.TenantId ?? retrievedByTenant);
subscription.SetTenant(retrievedByTenant);
subscription.SetSubscriptionPolicies(JsonConvert.SerializeObject(other.SubscriptionPolicies));
return subscription;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using System.Linq;
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
using Newtonsoft.Json;

namespace Microsoft.Azure.Management.ResourceManager.Version2019_06_01.Models.Utilities
{
Expand All @@ -34,6 +35,7 @@ public static AzureSubscription ToAzureSubscription(this Subscription other, IAz
subscription.SetManagedByTenants(other.ManagedByTenants.Select(t => t.TenantId).ToArray());
}
subscription.SetTenant(retrievedByTenant);
subscription.SetSubscriptionPolicies(JsonConvert.SerializeObject(other.SubscriptionPolicies));
return subscription;
}
}
Expand Down