Proxy Settings when using OMS Agent VM Extension via ARM template

%3CLINGO-SUB%20id%3D%22lingo-sub-313692%22%20slang%3D%22en-US%22%3EProxy%20Settings%20when%20using%20OMS%20Agent%20VM%20Extension%20via%20ARM%20template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-313692%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20all%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20adding%20the%20Monitoring%20Agent%20using%20a%20VM%20extension%20in%20an%20ARM%20template%2C%20using%20the%20following%20code.%20My%20question%20is%20whether%20it's%20possible%20to%20specify%20authentication%20details%20in%20the%20template%20code%20so%20that%20the%20agent%20can%20authenticate%20to%20the%20proxy%20server.%20Is%20this%20possible%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%22properties%22%3A%20%7B%3CBR%20%2F%3E%22publisher%22%3A%20%22Microsoft.EnterpriseCloud.Monitoring%22%2C%3CBR%20%2F%3E%22type%22%3A%20%22MicrosoftMonitoringAgent%22%2C%3CBR%20%2F%3E%22typeHandlerVersion%22%3A%20%221.0%22%2C%3CBR%20%2F%3E%22autoUpgradeMinorVersion%22%3A%20true%2C%3CBR%20%2F%3E%22settings%22%3A%20%7B%3CBR%20%2F%3E%22workspaceId%22%3A%20%22%5Bparameters('omsworkspaceid')%5D%22%2C%3CBR%20%2F%3E%22proxyUri%22%3A%20%22proxy%3A8080%22%3CBR%20%2F%3E%7D%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-313692%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Earm%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ETemplate%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1191434%22%20slang%3D%22en-US%22%3ERe%3A%20Proxy%20Settings%20when%20using%20OMS%20Agent%20VM%20Extension%20via%20ARM%20template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1191434%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F263930%22%20target%3D%22_blank%22%3E%40Vinoth_Azure%3C%2FA%3E%26nbsp%3BIt's%20really%20cool%20to%20get%20the%20proxyUri%20settings%20in%20ARM.%20It%20works%20for%20me%20on%20Windows%20but%20when%20I%20try%20it%20with%20linux%20version%20(type%20%3D%20%22OmsAgentForLinux%22)%20it%20always%20fail%20with%20this%20error.%20Do%20you%20know%20if%20this%20parameter%20is%20supported%20on%20Linux%20version%20of%20the%26nbsp%3BMicrosoft.EnterpriseCloud.Monitoring%20extension%3F%3CBR%20%2F%3E%3CBR%20%2F%3E%22code%22%3A%20%22VMExtensionProvisioningError%22%2C%3CBR%20%2F%3E%22message%22%3A%20%22VM%20has%20reported%20a%20failure%20when%20processing%20extension%20'LogAnalytics-Agent-Extension'.%20Error%20message%3A%3CBR%20%2F%3E%5C%22Enable%20failed%20with%20exit%20code%2053%20Installation%20failed%20due%20to%20incorrect%20workspace%20key.%20Please%20check%20if%20the%20workspace%3CBR%20%2F%3Ekey%20is%20correct.%20For%20details%2C%20check%20logs%20in%3CBR%20%2F%3E%2Fvar%2Flog%2Fazure%2FMicrosoft.EnterpriseCloud.Monitoring.OmsAgentForLinux%2Fextension.log%5C%22%5Cr%5Cn%5Cr%5CnMore%20information%20on%3CBR%20%2F%3Etroubleshooting%20is%20available%20at%20%3CA%20href%3D%22https%3A%2F%2Faka.ms%2FVMExtensionOMSAgentLinuxTroubleshoot%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Faka.ms%2FVMExtensionOMSAgentLinuxTroubleshoot%3C%2FA%3E%20%22%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-314439%22%20slang%3D%22en-US%22%3ERe%3A%20Proxy%20Settings%20when%20using%20OMS%20Agent%20VM%20Extension%20via%20ARM%20template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-314439%22%20slang%3D%22en-US%22%3ETo%20configure%20proxy%20settings%20for%20the%20Microsoft%20Monitoring%20Agent%20using%20Control%20Panel%3CBR%20%2F%3E%3CBR%20%2F%3EOpen%20Control%20Panel.%3CBR%20%2F%3E%3CBR%20%2F%3EOpen%20Microsoft%20Monitoring%20Agent.%3CBR%20%2F%3E%3CBR%20%2F%3EClick%20the%20Proxy%20Settings%20tab.%3CBR%20%2F%3Eproxy%20settings%20tab%3CBR%20%2F%3E%3CBR%20%2F%3ESelect%20Use%20a%20proxy%20server%20and%20type%20the%20URL%20and%20port%20number%2C%20if%20one%20is%20needed%2C%20similar%20to%20the%20example%20shown.%20If%20your%20proxy%20server%20requires%20authentication%2C%20type%20the%20username%20and%20password%20to%20access%20the%20proxy%20server.%3CBR%20%2F%3E%3CBR%20%2F%3EUse%20the%20following%20procedure%20to%20create%20a%20PowerShell%20script%20that%20you%20can%20run%20to%20set%20the%20proxy%20settings%20for%20each%20agent%20that%20connects%20directly%20to%20servers.%3CBR%20%2F%3E%3CBR%20%2F%3ETo%20configure%20proxy%20settings%20for%20the%20Microsoft%20Monitoring%20Agent%20using%20a%20script%3CBR%20%2F%3ECopy%20the%20following%20sample%2C%20update%20it%20with%20information%20specific%20to%20your%20environment%2C%20save%20it%20with%20a%20PS1%20file%20name%20extension%2C%20and%20then%20run%20the%20script%20on%20each%20computer%20that%20connects%20directly%20to%20the%20OMS%20service.%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eparam(%24ProxyDomainName%3D%22%3CA%20href%3D%22http%3A%2F%2Fproxy.contoso.com%3A80%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fproxy.contoso.com%3A80%3C%2FA%3E%22%2C%20%24cred%3D(Get-Credential))%3CBR%20%2F%3E%3CBR%20%2F%3E%23%20First%20we%20get%20the%20Health%20Service%20configuration%20object.%20We%20need%20to%20determine%20if%20we%3CBR%20%2F%3E%23%20have%20the%20right%20update%20rollup%20with%20the%20API%20we%20need.%20If%20not%2C%20no%20need%20to%20run%20the%20rest%20of%20the%20script.%3CBR%20%2F%3E%24healthServiceSettings%20%3D%20New-Object%20-ComObject%20'AgentConfigManager.MgmtSvcCfg'%3CBR%20%2F%3E%3CBR%20%2F%3E%24proxyMethod%20%3D%20%24healthServiceSettings%20%7C%20Get-Member%20-Name%20'SetProxyInfo'%3CBR%20%2F%3E%3CBR%20%2F%3Eif%20(!%24proxyMethod)%3CBR%20%2F%3E%7B%3CBR%20%2F%3EWrite-Output%20'Health%20Service%20proxy%20API%20not%20present%2C%20will%20not%20update%20settings.'%3CBR%20%2F%3Ereturn%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%3CBR%20%2F%3EWrite-Output%20%22Clearing%20proxy%20settings.%22%3CBR%20%2F%3E%24healthServiceSettings.SetProxyInfo(''%2C%20''%2C%20'')%3CBR%20%2F%3E%3CBR%20%2F%3E%24ProxyUserName%20%3D%20%24cred.username%3CBR%20%2F%3E%3CBR%20%2F%3EWrite-Output%20%22Setting%20proxy%20to%20%24ProxyDomainName%20with%20proxy%20username%20%24ProxyUserName.%22%3CBR%20%2F%3E%24healthServiceSettings.SetProxyInfo(%24ProxyDomainName%2C%20%24ProxyUserName%2C%20%24cred.GetNetworkCredential().password)%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-314412%22%20slang%3D%22en-US%22%3ERe%3A%20Proxy%20Settings%20when%20using%20OMS%20Agent%20VM%20Extension%20via%20ARM%20template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-314412%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20for%20the%20reply.%20I'm%20able%20to%20configure%20the%20proxy%20address%20using%20this%20method%2C%20however%20my%20question%20is%20how%20I%20can%20use%20proxy%20credentials%2C%20in%20order%20to%20authenticate%20to%20the%20proxy.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-314303%22%20slang%3D%22en-US%22%3ERe%3A%20Proxy%20Settings%20when%20using%20OMS%20Agent%20VM%20Extension%20via%20ARM%20template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-314303%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EAdding%20the%20OMS%26nbsp%3B%20agent%20generally%20we%20use%20this%20like%20below.%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSTRONG%3E%7B%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%22type%22%3A%26nbsp%3B%22Microsoft.Compute%2FvirtualMachines%2Fextensions%22%2C%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%22name%22%3A%26nbsp%3B%22%5Bconcat(parameters('vmName')%2C'%2F'%2C'MMAAgent')%5D%22%2C%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%22apiVersion%22%3A%26nbsp%3B%222015-05-01-preview%22%2C%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%22location%22%3A%26nbsp%3B%22%5BresourceGroup().location%5D%22%2C%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%22properties%22%3A%20%7B%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%22publisher%22%3A%26nbsp%3B%22Microsoft.EnterpriseCloud.Monitoring%22%2C%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%22type%22%3A%26nbsp%3B%22MicrosoftMonitoringAgent%22%2C%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%22typeHandlerVersion%22%3A%26nbsp%3B%221.0%22%2C%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%22autoUpgradeMinorVersion%22%3A%26nbsp%3Btrue%2C%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%22settings%22%3A%20%7B%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%22workspaceId%22%3A%26nbsp%3B%22%5Breference(resourceId(parameters('OMSResourceGroupName')%2C'Microsoft.OperationalInsights%2Fworkspaces%2F'%2C%20parameters('workspaceName'))%2C%20'2015-03-20').customerId%5D%22%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%7D%2C%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%22protectedSettings%22%3A%20%7B%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%22workspaceKey%22%3A%26nbsp%3B%22%5BlistKeys(resourceId(parameters('OMSResourceGroupName')%2C'Microsoft.OperationalInsights%2Fworkspaces%2F'%2C%20parameters('workspaceName'))%2C%20'2015-03-20').primarySharedKey%5D%22%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%7D%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%7D%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%7D%3C%2FSTRONG%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAdding%20the%20%3CSPAN%3EproxyUri%20to%20the%20settings.%20I%20think%20that%20should%20work.%3C%2FSPAN%3E%3C%2FP%3E%3CPRE%3E%7B%3CBR%20%2F%3E%22type%22%3A%20%22Microsoft.Compute%2FvirtualMachines%2Fextensions%22%2C%0A%22name%22%3A%20%22%5Bconcat(parameters('vmName')%2C'%2F'%2C'MMAAgent')%5D%22%2C%0A%22apiVersion%22%3A%20%222015-05-01-preview%22%2C%0A%22location%22%3A%20%22%5BresourceGroup().location%5D%22%2C%0A%22properties%22%3A%20%7B%0A%22publisher%22%3A%20%22Microsoft.EnterpriseCloud.Monitoring%22%2C%0A%22type%22%3A%20%22MicrosoftMonitoringAgent%22%2C%0A%22typeHandlerVersion%22%3A%20%221.0%22%2C%0A%22autoUpgradeMinorVersion%22%3A%20true%2C%0A%22settings%22%3A%20%7B%0A%22workspaceId%22%3A%20%22%5Breference(resourceId(parameters('OMSResourceGroupName')%2C'Microsoft.OperationalInsights%2Fworkspaces%2F'%2C%20parameters('workspaceName'))%2C%20'2015-03-20').customerId%5D%22%2C%0A%22proxyUri%22%3A%20%22%5Bparameters('ProxyUri')%5D%22%0A%7D%2C%0A%22protectedSettings%22%3A%20%7B%0A%22workspaceKey%22%3A%20%22%5BlistKeys(resourceId(parameters('OMSResourceGroupName')%2C'Microsoft.OperationalInsights%2Fworkspaces%2F'%2C%20parameters('workspaceName'))%2C%20'2015-03-20').primarySharedKey%5D%22%0A%7D%0A%7D%0A%7D%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi all

 

