Skip to content

Commit 2a9db46

Browse files
authored
Adding Azure Session user agent to Publish-AzureWebsiteProject Command
1 parent 43dd149 commit 2a9db46

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

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

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

13641370
return remoteBaseOptions;
13651371
}
1372+
1373+
/// <summary>
1374+
/// Gets user agent for azure session
1375+
/// </summary>
1376+
/// <returns>useragent string </returns>
1377+
private string GetUserAgentForAzureSession()
1378+
{
1379+
var userAgent = string.Empty;
1380+
if (AzureSession.ClientFactory.UserAgents != null)
1381+
{
1382+
foreach (var agent in AzureSession.ClientFactory.UserAgents)
1383+
{
1384+
if (agent != null && agent.Product != null && !string.IsNullOrEmpty(agent.Product.Name))
1385+
{
1386+
if (!string.IsNullOrEmpty(agent.Product.Version))
1387+
{
1388+
userAgent = string.Concat(userAgent, agent.Product.Name, "/", agent.Product.Version, " ");
1389+
}
1390+
else
1391+
{
1392+
userAgent = string.Concat(userAgent, agent.Product.Name, " ");
1393+
}
1394+
}
1395+
}
1396+
}
1397+
1398+
return userAgent.TrimEnd();
1399+
}
13661400

13671401
/// <summary>
13681402
/// Replace all the connection strings in the deployment.

0 commit comments

Comments
 (0)