As Azure user I can be STOP the running VM. When you stop it. All services related to that will be get stopped. So before stopping VM make sure you have some reason behind on it.
Azure Virtual Machine can be stopped two ways.
- Manually Stop VM
- API request to Stop VM
1.Manually Stop VM : Go To VM overview page - click STOP button - Click OK
2.API request to Stop VM
Build API request and Stop Azure Virtual Machine.
Collect Arguments information
{0} - subscriptionId {1} - resourceGroupName {2} - virtualMachinesName {3} - apiVersion
Variables
private string azureDomain = "https://management.azure.com";
private string vmStopUri = "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachines/{2}/powerOff?api-version={3}";
private string _apiV_2019_12_01 = "2019-12-01";
Write a Method
public void StopVirtualMachine(string vmName)
{
string vmStopUrl = string.Format(azureDomain + vmStopUri, _subscriptionId, _resourceGroupName, vmName, _apiV_2019_12_01);
_apiRequest.PostRESTfulResponseWithToken(_token, vmStopUrl, "");
Thread.Sleep(30000);
}
{
string vmStopUrl = string.Format(azureDomain + vmStopUri, _subscriptionId, _resourceGroupName, vmName, _apiV_2019_12_01);
_apiRequest.PostRESTfulResponseWithToken(_token, vmStopUrl, "");
Thread.Sleep(30000);
}
Once VM has been stopped. You can try to access, Finally you will get below warning.
Comments
Post a Comment