Skip to content

Commit 47b4a06

Browse files
committed
Revised
1 parent 6f03bad commit 47b4a06

File tree

3 files changed

+83
-156
lines changed

3 files changed

+83
-156
lines changed

articles/key-vault/key-vault-ovw-throttling.md

Lines changed: 13 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -61,97 +61,24 @@ When you implement your app's error handling, use the HTTP error code 429 to det
6161

6262
Code that implements exponential backoff is shown below.
6363
```
64-
public sealed class RetryWithExponentialBackoff
64+
SecretClientOptions options = new SecretClientOptions()
6565
{
66-
private readonly int maxRetries, delayMilliseconds, maxDelayMilliseconds;
67-
68-
public RetryWithExponentialBackoff(int maxRetries = 50,
69-
int delayMilliseconds = 200,
70-
int maxDelayMilliseconds = 2000)
71-
{
72-
this.maxRetries = maxRetries;
73-
this.delayMilliseconds = delayMilliseconds;
74-
this.maxDelayMilliseconds = maxDelayMilliseconds;
75-
}
76-
77-
public async Task RunAsync(Func<Task> func)
78-
{
79-
ExponentialBackoff backoff = new ExponentialBackoff(this.maxRetries,
80-
this.delayMilliseconds,
81-
this.maxDelayMilliseconds);
82-
retry:
83-
try
84-
{
85-
await func();
86-
}
87-
catch (Exception ex) when (ex is TimeoutException ||
88-
ex is System.Net.Http.HttpRequestException)
89-
{
90-
Debug.WriteLine("Exception raised is: " +
91-
ex.GetType().ToString() +
92-
" –Message: " + ex.Message +
93-
" -- Inner Message: " +
94-
ex.InnerException.Message);
95-
await backoff.Delay();
96-
goto retry;
97-
}
98-
}
99-
}
100-
101-
public struct ExponentialBackoff
102-
{
103-
private readonly int m_maxRetries, m_delayMilliseconds, m_maxDelayMilliseconds;
104-
private int m_retries, m_pow;
105-
106-
public ExponentialBackoff(int maxRetries, int delayMilliseconds,
107-
int maxDelayMilliseconds)
66+
Retry =
10867
{
109-
m_maxRetries = maxRetries;
110-
m_delayMilliseconds = delayMilliseconds;
111-
m_maxDelayMilliseconds = maxDelayMilliseconds;
112-
m_retries = 0;
113-
m_pow = 1;
114-
}
115-
116-
public Task Delay()
117-
{
118-
if (m_retries == m_maxRetries)
119-
{
120-
throw new TimeoutException("Max retry attempts exceeded.");
121-
}
122-
++m_retries;
123-
if (m_retries < 31)
124-
{
125-
m_pow = m_pow << 1; // m_pow = Pow(2, m_retries - 1)
126-
}
127-
int delay = Math.Min(m_delayMilliseconds * (m_pow - 1) / 2,
128-
m_maxDelayMilliseconds);
129-
return Task.Delay(delay);
130-
}
131-
}
68+
Delay= TimeSpan.FromSeconds(2),
69+
MaxDelay = TimeSpan.FromSeconds(16),
70+
MaxRetries = 5,
71+
Mode = RetryMode.Exponential
72+
}
73+
};
74+
var client = new SecretClient(new Uri(https://keyVaultName.vault.azure.net"), new DefaultAzureCredential(),options);
75+
76+
//Retrieve Secret
77+
secret = client.GetSecret(secretName);
13278
```
13379

13480

135-
Using this code in a client C\# application is straightforward. The following example shows how, using the HttpClient class.
136-
137-
```csharp
138-
public async Task<Cart> GetCartItems(int page)
139-
{
140-
_apiClient = new HttpClient();
141-
//
142-
// Using HttpClient with Retry and Exponential Backoff
143-
//
144-
var retry = new RetryWithExponentialBackoff();
145-
await retry.RunAsync(async () =>
146-
{
147-
// work with HttpClient call
148-
dataString = await _apiClient.GetStringAsync(catalogUrl);
149-
});
150-
return JsonConvert.DeserializeObject<Cart>(dataString);
151-
}
152-
```
153-
154-
Remember that this code is suitable only as a proof of concept.
81+
Using this code in a client C# application is straightforward.
15582

