|
20 | 20 | using System.Linq;
|
21 | 21 | using System.Net;
|
22 | 22 | using System.Net.Http;
|
| 23 | +using System.Net.Http.Headers; |
23 | 24 | using System.Web;
|
24 | 25 | using System.Xml.Linq;
|
25 | 26 | using Microsoft.Build.Evaluation;
|
@@ -1361,25 +1362,30 @@ private DeploymentBaseOptions CreateRemoteDeploymentBaseOptions(string websiteNa
|
1361 | 1362 | TempAgent = false
|
1362 | 1363 | };
|
1363 | 1364 |
|
1364 |
| - var azureSessionUserAgent = GetUserAgentForAzureSession(); |
| 1365 | + var azureSessionUserAgent = GetDeploymentBaseOptionsUserAgent(); |
1365 | 1366 | if (!string.IsNullOrEmpty(azureSessionUserAgent))
|
1366 | 1367 | {
|
1367 | 1368 | remoteBaseOptions.UserAgent = azureSessionUserAgent;
|
1368 | 1369 | }
|
1369 | 1370 |
|
1370 | 1371 | return remoteBaseOptions;
|
1371 | 1372 | }
|
1372 |
| - |
| 1373 | + |
1373 | 1374 | /// <summary>
|
1374 |
| - /// Gets user agent for azure session |
| 1375 | + /// Gets remote deployment base options useragent using AzureSession/WebSiteManagementClient. |
1375 | 1376 | /// </summary>
|
1376 |
| - /// <returns>useragent string </returns> |
1377 |
| - private string GetUserAgentForAzureSession() |
| 1377 | + /// <returns>useragent string.</returns> |
| 1378 | + private string GetDeploymentBaseOptionsUserAgent() |
1378 | 1379 | {
|
1379 | 1380 | var userAgent = string.Empty;
|
1380 |
| - if (AzureSession.ClientFactory.UserAgents != null) |
| 1381 | + var managementClient = this.WebsiteManagementClient as WebSiteManagementClient; |
| 1382 | + var userAgents = AzureSession.ClientFactory.UserAgents.Any() |
| 1383 | + ? AzureSession.ClientFactory.UserAgents as IEnumerable<ProductInfoHeaderValue> |
| 1384 | + : (managementClient != null) ? managementClient.UserAgent : null; |
| 1385 | + |
| 1386 | + if (userAgents != null) |
1381 | 1387 | {
|
1382 |
| - foreach (var agent in AzureSession.ClientFactory.UserAgents) |
| 1388 | + foreach (var agent in userAgents) |
1383 | 1389 | {
|
1384 | 1390 | if (agent != null && agent.Product != null && !string.IsNullOrEmpty(agent.Product.Name))
|
1385 | 1391 | {
|
|
0 commit comments