Azure Automation - Shutdown of VM

Hi Azure Experts

I have been testing Azure of late and getting stuck in.

I have setup Azure Automation. I have configured a Start-up Job which works a treat. I have also created a Shut-down Job as follows:
workflow ShutDown_STMine_VM
{
$Cred = Get-AutomationPSCredential -Name 'automation'
Add-AzureAccount -Credential $Cred
InlineScript
  {
  Select-AzureSubscription -SubscriptionName "Microsoft Partner Network"
  $VMS = Get-AzureVM
  ForEach ($VM in $VMS)
    {
    $VMName = $VM.Name
   Write-Output "Attempting to shut down VM: $VMName"
  Stop-AzureVM -ServiceName $VM.ServiceName -Name $VM.Name -StayProvisioned
    }
  }
}

Open in new window


Now, whilst the Shut-down job shuts down the VM's I have in there, I'm seeing this:
1.PNGThe message 'Virtual machines continue to incur compute charges if they are stopped from the guest operating system. To avoid these charges, use the management portal to stop the virtual machines or to delete them' - can anyone advise how I can get the VM to completely shutdown so that it is not incurring any Compute Charges?

Thanks
Mark
LVL 13
Mark GalvinManaging Director / Principal ConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
note the difference between -stayprovisioned (you keep paying) and -force (you stop paying)

$subscription = Import-AzurePublishSettingsFile -PublishSettingsFile 'D:\Downloads\Visual Studio Premium with MSDN-8-20-2015-credentials.publishsettings'
# create a context for account and key
Set-AzureSubscription -SubscriptionId $subscription.id
$vms = Get-AzureVM -servicename SSCM2012DWJ
foreach ($vm in $vms) {
      if ($vm.InstanceStatus -ne 'StoppedDeallocated' )
        {
        write-output("Stopping:"+$vm.Name)        
       Stop-AzureVM -ServiceName $vm.ServiceName -Name $vm.Name -force
       }
    }

Open in new window


My start-myazurevms.ps1 script
Import-AzurePublishSettingsFile -PublishSettingsFile "D:\downloads\Visual Studio Premium with MSDN-8-20-2015-credentials.publishsettings"
$vms = get-azurevm 
foreach($vm in $vms){
    if(!($vm.status -like  "Running")){
        write-host('Starting:'+ $vm.name)
        start-azurevm -servicename $vm.servicename -name $vm.name
        }
    }

Open in new window

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mark GalvinManaging Director / Principal ConsultantAuthor Commented:
hi

Thanks for that. I was using the '-stayprovisioned' to keep the same external IP but see the error of my ways.

If I wanted to have a static external IP as I am hosting an app server how to I go about that? The app server needs to be available to the public via port 25565. I have another question open about the fact that that port is open even though I have set it as endpoint.

Thanks
Mark
0
David Johnson, CD, MVPOwnerCommented:
you probably don't need a full blown virtual machine for your app.
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Mark GalvinManaging Director / Principal ConsultantAuthor Commented:
Hi

The server for the application needs a full Windows Server running.

If have a static IP via Azure is not possible I presume that using something like DYNDNS is allowed?
0
David Johnson, CD, MVPOwnerCommented:
0
Mark GalvinManaging Director / Principal ConsultantAuthor Commented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Azure

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.