Skip to content

Commit 26d6b16

Browse files
authored
Merge pull request Azure#3109 from pragupta-ms/dev
Adding Azure Session user agent to Publish-AzureWebsiteProject Command
2 parents da95b28 + 317a228 commit 26d6b16

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/ServiceManagement/Services/Commands.Utilities/Websites/WebsitesClient.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,10 +1360,45 @@ private DeploymentBaseOptions CreateRemoteDeploymentBaseOptions(string websiteNa
13601360
AuthenticationType = "Basic",
13611361
TempAgent = false
13621362
};
1363+
1364+
var userAgent = GetDeploymentBaseOptionsUserAgent();
1365+
if (!string.IsNullOrEmpty(userAgent))
1366+
{
1367+
remoteBaseOptions.UserAgent = userAgent;
1368+
}
13631369

13641370
return remoteBaseOptions;
13651371
}
13661372

1373+
/// <summary>
1374+
/// Gets remote deployment base options useragent using AzureSession/WebSiteManagementClient.
1375+
/// </summary>
1376+
/// <returns>useragent string.</returns>
1377+
private string GetDeploymentBaseOptionsUserAgent()
1378+
{
1379+
var userAgent = string.Empty;
1380+
var managementClient = this.WebsiteManagementClient as WebSiteManagementClient;
1381+
if (managementClient != null && managementClient.UserAgent != null)
1382+
{
1383+
foreach (var agent in managementClient.UserAgent)
1384+
{
1385+
if (agent != null && agent.Product != null && !string.IsNullOrEmpty(agent.Product.Name))
1386+
{
1387+
if (!string.IsNullOrEmpty(agent.Product.Version))
1388+
{
1389+
userAgent = string.Concat(userAgent, agent.Product.Name, "/", agent.Product.Version, " ");
1390+
}
1391+
else
1392+
{
1393+
userAgent = string.Concat(userAgent, agent.Product.Name, " ");
1394+
}
1395+
}
1396+
}
1397+
}
1398+
1399+
return userAgent.TrimEnd();
1400+
}
1401+
13671402
/// <summary>
13681403
/// Replace all the connection strings in the deployment.
13691404
/// </summary>

0 commit comments

Comments
 (0)