15683
### Recommended client-side throttling method
15784

articles/virtual-machines/extensions/key-vault-linux.md

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,20 @@ The following JSON shows the schema for the Key Vault VM extension. The extensio
3737
"[concat('Microsoft.Compute/virtualMachines/', <vmName>)]"
3838
],
3939
"properties": {
40-
"publisher": "Microsoft.Azure.KeyVault",
41-
"type": "KeyVaultForLinux",
42-
"typeHandlerVersion": "1.0",
43-
"autoUpgradeMinorVersion": true,
44-
"settings": {
45-
"secretsManagementSettings": {
46-
"pollingIntervalInS": <polling interval in seconds, e.g. "3600">,
47-
"certificateStoreName": <certificate store name, e.g.: "MY">,
48-
"linkOnRenewal": <Not available on Linux e.g.: false>,
49-
"certificateStoreLocation": <certificate store location, currently it works locally only e.g.: "LocalMachine">,
50-
"requireInitialSync": <initial synchronization of certificates e..g: true>,
51-
"observedCertificates": <list of KeyVault URIs representing monitored certificates, e.g.: "https://myvault.vault.azure.net/secrets/mycertificate"
52-
}
53-
}
40+
"publisher": "Microsoft.Azure.KeyVault",
41+
"type": "KeyVaultForLinux",
42+
"typeHandlerVersion": "1.0",
43+
"autoUpgradeMinorVersion": true,
44+
"settings": {
45+
"secretsManagementSettings": {
46+
"pollingIntervalInS": <polling interval in seconds, e.g. "3600">,
47+
"certificateStoreName": <certificate store name, e.g.: "MY">,
48+
"linkOnRenewal": <Not available on Linux e.g.: false>,
49+
"certificateStoreLocation": <certificate store location, currently it works locally only e.g.: "LocalMachine">,
50+
"requireInitialSync": <initial synchronization of certificates e..g: true>,
51+
"observedCertificates": <list of KeyVault URIs representing monitored certificates, e.g.: "https://myvault.vault.azure.net/secrets/mycertificate"
52+
}
53+
}
5454
}
5555
}
5656
```
@@ -93,17 +93,17 @@ The JSON configuration for a virtual machine extension must be nested inside the
9393
"[concat('Microsoft.Compute/virtualMachines/', <vmName>)]"
9494
],
9595
"properties": {
96-
"publisher": "Microsoft.Azure.KeyVault",
97-
"type": "KeyVaultForLinux",
98-
"typeHandlerVersion": "1.0",
99-
"autoUpgradeMinorVersion": true,
100-
"settings": {
101-
"pollingIntervalInS": <polling interval in seconds, e.g. "3600">,
102-
"certificateStoreName": <certificate store name, e.g.: "MY">,
103-
"certificateStoreLocation": <certificate store location, currently it works locally only e.g.: "LocalMachine">,
104-
"observedCertificates": <list of KeyVault URIs representing monitored certificates, e.g.: "https://myvault.vault.azure.net/secrets/mycertificate"
105-
}
106-
}
96+
"publisher": "Microsoft.Azure.KeyVault",
97+
"type": "KeyVaultForLinux",
98+
"typeHandlerVersion": "1.0",
99+
"autoUpgradeMinorVersion": true,
100+
"settings": {
101+
"pollingIntervalInS": <polling interval in seconds, e.g. "3600">,
102+
"certificateStoreName": <certificate store name, e.g.: "MY">,
103+
"certificateStoreLocation": <certificate store location, currently it works locally only e.g.: "LocalMachine">,
104+
"observedCertificates": <list of KeyVault URIs representing monitored certificates, e.g.: "https://myvault.vault.azure.net/secrets/mycertificate"
105+
}
106+
}
107107
}
108108
}
109109
```
@@ -118,10 +118,10 @@ The Azure PowerShell can be used to deploy the Key Vault VM extension to an exis
118118
```powershell
119119
# Build settings
120120
$settings = '{"secretsManagementSettings":
121-
{ "pollingIntervalInS": "' + <pollingInterval> +
122-
'", "certificateStoreName": "' + <certStoreName> +
123-
'", "certificateStoreLocation": "' + <certStoreLoc> +
124-
'", "observedCertificates": ["' + <observedCerts> + '"] } }'
121+
{ "pollingIntervalInS": "' + <pollingInterval> +
122+
'", "certificateStoreName": "' + <certStoreName> +
123+
'", "certificateStoreLocation": "' + <certStoreLoc> +
124+
'", "observedCertificates": ["' + <observedCerts> + '"] } }'
125125
$extName = "KeyVaultForLinux"
126126
$extPublisher = "Microsoft.Azure.KeyVault"
127127
$extType = "KeyVaultForLinux"
@@ -138,10 +138,10 @@ The Azure PowerShell can be used to deploy the Key Vault VM extension to an exis
138138
139139
# Build settings
140140
$settings = '{"secretsManagementSettings":
141-
{ "pollingIntervalInS": "' + <pollingInterval> +
142-
'", "certificateStoreName": "' + <certStoreName> +
143-
'", "certificateStoreLocation": "' + <certStoreLoc> +
144-
'", "observedCertificates": ["' + <observedCerts> + '"] } }'
141+
{ "pollingIntervalInS": "' + <pollingInterval> +
142+
'", "certificateStoreName": "' + <certStoreName> +
143+
'", "certificateStoreLocation": "' + <certStoreLoc> +
144+
'", "observedCertificates": ["' + <observedCerts> + '"] } }'
145145
$extName = "KeyVaultForLinux"
146146
$extPublisher = "Microsoft.Azure.KeyVault"
147147
$extType = "KeyVaultForLinux"
@@ -183,8 +183,8 @@ The Azure CLI can be used to deploy the Key Vault VM extension to an existing vi
183183
184184
Please be aware of the following restrictions/requirements:
185185
- Key Vault restrictions:
186-
- It must exist at the time of the deployment
187-
- Key Vault Access Policy is set for VM/VMSS Identity using MSI
186+
- It must exist at the time of the deployment
187+
- Key Vault Access Policy is set for VM/VMSS Identity using MSI
188188
189189
190190
## Troubleshoot and support

articles/virtual-machines/extensions/key-vault-windows.md

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,20 @@ The following JSON shows the schema for the Key Vault VM extension. The extensio
3737
"[concat('Microsoft.Compute/virtualMachines/', <vmName>)]"
3838
],
3939
"properties": {
40-
"publisher": "Microsoft.Azure.KeyVault",
41-
"type": "KeyVaultForWindows",
42-
"typeHandlerVersion": "1.0",
43-
"autoUpgradeMinorVersion": true,
44-
"settings": {
45-
"secretsManagementSettings": {
46-
"pollingIntervalInS": <polling interval in seconds, e.g: "3600">,
47-
"certificateStoreName": <certificate store name, e.g.: "MY">,
48-
"linkOnRenewal": <Only Windows. This feature enables auto-rotation of SSL certificates, without necessitating a re-deployment or binding. e.g.: false>,
49-
"certificateStoreLocation": <certificate store location, currently it works locally only e.g.: "LocalMachine">,
50-
"requireInitialSync": <initial synchronization of certificates e..g: true>,
51-
"observedCertificates": <list of KeyVault URIs representing monitored certificates, e.g.: "https://myvault.vault.azure.net/secrets/mycertificate"
52-
}
53-
}
40+
"publisher": "Microsoft.Azure.KeyVault",
41+
"type": "KeyVaultForWindows",
42+
"typeHandlerVersion": "1.0",
43+
"autoUpgradeMinorVersion": true,
44+
"settings": {
45+
"secretsManagementSettings": {
46+
"pollingIntervalInS": <polling interval in seconds, e.g: "3600">,
47+
"certificateStoreName": <certificate store name, e.g.: "MY">,
48+
"linkOnRenewal": <Only Windows. This feature enables auto-rotation of SSL certificates, without necessitating a re-deployment or binding. e.g.: false>,
49+
"certificateStoreLocation": <certificate store location, currently it works locally only e.g.: "LocalMachine">,
50+
"requireInitialSync": <initial synchronization of certificates e..g: true>,
51+
"observedCertificates": <list of KeyVault URIs representing monitored certificates, e.g.: "https://myvault.vault.azure.net/secrets/mycertificate"
52+
}
53+
}
5454
}
5555
}
5656
```
@@ -92,17 +92,17 @@ The JSON configuration for a virtual machine extension must be nested inside the
9292
"[concat('Microsoft.Compute/virtualMachines/', <vmName>)]"
9393
],
9494
"properties": {
95-
"publisher": "Microsoft.Azure.KeyVault",
96-
"type": "KeyVaultForWindows",
97-
"typeHandlerVersion": "1.0",
98-
"autoUpgradeMinorVersion": true,
99-
"settings": {
100-
"pollingIntervalInS": <polling interval in seconds, e.g: "3600">,
101-
"certificateStoreName": <certificate store name, e.g.: "MY">,
102-
"certificateStoreLocation": <certificate store location, currently it works locally only e.g.: "LocalMachine">,
103-
"observedCertificates": <list of KeyVault URIs representing monitored certificates, e.g.: "https://myvault.vault.azure.net/secrets/mycertificate"
104-
}
105-
}
95+
"publisher": "Microsoft.Azure.KeyVault",
96+
"type": "KeyVaultForWindows",
97+
"typeHandlerVersion": "1.0",
98+
"autoUpgradeMinorVersion": true,
99+
"settings": {
100+
"pollingIntervalInS": <polling interval in seconds, e.g: "3600">,
101+
"certificateStoreName": <certificate store name, e.g.: "MY">,
102+
"certificateStoreLocation": <certificate store location, currently it works locally only e.g.: "LocalMachine">,
103+
"observedCertificates": <list of KeyVault URIs representing monitored certificates, e.g.: "https://myvault.vault.azure.net/secrets/mycertificate"
104+
}
105+
}
106106
}
107107
}
108108
```
@@ -117,10 +117,10 @@ The Azure PowerShell can be used to deploy the Key Vault VM extension to an exis
117117
```powershell
118118
# Build settings
119119
$settings = '{"secretsManagementSettings":
120-
{ "pollingIntervalInS": "' + <pollingInterval> +
121-
'", "certificateStoreName": "' + <certStoreName> +
122-
'", "certificateStoreLocation": "' + <certStoreLoc> +
123-
'", "observedCertificates": ["' + <observedCerts> + '"] } }'
120+
{ "pollingIntervalInS": "' + <pollingInterval> +
121+
'", "certificateStoreName": "' + <certStoreName> +
122+
'", "certificateStoreLocation": "' + <certStoreLoc> +
123+
'", "observedCertificates": ["' + <observedCerts> + '"] } }'
124124
$extName = "KeyVaultForWindows"
125125
$extPublisher = "Microsoft.Azure.KeyVault"
126126
$extType = "KeyVaultForWindows"
@@ -137,10 +137,10 @@ The Azure PowerShell can be used to deploy the Key Vault VM extension to an exis
137137
138138
# Build settings
139139
$settings = '{"secretsManagementSettings":
140-
{ "pollingIntervalInS": "' + <pollingInterval> +
141-
'", "certificateStoreName": "' + <certStoreName> +
142-
'", "certificateStoreLocation": "' + <certStoreLoc> +
143-
'", "observedCertificates": ["' + <observedCerts> + '"] } }'
140+
{ "pollingIntervalInS": "' + <pollingInterval> +
141+
'", "certificateStoreName": "' + <certStoreName> +
142+
'", "certificateStoreLocation": "' + <certStoreLoc> +
143+
'", "observedCertificates": ["' + <observedCerts> + '"] } }'
144144
$extName = "KeyVaultForWindows"
145145
$extPublisher = "Microsoft.Azure.KeyVault"
146146
$extType = "KeyVaultForWindows"
@@ -182,8 +182,8 @@ The Azure CLI can be used to deploy the Key Vault VM extension to an existing vi
182182
183183
Please be aware of the following restrictions/requirements:
184184
- Key Vault restrictions:
185-
- It must exist at the time of the deployment
186-
- Key Vault Access Policy is set for VM/VMSS Identity using MSI
185+
- It must exist at the time of the deployment
186+
- Key Vault Access Policy is set for VM/VMSS Identity using MSI
187187
188188
189189
## Troubleshoot and support

0 commit comments

Comments
 (0)