Skip to content

Commit dbe5b6c

Browse files
committed
Merge pull request #1491 from Nilambari/latestdev
Fix GenerateVpnClient commandlet, remove hardcoded location value
2 parents 33578d4 + 9e1a3e4 commit dbe5b6c

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/ResourceManager/Network/Commands.Network/Common/NetworkClient.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,28 +156,28 @@ public async Task<AzureOperationResponse<string>> GeneratevpnclientpackageWithHt
156156
var result = new AzureOperationResponse<string>();
157157
result.Request = httpRequest;
158158
result.Response = httpResponse;
159-
if (httpResponse.Headers.Contains("x-ms-request-id"))
159+
string locationResultsUrl = string.Empty;
160+
161+
// Retrieve the location from LocationUri
162+
if (httpResponse.Headers.Contains("Location"))
160163
{
161-
result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
164+
locationResultsUrl = httpResponse.Headers.GetValues("Location").FirstOrDefault();
162165
}
163166
else
164167
{
165-
throw new Exception(string.Format("Get-AzureRmVpnClientPackage Operation Failed as no valid status code received in response!"));
168+
throw new Exception(string.Format("Get-AzureRmVpnClientPackage Operation Failed as no valid Location header received in response!"));
166169
}
167170

168-
string operationId = result.RequestId;
171+
if(string.IsNullOrEmpty(locationResultsUrl))
172+
{
173+
throw new Exception(string.Format("Get-AzureRmVpnClientPackage Operation Failed as no valid Location header value received in response!"));
174+
}
169175
#endregion
170176

171177
#region 2. Wait for Async operation to succeed and then Get the content i.e. VPN Client package Url from locationResults
172178
//Microsoft.WindowsAzure.Commands.Utilities.Common.TestMockSupport.Delay(60000);
173179

174180
// 2. Wait for Async operation to succeed
175-
var locationResultsUrl = new Uri(new Uri(baseUrl + (baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Network/" +
176-
"locations/westus.validation/operationResults/{operationId}").ToString();
177-
locationResultsUrl = locationResultsUrl.Replace("{operationId}", Uri.EscapeDataString(operationId));
178-
locationResultsUrl = locationResultsUrl.Replace("{subscriptionId}", Uri.EscapeDataString(NetworkManagementClient.SubscriptionId));
179-
locationResultsUrl += "?" + string.Join("&", string.Format("api-version={0}", Uri.EscapeDataString(apiVersion)));
180-
181181
DateTime startTime = DateTime.UtcNow;
182182
DateTime giveUpAt = DateTime.UtcNow.AddMinutes(3);
183183

0 commit comments

Comments
 (0)