diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmClient.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmClient.cs
index 3c0c9c409814..52f3951d956e 100644
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmClient.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmClient.cs
@@ -92,10 +92,10 @@ public ArmClient(
ClientOptions = options?.Clone() ?? new ArmClientOptions();
Pipeline = ManagementPipelineBuilder.Build(Credential, BaseUri, options ?? ClientOptions);
+ _tenant = new TenantOperations(ClientOptions, Credential, BaseUri, Pipeline);
DefaultSubscription = string.IsNullOrWhiteSpace(defaultSubscriptionId)
? GetDefaultSubscription()
: GetSubscriptions().TryGet(defaultSubscriptionId);
- _tenant = new TenantOperations(ClientOptions, Credential, BaseUri, Pipeline);
ClientOptions.ApiVersions.SetProviderClient(this);
}
@@ -128,10 +128,7 @@ public ArmClient(
/// Gets the Azure subscriptions.
///
/// Subscription container.
- public virtual SubscriptionContainer GetSubscriptions()
- {
- return new SubscriptionContainer(new ClientContext(ClientOptions, Credential, BaseUri, Pipeline));
- }
+ public virtual SubscriptionContainer GetSubscriptions() => _tenant.GetSubscriptions();
///
/// Gets the tenants.
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/FeatureContainer.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/FeatureContainer.cs
index 3af480a13d37..55524eb9d14b 100644
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/FeatureContainer.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/FeatureContainer.cs
@@ -36,6 +36,11 @@ internal FeatureContainer(ProviderOperations parent)
_restClient = new FeaturesRestOperations(_clientDiagnostics, Pipeline, Id.SubscriptionId, BaseUri);
}
+ ///
+ /// Gets the parent resource of this resource.
+ ///
+ protected new ProviderOperations Parent { get {return base.Parent as ProviderOperations;} }
+
///
protected override ResourceType ValidResourceType => ProviderOperations.ResourceType;
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/ManagementGroup/ManagementGroupContainer.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/ManagementGroup/ManagementGroupContainer.cs
index d3a28e5d9cbb..fda384bc1988 100644
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/ManagementGroup/ManagementGroupContainer.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/ManagementGroup/ManagementGroupContainer.cs
@@ -36,6 +36,11 @@ internal ManagementGroupContainer(TenantOperations tenant)
_restClient = new ManagementGroupsRestOperations(_clientDiagnostics, Pipeline, BaseUri);
}
+ ///
+ /// Gets the parent resource of this resource.
+ ///
+ protected new TenantOperations Parent { get {return base.Parent as TenantOperations;} }
+
///
protected override ResourceType ValidResourceType => TenantOperations.ResourceType;
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/ResourceGroupContainer.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/ResourceGroupContainer.cs
index 7f802cbf595c..82641cd5c307 100644
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/ResourceGroupContainer.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/ResourceGroupContainer.cs
@@ -34,6 +34,11 @@ internal ResourceGroupContainer(SubscriptionOperations subscription)
///
protected override ResourceType ValidResourceType => SubscriptionOperations.ResourceType;
+ ///
+ /// Gets the parent resource of this resource.
+ ///
+ protected new SubscriptionOperations Parent { get {return base.Parent as SubscriptionOperations;} }
+
private ResourceGroupsRestOperations RestClient
{
get
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/SubscriptionContainer.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/SubscriptionContainer.cs
index b05d63e4bb4c..59baae3a13f4 100644
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/SubscriptionContainer.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/SubscriptionContainer.cs
@@ -24,17 +24,22 @@ protected SubscriptionContainer()
///
/// Initializes a new instance of the class.
///
- ///
- internal SubscriptionContainer(ClientContext clientContext)
- : base(clientContext, null)
+ /// The resource representing the parent resource.
+ internal SubscriptionContainer(TenantOperations parent)
+ : base(parent)
{
RestClient = new SubscriptionsRestOperations(this.Diagnostics, this.Pipeline, this.BaseUri);
}
+ ///
+ /// Gets the parent resource of this resource.
+ ///
+ protected new TenantOperations Parent { get {return base.Parent as TenantOperations;} }
+
///
/// Gets the valid resource type associated with the container.
///
- protected override ResourceType ValidResourceType => SubscriptionOperations.ResourceType;
+ protected override ResourceType ValidResourceType => TenantOperations.ResourceType;
///
/// Gets the operations that can be performed on the container.
@@ -125,16 +130,6 @@ async Task> NextPageFunc(string nextLink, int? pageSizeHint)
return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
}
- ///
- /// Validate the resource identifier is supported in the current container.
- ///
- /// The identifier of the resource.
- protected override void Validate(ResourceIdentifier identifier)
- {
- if (!(identifier is null))
- throw new ArgumentException("Invalid parent for subscription container", nameof(identifier));
- }
-
///
/// Gets details for this subscription from the service.
///
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/TenantOperations.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/TenantOperations.cs
index 52eedd63b4f2..59c0c1062aae 100644
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/TenantOperations.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/TenantOperations.cs
@@ -213,5 +213,14 @@ internal ManagementGroupOperations GetManagementGroupOperations(string id)
{
return new ManagementGroupOperations(this, id);
}
+
+ ///
+ /// Gets the subscription container for this tenant.
+ ///
+ /// A container of the subscriptions.
+ public virtual SubscriptionContainer GetSubscriptions()
+ {
+ return new SubscriptionContainer(this);
+ }
}
}
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceContainerBase.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceContainerBase.cs
index 2c5cc755bedd..d98446118dcc 100644
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceContainerBase.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceContainerBase.cs
@@ -48,11 +48,6 @@ protected ResourceContainerBase(OperationsBase parent)
{
}
- ///
- /// Gets the parent resource of this resource.
- ///
- protected new ResourceOperationsBase Parent { get {return base.Parent as ResourceOperationsBase;} }
-
///
/// Verify that the input resource Id is a valid container for this type.
///