I'm adding the Monitoring Agent using a VM extension in an ARM template, using the following code. My question is whether it's possible to specify authentication details in the template code so that the agent can authenticate to the proxy server. Is this possible?

 

"properties": {
"publisher": "Microsoft.EnterpriseCloud.Monitoring",
"type": "MicrosoftMonitoringAgent",
"typeHandlerVersion": "1.0",
"autoUpgradeMinorVersion": true,
"settings": {
"workspaceId": "[parameters('omsworkspaceid')]",
"proxyUri": "proxy:8080"
},

 

 

4 Replies

 

Hi,

Adding the OMS  agent generally we use this like below. 

{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(parameters('vmName'),'/','MMAAgent')]",
"apiVersion": "2015-05-01-preview",
"location": "[resourceGroup().location]",
"properties": {
"publisher": "Microsoft.EnterpriseCloud.Monitoring",
"type": "MicrosoftMonitoringAgent",
"typeHandlerVersion": "1.0",
"autoUpgradeMinorVersion": true,
"settings": {
"workspaceId": "[reference(resourceId(parameters('OMSResourceGroupName'),'Microsoft.OperationalInsights/workspaces/', parameters('workspaceName')), '2015-03-20').customerId]"
},
"protectedSettings": {
"workspaceKey": "[listKeys(resourceId(parameters('OMSResourceGroupName'),'Microsoft.OperationalInsights/workspaces/', parameters('workspaceName')), '2015-03-20').primarySharedKey]"
}
}
}

 

