The IT infrastructure world has a history divided into:
<> The 90s for Networking
<> The 00s for Virtualization
<> The 10s for Cloud
So, if you still have not thought of cloud. you just living a life with trust issues and outdated technology.
Riyaz's Innovative Solutions Blog
Your one stop consultant for Digital Workplace
The IT infrastructure world has a history divided into:
<> The 90s for Networking
<> The 00s for Virtualization
<> The 10s for Cloud
So, if you still have not thought of cloud. you just living a life with trust issues and outdated technology.
This approach is useful for scenario where you work on a client workspace, where you don’t directly sign to root level Azure management portal. This was tested on Chrome.
Once after you login to client workspace level:
https://manage.windowsazure.com/@[YOURCLIENTNAME].onmicrosoft.com#Workspaces/All/dashboard
On the same browser copy the following url and hit enter:
https://manage.windowsazure.com/publishsettings/
you will notice the subscription file related to the client workspace getting downloaded.
The usual approach for this, when you have root level azure management access:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
Import-Module Azure
Get-AzurePublishSettingsFile
Note When you save your Publish Settings file, specify a short easily-typed file name to save your file.
Automation Account: The Automation Account is a placeholder for your other objects which include Runbooks, Assets, Scale configuration, etc.
Assets: An Asset can be a "Connection", a "Credential", a "Variable", or a "Schedule" object which can be linked or referenced in your Runbooks.
Runbooks: The Runbook is essentially the script containing the commands you want to issue to your environment. A Runbook can contain references to Assets such as a reusable "Credential".
The newer way of connecting to your Azure tenant from the Automation environment is to use an account in your Azure AD environment, adding it as an Asset (Credential), then referencing it in your connectivity to your environment.
We need to make a connection to the Azure environment which is done by issuing the following command:
$cred = Get-AutomationPSCredential -Name AzureAutomationAccount
We store the credentials in a variable called $cred which we pass to the function below. This makes it possible for an Administrator to establish a co-administrator ID without giving the password out to another person who might be using the account for scripting purposes.
Add-AzureAccount -Credential $cred
This command will connect to your Azure tenant using the credentials stored in the Asset you created earlier.
Select-AzureSubscription -SubscriptionName "Visual Studio Ultimate with MSDN"
NOTE: Depending on your environment, you may need to change the subscription name to your actual subscription name. So how do you find this information? Well, I suggest downloading the Azure PowerShell tools from: http://azure.microsoft.com/en-us/downloads/#cmd-line-tools. Start the Azure PowerShell tool and log into your account using the Add-AzureAccount function above. After authenticating, type Get-AzureSubscription and note the SubscriptionName parameter’s value.
You’re now ready to start issuing commands to your VMs. To start VMs in a particular cloud service use:
Start-AzureVM -Name -ServiceName
To stop all VMs in a cloud service, use:
Stop-AzureVM -Name * -ServiceName -Force
Using the "-Force" parameter will ensure the script properly de-allocates your Cloud Service resources including the shared Virtual IP. Without this switch the runbook will fail to shut down all the VMs.
You can save and test your Runbook using the buttons on the bottom toolbar when in "editing" mode to make sure everything is working. When complete, click the Publish button which will allow you now to schedule your Runbook.
Now that we’ve created a Runbook, we want to schedule it to run on a daily basis at 018:00 every day:
You can go back to your Automation Account then into Assets to view your "Schedule" asset which was created when you clicked the Link button in the above steps.
NOTE: If you need to change the start date, time, or frequency of your Schedule asset it doesn’t appear to be and editable object through the UI or Azure PowerShell (i.e. Set-AzureAutomationSchedule) so you likely have to create a new one, link it, and un-link the old one.