Troubleshooting site-to-site connection in Azure: error 797, 663.

When I created a site-to-site connection in Azure Networks (classic) and tried to connect to the gateway from my on-premise VPN server running on virtual Windows Server 2012 R2 for the first time I found the following error in Application Event Log:

CoId={guid}: The user SYSTEM dialed a connection named {name} which has failed. The error code returned on failure is 797.

Solution: in RRAS -> Ports -> Properties: WAN Winiport (IKEv2) make sure you have at least 1 port enabled.

Next error I got was:

CoId={guid}: The user SYSTEM dialed a connection named {name} which has failed. The error code returned on failure is 663.

Solution: in the same settings make sure you have Demand-dial routing connection (inbound and outbound) enabled.

Happy routing!