Skip to content

Commit 93b9c68

Browse files
author
Hovsep
committed
Merge pull request Azure#1089 from ogail/release-1.0.0-preview
Support SM/RM cmdlets execution with RP registration
2 parents eb56c84 + 7172ad5 commit 93b9c68

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/ResourceManager/Common/Commands.ResourceManager.Common/AzureRMCmdlet.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,16 @@ static AzureRMCmdlet()
4343
}
4444
}
4545

46+
/// <summary>
47+
/// Creates new instance from AzureRMCmdlet and add the RPRegistration handler.
48+
/// </summary>
4649
public AzureRMCmdlet()
4750
{
4851
AzureSession.ClientFactory.RemoveHandler(typeof(RPRegistrationDelegatingHandler));
4952
AzureSession.ClientFactory.AddHandler(new RPRegistrationDelegatingHandler(
50-
() => AzureSession.ClientFactory.CreateClient<ResourceManagementClient>(DefaultContext, AzureEnvironment.Endpoint.ResourceManager),
53+
() => new ResourceManagementClient(
54+
AzureSession.AuthenticationFactory.GetSubscriptionCloudCredentials(DefaultContext, AzureEnvironment.Endpoint.ResourceManager),
55+
DefaultContext.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager)),
5156
s => _debugMessages.Enqueue(s)));
5257
}
5358

src/ResourceManager/Common/Commands.ResourceManager.Common/RPRegistrationDelegatingHandler.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ public RPRegistrationDelegatingHandler(Func<ResourceManagementClient> createClie
4848

4949
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
5050
{
51-
ResourceManagementClient = createClient();
52-
5351
HttpResponseMessage responseMessage = await base.SendAsync(request, cancellationToken).ConfigureAwait(false);
5452
if (IsProviderNotRegistereError(responseMessage))
5553
{
@@ -61,6 +59,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
6159
registeredProviders.Add(providerName);
6260
try
6361
{
62+
ResourceManagementClient = createClient();
6463
writeDebug(string.Format(Resources.ResourceProviderRegisterAttempt, providerName));
6564
ResourceManagementClient.Providers.Register(providerName);
6665
Provider provider = null;

0 commit comments

Comments
 (0)