Https://azure.microsoft.com/en-us/documentation/articles/powershell-install-configure/
In this article:
- How To:install Azure PowerShell
- How To:connect to your subscription
- How to use the Cmdlets:an example
- Getting Help
- Additional Resources
- Comments
You can use Windows PowerShell to perform a variety of the tasks in Azure, either interactively at a command prompt or Automat Ically through scripts. Azure PowerShell is a module, provides cmdlets to manage azure through Windows PowerShell. You can use the cmdlets to create, test, deploy, and manage solutions and services delivered through the Azure platform. In the most cases, you can use the cmdlets to perform the same tasks for you can perform through the Azure Management Portal. For example, you can create and configure cloud services, virtual machines, virtual networks, and Web apps.
The module is distributed as a downloadable file and the source code is managed through a publicly available repository. A link to the downloadable files are provided in the installation instructions later in this topic. For information on the source code, see Azure PowerShell code repository.
This guide provides basic information about installing and setting up Azure PowerShell to manage the Azure platform.
Prerequisites for using Azure PowerShell
Azure is a subscription-based platform. This means, subscription is required to use the platform. In most cases, it also means that the cmdlets require subscription information to perform the tasks with your subscription . (Some of the storage-related cmdlets can be used without this information.) You provide the configuring your computer to connect to your subscription. Instructions is provided in this article, under "How To:connect to your subscription."
Note:
Beginning in version 0.8.5, the Azure PowerShell modules require Microsoft. NET Framework 4.5.
When you install the module, the installer checks your system for the required software and installs all dependencies, suc h as the correct version of Windows PowerShell and. NET Framework.
How To:install Azure PowerShell
You can download and install the Azure PowerShell modules by running the Microsoft Web Platform Installer. When prompted, click Run. The Web Platform Installer installs the Azure PowerShell modules and all dependencies. Follow the prompts to complete the installation.
Note:
If you just want to download the PowerShell installer, please visit https://github.com/Azure/azure-powershell/releases. Source code for the PowerShell cmdlets can is found at this repo as well
For more information on the command-line tools available for Azure, see command-line tools.
Installing the module also installs a customized console for Azure PowerShell. You can run the cmdlets from either the standard Windows PowerShell console or the Azure PowerShell console.
The method you use to open either console depends on the version of Windows you ' re running:
On a computer running in least Windows 8 or Windows Server, you can use the built-in Search. From the Start screen, begin typing power. This returns a scoped list of apps that includes Windows PowerShell and Azure PowerShell. To open the console, click either app. (to pin the app to the Start screen, right-click the icon.)
On a computer running a version earlier than Windows 8 or Windows Server, use the Start menu. From the Start menu, click "All Programs", click Azure, and then click Azure PowerShell.
How To:connect to your subscription
Use of Azure requires a subscription. If you don't have a subscription, see Get Started with Azure.
The cmdlets need your subscription so they can manage your services. There is ways to provide your subscription information to Windows PowerShell. Can use a management certificate this contains the information or you can sign in to Azure using your Microsoft Accoun T or a work or school account. When your sign in, Azure Active Directory (Azure AD) authenticates the credentials and returns a access token that lets Az Ure PowerShell Manage your account.
Choose the authentication method that's appropriate for your needs, consider the following:
- Azure AD is the recommended authentication method since it makes it easier to manage access to a subscription. With the update on version 0.8.6, it enables an automation scenario with Azure AD authentication as well if a work or Scho OL account is used. It works with the Azure Resource Manager API as well.
- When you use the certificate method, the subscription information is available as long as the subscription and the Certifi Cate is valid. However, this method makes it harder-manage access to a GKFX subscription, such as when more than one person is Autho Rized to access the account. Also, Azure Resource Manager API doesn ' t accept certificate authentication.
For more information about authentication and subscription management in Azure, see Manage Accounts, subscriptions, and Ad Ministrative Roles.
Use the Azure AD method
Open The Azure PowerShell console, as instructed in how To:install Azure PowerShell.
Type the following command:
CopyAdd-azureaccount
In the window, type the e-mail address and password associated with your account.
Azure authenticates and saves the credential information, and then closes the window.
Starting from 0.8.6, if your sign on using a work or school account, you can type the following command to bypass the pop u P window. This would pop up the standard Windows PowerShell credential window for your to enter your work or school account user name and password.
Copy=Get-credentialAdd-azureaccount-credential $cred
Note:For more information in security and using credentials, see Best practices for deploying passwords and other sensitive dat A to ASP. NET and Azure Websites.
Note:This non-interactive login method is works with a or school account. A work or school account is a user this is managed by your work or school, and defined in the Azure Active Directory Insta NCE for your work or school. If you does not currently has a work or school account, and is using a Microsoft account to log on to your Azure subscript Ion, you can easily create one using the following steps.
Login to the Azure Management Portal, and click on Active Directory.
If No directory exists, select Create your directory and provide the requested information.
Select your directory and add a new user. This new user can sign in using a work or school account.
During the creation of the user, you'll be supplied with both an e-mail address for the user and a temporary password. Save this information as it's used in another step.
From the Management portal, select Settings and then select Administrators. Select Add, and Add the new user as a co-administrator. This allows the work or school account to manage your Azure subscription.
Finally, log out of the "Azure Portal" and then log back in using the "work" or school account. If This was the first time logging in with this account, you'll be prompted to the password.
For more information on signing up for Microsoft Azure with a work or school account, see Sign up for Microsoft Azure as a N Organization.
Use the Certificate method
The Azure module includes cmdlets you download and import the certificate.
Note:
The cmdlets in the Azureresourcemanager module require the Azure AD method (Add-azureaccount). These cmdlets do not support publish settings files. For more information on the cmdlets in the Azureresourcemanager module, see Azure Resource Manager cmdlets.
The Get-azurepublishsettingsfile cmdlet opens a Web page on the Azure Management Portal, from which can downl Oad the subscription information. The information is contained in a. publishsettings file.
The import-azurepublishsettingsfile imports the. publishsettings file for use by the module. This file includes a management certificate the has security credentials.
IMPORTANT:
We recommend that I delete the publishing profile, the downloaded using get-azurepublishsettingsfile after You import those settings. Because The management certificate includes security credentials, it should not being accessed by unauthorized users. If You need information about your subscriptions, you can get it from the Azure Management Portal or the Microsoft Online Services Customer Portal.
Sign in to the Azure Management Portal using the-credentials for your Azure account.
Open The Azure PowerShell console, as instructed in how To:install Azure PowerShell.
Type the following command:
CopyGet-azurepublishsettingsfile
-
When prompted, download and save the publishing profile and note the path and name of the. publishsettings file. This information was required when you run the Import-azurepublishsettingsfile cmdlet to Import the Settin Gs. The default location and file name format is:
copy C:\\users\< userprofile>\\download \\[*mysubscription*-...] -*downloaddate*-credentials. Publishsettings
Type a command similar to the following, substituting your Windows account name and the path and file name for the Placeho Lders:
CopyImport-azurepublishsettingsfile C:\users\<userprofile>\downloads\< Subscriptionname>-credentials. Publishsettings
Note:
If you're added to and subscriptions as a co-administrator after you import your publish settings, you'll need to Repea t this process to download a new publishsettings file, and then import those settings. For information about adding co-administrators to help manage services for a subscription, see ADD and Remove co-administr Ators for Your Azure subscriptions.
View Account and subscription details
You can have multiple accounts and subscriptions available for use by Azure PowerShell. You can add multiple accounts by running Add-azureaccount more than once.
To get the available Azure accounts, type:
Copy
Get-azureaccount
To get your Azure subscriptions, type:
Copy
Get-azuresubscription
How to use the Cmdlets:an example
After your ' ve installed the module and configured your computer to connect to your subscription, you can create a Azure we B app. This example would get you started using the Azure cmdlets.
Start the Azure PowerShell console.
-
Choose a name for your web app. Pick a name, conforms to DNS naming conventions. Valid names can contain only letters ' a ' through ' z ', numbers ' 0 ' through ' 9 ', and a hyphen ('-').
The Web App name must is unique in Azure. We'll use the "MySite" in the "example", but being sure to choose a different name, such as your account name followed by a number .
After you pick a name, type a command similar to the following. Substitute your web app name for "MySite".
Copynew- azurewebsite MySite
The The cmdlet creates the Web app and returns an object that represents the new Web App. The object properties include useful information about the Web App.
To get information about the Web app, type this command. It returns a bit of information about all Web apps in the subscription, including the one so you just created.
CopyGet-azurewebsite
To get more information about your Web apps, include the Web app name in the command. Be sure to substitute the name of your web app for "MySite".
CopyGet-azurewebsite-Name mySite
Web apps is started after they is created. To stop the Web app, type This command, including the name of the your Web app.
CopyStop-azurewebsite-Name mySite
To verify the site's state is ' stopped ', run the Get-azurewebsite command again.
CopyGet-azurewebsite
To complete this test, delete the Web App. Type:
CopyRemove-azurewebsite-Name mySite
To complete the task, confirm the web app is deleted.
CopyGet-azurewebsite-Name mySite
Getting Help
These resources provide help for specific cmdlets:
From within the console, you can use the built-in Help system. The Get-help cmdlet provides access to this system. The following table provides some examples of commands you can use to get help. You can get more information from within the console by typing help.
Command |
Result |
Get-help |
Describes the help system. Note: The description includes some information about help files, the does not apply to the Azure module. Specifically, help files was installed when the module is installed. They is not available for download separately. |
Get-help Azure |
Gets all cmdlets in the Azure module. |
Get-help <language>-dev |
Gets cmdlets for developing and managing applications in a specific language. For example, the Help Node-dev, the help Php-dev, or the help Python-dev. |
Get-help <cmdlets> |
Gets Help on a Windows PowerShell cmdlet. Replace with the cmdlet name. |
Get-help <cmdlets>-parameter * |
Gets descriptions of the cmdlet parameters. The asterisk (*) means "all". |
Get-help <cmdlets>-examples |
Gets the syntax and examples of the using the cmdlet. |
Get-help <cmdlets>-full |
Gets all the Help for a cmdlet, including technical details. |
Reference information about the cmdlets in the Azure PowerShell modules are also available in the Azure library. For information, see Azure Cmdlet Reference.
For help from the community, try these popular forums:
- Azure Forum on MSDN
- StackOverflow
Additional Resources
These is some of the resources available that's can use to learn to use Azure and Windows PowerShell.
To learn what to access Azure Storage components, see Using Azure PowerShell with Azure Storage.
To provide feedback on the cmdlets, report issues, or access the source code, see Azure PowerShell code repository.
To learn on the Windows PowerShell command line and scripting environment, see the TechNet Script Center.
For information on installing, learning, using, and customizing Windows PowerShell, see Scripting with Windows Powershe ll.
For information on what scripts is and how to run them in Windows PowerShell, see Running scripts. This article includes basic information on creating scripts and configuring your computer to run scripts.
For information on cmdlets for Azure AD, see Manage Azure ad using Windows PowerShell.
How to install and configure Azure PowerShell