2021-09-29

Azure VM agent is missing or not responding

I realized that one of my virtual machines is not correctly added to Microsoft Azure Automation Account Update Management. There was some problem with former membership to different WorkspaceId which prevented Portal wizard to add that machine update list. What to do? 

First the original error message

Error message in Updates(loganalytics) | Virtual machines
VM agent is missing or not responding. 

In this case, I knew what is the source of the problem since the original connected LogAnalytics object was deleted without unregistering the MicrosoftMonitoringAgent used on the virtual machine.

Second step check what configuration you have in your target VM 

az vm show --name <VMname> -g <ResourceGroupName> --query resources[].settings

Let's be more exast about value we are looing. Here you can extract path of Log Analytics Id

az vm show --name <VMname> -g <ResourceGroupName> --query resources[].settings.workspaceId

There I was able to see Id which was not correct. Do a cross-check with some properly configured Virtual machine to find the right value. 

Thirds step: We are going to replace that Id with a new one. VM is still operational during the action.
I realized that replacing the value removed the whole section resources from VM configuration which was not working anyway.

az vm update --name <VMname> -g <ResourceGroupName> --set resources[0].settings.workspaceId='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'

Result check:
az vm show --name <VMname> -g <ResourceGroupName>

Forth step: Navigate in Azure Portal to Solution object which is called Updates(<Log Analytics Workspace Name>) click in the right column on the option Workspace Data Sources => Virtual machines, click on affected VM, and click to "Connect". All troubles should be resolved by that.

Result check:
az vm show --name <VMname> -g <ResourceGroupName> --query resources[].settings

You might also experience the error message "Agent has a problem" which I have still under investigation, but a general solution might require a reboot or even deallocation of the server. TBC...

Workaround to keep data collection working even when there is a problem with Agent: Install "desktop" software tool for Windows called Microsof Monitoring Agent (MMA) and link it with keys to LogAnalytics. Available also for linux.

2021-09-23

Samsung Galaxy dock ThinkPad

Zajímá vás, jesli můžete připojit telefon Samsung Galaxy S21 (a nižší) na dokovací stanici ke svému pracovnímu počítači Lenovo ThinkPad abyste získali prostředí Samsung Dex či obrazovku navíc? Odpověď je, že to nejde.

Vyzkoušeno s dokovacími stanicemi Lenovo DK1841 a ThinkPad Thunderbolt 3 Dock - Type 40A. Mobilní telefon byl v tomto případě Samsung SM-G991B/DS.

Ačkoliv fyzické spojení lze zařídit, když máte samostatný USB-C kabel. Zkoušel jsem také použít prodlužovačku, neboť jedna z dokovacích stanicí používá sdružený USB-C a napájecí kabel, který nejde do telefonu zasunout. Nicméně datové spojení se ani v jednom případě nenaváže (u sdruženého konektoru dokonce ani nabíjení ne), protože dokovačka používá protokol Thunderbold, který v telefonu od Samsungu není. Prostě to nebude fungovat.

Mohlo by vás také napadnout použít jako vstup přední panel dokovací stanice, kde je jen USB-C port se symbolem blesku a ten spojit s telefonem vhodným kabelem. Ani to nebude fungovat, symbol blesku znamená ten Thunderbold, který mobilní telefon neumí.

Je to ovšem jen volbou dokovačky, zkoušel jsem svůj Samsung připojit k Hama 7-in-1 USB-C Docking Station, kde se Dex mód spustí. Tady kompatibilitu zejména s displeji zajišťuje protokol DisplayPort Alternate Mode. Klávesnice s myší pak funguje, protože se zařízení chová jako USB hub.

Později jsem zkoušel dokovací stanici Dell WD19S a ta se k DEX kabelově připojí bez problému. Na koncovce kabelu svítí logo "DP" a nikoliv blesk.

Že Dex funguje můžete také vyzkoušet, připojíte-li si telefon kabelem přímo k počítači s nainstalovaným programem Samsung Dex (zkoušel jsem na Windows). Samsung Dex se spustí a to se hodí v případě, že váš počítač je opravdu pomalý, ale má velkou obrazovku, pohodlnou klávesnici nebo chcete pracovat se soubory v telefonu.

Snad za pomocí tohoto článku předejdete zbytečnému snažení. Více trablech s dokovacími stanicemi.

2021-09-01

Azure Application Gateway change subnet

It is possible to change subnet in which is azure application gateway running without need to delete the whole instance and do all configuration from the beggining. It would be faster with recreation than going via process described below. This require quite long service break. I had reserved 2 hours and with little bit of trial-and-fix I managed to fit in.

  

Web UI way

Step 1 set application gateway to be manually scaled.

Step 2 stop application gateway via console command "az network application-gateway stop"

