Skip to content

Commit 662d4c3

Browse files
authored
Enable service client to set max retry-after times (#258)
* Enable service client to set max retry-after times after it is created by CreateCustomArmClient * Add property names to AzureAccount to support new cetrificate authentication method * Address review comments
1 parent cd14866 commit 662d4c3

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

src/Authentication.Abstractions/AzureAccount.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,24 @@ public static class Property
148148
/// <summary>
149149
/// Secret that may be used with service principal login
150150
/// </summary>
151-
ServicePrincipalSecret = "ServicePrincipalSecret";
151+
ServicePrincipalSecret = "ServicePrincipalSecret",
152+
153+
154+
/// <summary>
155+
/// The path of certficate file in pem or pkcs#12 format
156+
/// </summary>
157+
CertificatePath = "CertificatePath",
158+
159+
/// <summary>
160+
/// The password required to access the pkcs#12 certificate file
161+
/// </summary>
162+
CertificatePassword = "CertificatePassword",
163+
164+
165+
/// <summary>
166+
/// Specifies if the x5c claim (public key of the certificate) should be sent to the STS to achieve easy certificate rollover in Azure AD
167+
/// </summary>
168+
SendCertificateChain = "SendCertificateChain";
152169
}
153170
}
154171
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
17+
namespace Microsoft.Azure.Commands.Common.Authentication.Abstractions
18+
{
19+
public static class ServiceClientExtension
20+
{
21+
/// <summary>
22+
/// Set max retry times of retry after handler that is used to handle the response with retry-after header
23+
/// </summary>
24+
/// <param name="retrytimes">Max retry times</param>
25+
/// <returns>Whether succeed to set max retry times or not</returns>
26+
public static bool SetMaxTimesForRetryAfterHandler<TClient>(this Microsoft.Rest.ServiceClient<TClient> serviceClient, uint retrytimes) where TClient : Microsoft.Rest.ServiceClient<TClient>
27+
{
28+
bool findRetryHandler = false;
29+
foreach(var handler in serviceClient.HttpMessageHandlers)
30+
{
31+
var retryHandler = handler as Microsoft.Rest.RetryAfterDelegatingHandler;
32+
if (retryHandler != null)
33+
{
34+
retryHandler.MaxRetries = Convert.ToInt32(retrytimes);
35+
findRetryHandler = true;
36+
}
37+
}
38+
return findRetryHandler;
39+
}
40+
}
41+
}

src/Dependencies.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
99
</ItemGroup>
1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.20" />
11+
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.23" />
1212
</ItemGroup>
1313
<ItemGroup Condition="'$(IncludeHyak)' == 'true'">
1414
<PackageReference Include="Microsoft.Azure.Common" Version="2.2.1" />

0 commit comments

Comments
 (0)