Saturday, April 4, 2015

Configure Azure PowerShell

  1. Install the Azure PowerShell console. For instructions, see How to install and configure Azure PowerShell.
    This customized console is configured to work with your Azure subscription. The Azure module is installed in the Program Files directory and is automatically imported on every use of the Azure PowerShell console.
    If you prefer to work in a different host program, such as Windows PowerShell ISE, be sure to use the Import-Module cmdlet to import the Azure module or use a command in the Azure module to trigger automatic importing of the module.
  2. Start Azure PowerShell with the Run as administrator option.
  3. Run the Set-ExecutionPolicy cmdlet to set the Azure PowerShell execution policy to RemoteSigned. Enter Y (for Yes) to complete the policy change.
    PS C:\> Set-ExecutionPolicy RemoteSigned
    This setting enables you to run local scripts that aren't digitally signed. (You can also set the execution policy to Unrestricted, which would eliminate the need for the unblock step later, but this is not recommended for security reasons.)
  4. Run the Add-AzureAccount cmdlet to set up PowerShell with credentials for your account.
    PS C:\> Add-AzureAccount
    These credentials expire after a period of time and you have to re-run the Add-AzureAccount cmdlet. As this e-book is being written, the time limit before credentials expire is 12 hours.
  5. If you have multiple subscriptions, use the Select-AzureSubscription cmdlet to specify the subscription you want to create the test environment in.
  6. Import a management certificate for the same Azure subscription by using the Get-AzurePublishSettingsFile and Import-AzurePublishSettingsFile cmdlets. The first of these cmdlets downloads a certificate file, and in the second one you specify the location of that file in order to import it. Important:  Keep the downloaded file in a safe location or delete it when you're done with it, because it contains a certificate that can be used to manage your Azure services.
    PS C:\> Get-AzurePublishSettingsFile
    PS C:\> Import-AzurePublishSettingsFile ""
    The certificate is used for a REST API call that detects the development machine's IP address in order to set a firewall rule on the SQL Database server.

No comments:

Post a Comment