wait to proceeed

Step 3 open appgw page in portal.azure.com

modify URL from

https://portal.azure.com/#@CUSTOMER.onmicrosoft.com/resource/subscriptions/SUBSCRIPTIONID/resourceGroups/RESOURCEGROUP/providers/Microsoft.Network/applicationGateways/APPLICATIONGATEWAY/overview

modify URL to

https://resources.azure.com/#@CUSTOMER.onmicrosoft.com/resource/subscriptions/SUBSCRIPTIONID/resourceGroups/RESOURCEGROUP/providers/Microsoft.Network/applicationGateways/APPLICATIONGATEWAY

Step 4 open modified page

Step 5 click get and search in page "subnet". We are going to modify this value only.

Step 6 switch to read/write mode on top of the page

Step 7 click on button edit

Step 8 find again "subnet" and modify name or path to subnet which you want to use

Step 9 click press PUT and wait for green tick on the screen

Step 10 if there is an orange warning, scroll to bottom of the page and there is additional text area explaining what is causing problem. Fix it and repeat.

Step 11 wait till update is done. There is no need to start application gateway again, because update will start it.

Azure Cloud Shell

Alternatively it's possible to do it with commands via Azure cloud shell or similar.

Check settings

az network application-gateway show --subscription <SUBSCRIPTIONID> --resource-group <RESOURCEGROUP> --name <APPLICATIONGATEWAY> --query gatewayIpConfigurations

Stop AppGw

az network application-gateway stop --subscription <SUBSCRIPTIONID> --resource-group <RESOURCEGROUP> --name <APPLICATIONGATEWAY>

Get JSON 

az network application-gateway show --subscription <SUBSCRIPTIONID> --resource-group <RESOURCEGROUP> --name <APPLICATIONGATEWAY> --output json

Prepare JSON by modify the value of subnet. Next stop shrink it to one line (visual studio code and shift+tab) and put as one liner. 

Post it

az network application-gateway update --subscription <SUBSCRIPTIONID> --resource-group <RESOURCEGROUP> --name  <APPLICATIONGATEWAY> --set gatewayIpConfigurations[0].subnet.id='[{"id": "/subscriptions/<SUBSCRIPTIONID>/resourceGroups/<RESOURCEGROUP>/providers/Microsoft.Network/applicationGateways/ <APPLICATIONGATEWAY>/gatewayIPConfigurations/appGatewayFrontendIP","name": "appGatewayFrontendIP","provisioningState": "Succeeded","resourceGroup": "<RESOURCEGROUP>","subnet": {"id": "/subscriptions/<SUBSCRIPTIONID>/resourceGroups/<RESOURCEGROUP>/providers/Microsoft.Network/virtualNetworks/<VNET>/subnets/<SUBNET>","resourceGroup": "<RESOURCEGROUP>"},"type": "Microsoft.Network/applicationGateways/gatewayIPConfigurations"}]'

Start

az network application-gateway start --subscription <SUBSCRIPTIONID> --resource-group <RESOURCEGROUP> --name <APPLICATIONGATEWAY>

Beware

There is some leftover network device after application gateway migration, so you cannot easily delete subnet you used for migration. See output of trial of deleting that subnet:

az network vnet subnet delete --ids /subscriptions/<SUBSCRIPTIONID>/resourceGroups/<RESOURCEGROUP>/providers/Microsoft.Network/virtualNetworks/<VNET>/subnets/<SUBNET>

(InUseSubnetCannotBeDeleted) Subnet <SUBNET> is in use by subscriptions/<SUBSCRIPTIONID>/resourceGroups/<WEIRDRESOURCEGROUPARMRG>/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|appgw|virtualMachines|1|networkInterfaces|custnic and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet.

This I could resolve without help of Microsoft Support, so I created a ticket. Here is solution summary:

It was due to an error i.e. when the App GW was moved to other subnet from these subnet it was not completely removed in the backend due to which you were not able to delete the subnet   

  • Initially I informed you that all the delegations and the service endpoints need to be removed before proceeding with the deletion of the subnet.
  • You confirmed that you removed all the delegations and the service endpoints and I could see the same from my end that they got removed.
  • I suggested you to try the deletion again but the deletion still kept failing.
  • I asked for the error messages that you were receiving for reference.
  • Upon further troubleshooting we could see that the traces of Network Interface card of the AppGW that was previously present in those subnet were not deleted properly in the backend.
  • We engaged the backend team to do a manual cleanup of the traces left.
  • PG team completed the manual cleanup after which I requested you to try the deletion again and you confirmed that the deletion was successful.
  • You informed us that the ticket can be archived. 
It was quite exhausing process in the end, but thankfully working even it took several days to close it.