Adding the proxyUri to the settings. I think that should work.

{
"type": "Microsoft.Compute/virtualMachines/extensions", "name": "[concat(parameters('vmName'),'/','MMAAgent')]", "apiVersion": "2015-05-01-preview", "location": "[resourceGroup().location]", "properties": { "publisher": "Microsoft.EnterpriseCloud.Monitoring", "type": "MicrosoftMonitoringAgent", "typeHandlerVersion": "1.0", "autoUpgradeMinorVersion": true, "settings": { "workspaceId": "[reference(resourceId(parameters('OMSResourceGroupName'),'Microsoft.OperationalInsights/workspaces/', parameters('workspaceName')), '2015-03-20').customerId]", "proxyUri": "[parameters('ProxyUri')]" }, "protectedSettings": { "workspaceKey": "[listKeys(resourceId(parameters('OMSResourceGroupName'),'Microsoft.OperationalInsights/workspaces/', parameters('workspaceName')), '2015-03-20').primarySharedKey]" } } }

 

Thank you for the reply. I'm able to configure the proxy address using this method, however my question is how I can use proxy credentials, in order to authenticate to the proxy. 

To configure proxy settings for the Microsoft Monitoring Agent using Control Panel

Open Control Panel.

Open Microsoft Monitoring Agent.

Click the Proxy Settings tab.
proxy settings tab

Select Use a proxy server and type the URL and port number, if one is needed, similar to the example shown. If your proxy server requires authentication, type the username and password to access the proxy server.

Use the following procedure to create a PowerShell script that you can run to set the proxy settings for each agent that connects directly to servers.

To configure proxy settings for the Microsoft Monitoring Agent using a script
Copy the following sample, update it with information specific to your environment, save it with a PS1 file name extension, and then run the script on each computer that connects directly to the OMS service.


param($ProxyDomainName="http://proxy.contoso.com:80", $cred=(Get-Credential))

# First we get the Health Service configuration object. We need to determine if we
# have the right update rollup with the API we need. If not, no need to run the rest of the script.
$healthServiceSettings = New-Object -ComObject 'AgentConfigManager.MgmtSvcCfg'

$proxyMethod = $healthServiceSettings | Get-Member -Name 'SetProxyInfo'

if (!$proxyMethod)
{
Write-Output 'Health Service proxy API not present, will not update settings.'
return
}

Write-Output "Clearing proxy settings."
$healthServiceSettings.SetProxyInfo('', '', '')

$ProxyUserName = $cred.username

Write-Output "Setting proxy to $ProxyDomainName with proxy username $ProxyUserName."
$healthServiceSettings.SetProxyInfo($ProxyDomainName, $ProxyUserName, $cred.GetNetworkCredential().password)

@Vinoth_Azure It's really cool to get the proxyUri settings in ARM. It works for me on Windows but when I try it with linux version (type = "OmsAgentForLinux") it always fail with this error. Do you know if this parameter is supported on Linux version of the Microsoft.EnterpriseCloud.Monitoring extension?

"code": "VMExtensionProvisioningError",
"message": "VM has reported a failure when processing extension 'LogAnalytics-Agent-Extension'. Error message:
\"Enable failed with exit code 53 Installation failed due to incorrect workspace key. Please check if the workspace
key is correct. For details, check logs in
/var/log/azure/Microsoft.EnterpriseCloud.Monitoring.OmsAgentForLinux/extension.log\"\r\n\r\nMore information on
troubleshooting is available at https://aka.ms/VMExtensionOMSAgentLinuxTroubleshoot "