How to install and configure Azure PowerShell
https://azure.microsoft.com/en-us/documentation/articles/powershell-install-configure/
You can use Windows PowerShell to perform a variety of tasks in Azure, either interactively at a command prompt or automatically through scripts. Azure PowerShell is a module that 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 most cases, you can use the cmdlets to perform the same tasks that 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 is provided in the installation instructions later in this topic. For information about 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 that a 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 this by configuring your computer to connect to your subscription. Instructions are 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, such 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 be found at this repo as well
For more information about 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 at least Windows 8 or Windows Server 2012, 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 2012, 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 are two ways to provide your subscription information to Windows PowerShell. You can use a management certificate that contains the information or you can sign in to Azure using your Microsoft account or a work or school account. When you sign in, Azure Active Directory (Azure AD) authenticates the credentials and returns an access token that lets Azure PowerShell manage your account.
To help you 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 in version 0.8.6, it enables an automation scenario with Azure AD authentication as well if a work or school account is used. It works with Azure Resource Manager API as well.
- When you use the certificate method, the subscription information is available as long as the subscription and the certificate are valid. However, this method makes it harder to manage access to a shared subscription, such as when more than one person is authorized 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 Administrative 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 email 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 you sign in using a work or school account, you can type the following command to bypass the pop up window. This will pop up the standard Windows PowerShell credential window for you to enter your work or school account user name and password.
Copy$cred = Get-Credential
Add-AzureAccount -Credential $credNOTE:
For more information on security and using credentials, see Best practices for deploying passwords and other sensitive data to ASP.NET and Azure Websites.
NOTE:
This non-interactive login method only works with a work or school account. A work or school account is a user that is managed by your work or school, and defined in the Azure Active Directory instance for your work or school. If you do not currently have a work or school account, and are using a Microsoft account to log in to your Azure subscription, 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 will be supplied with both an e-mail address for the user and a temporary password. Save this information as it is 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 is the first time logging in with this account, you will be prompted to change the password.
For more information on signing up for Microsoft Azure with a work or school account, see Sign up for Microsoft Azure as an Organization.
Use the certificate method
The Azure module includes cmdlets that help 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 about 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 you can download 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 that has security credentials.
IMPORTANT:
We recommend that you delete the publishing profile that you downloaded using Get-AzurePublishSettingsFile after you import those settings. Because the management certificate includes security credentials, it should not be 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 is required when you run the Import-AzurePublishSettingsFile cmdlet to import the settings. The default location and file name format is:
CopyC:\\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 placeholders:
CopyImport-AzurePublishSettingsFile C:\Users\<UserProfile>\Downloads\<SubscriptionName>-credentials.publishsettings
NOTE:
If you are added to other subscriptions as a co-administrator after you import your publish settings, you'll need to repeat 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-Administrators 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:
Get-AzureAccount
To get your Azure subscriptions, type:
Get-AzureSubscription
How to use the cmdlets: An example
After you've installed the module and configured your computer to connect to your subscription, you can create an Azure web app. This example will get you started using the Azure cmdlets.
Start the Azure PowerShell console.
Choose a name for your web app. Pick a name that 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 be unique in Azure. We'll use "mySite" in this example, but be 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 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 that you just created.
CopyGet-AzureWebsite
To get more information about your web app, 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 are started after they are created. To stop the web app, type this command, including the name of your web app.
CopyStop-AzureWebsite -Name mySite
To verify that 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 that 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 how to use the Help system. Note: The description includes some information about Help files that does not apply to the Azure module. Specifically, Help files are installed when the module is installed. They are 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, help node-dev, help php-dev, or help python-dev. Get-Help <cmdlet> Gets help about a Windows PowerShell cmdlet. Replace with the cmdlet name. Get-Help <cmdlet> -Parameter * Gets descriptions of the cmdlet parameters. The asterisk (*) means "all". Get-Help <cmdlet> -Examples Gets the syntax and examples of using the cmdlet. Get-Help <cmdlet> -Full Gets all help for a cmdlet, including technical details. Reference information about the cmdlets in the Azure PowerShell modules is also available in the Azure library. For information, see Azure Cmdlet Reference.
For help from the community, try these popular forums:
Additional Resources
These are some of the resources available that you can use to learn to use Azure and Windows PowerShell.
To learn about how to access Azure Storage components, see Using Azure PowerShell with Azure Storage.
To provide feedback about the cmdlets, report issues, or access the source code, see Azure PowerShell code repository.
To learn about the Windows PowerShell command line and scripting environment, see the TechNet Script Center.
For information about installing, learning, using, and customizing Windows PowerShell, see Scripting with Windows PowerShell.
For information about what scripts are and how to run them in Windows PowerShell, see Running Scripts. This article includes basic information about creating scripts and configuring your computer to run scripts.
For information about cmdlets for Azure AD, see Manage Azure AD using Windows PowerShell.
How to install and configure Azure PowerShell的更多相关文章
- Install and Configure SharePoint 2013 Workflow
这篇文章主要briefly introduce the Install and configure SharePoint 2013 Workflow. Microsoft 推出了新的Workflow ...
- How to build windows azure PowerShell Source Code
Download any version source code of Windows Azure Powershell from https://github.com/Azure/azure-sdk ...
- 使用 Azure PowerShell 模块创建和管理 Windows VM
Azure 虚拟机提供完全可配置的灵活计算环境. 本教程介绍 Azure 虚拟机的基本部署项目,例如选择 VM 大小.选择 VM 映像和部署 VM. 你将学习如何执行以下操作: 创建并连接到 VM 选 ...
- Azure资源管理工具Azure PowerShell介绍
什么是 Azure PowerShell? Azure PowerShell 是一组模块,提供用于通过 Windows PowerShell 管理 Azure 的 cmdlet.你可以使用 cmdle ...
- Azure PowerShell (1) PowerShell入门
<Windows Azure Platform 系列文章目录> Update: 2016-01-11 笔者文档主要都是用Azure PowerShell 0.x版本来实现的,比如0.98版 ...
- Azure PowerShell (2) 修改Azure订阅名称
<Windows Azure Platform 系列文章目录> Update: 2016-01-11 笔者文档主要都是用Azure PowerShell 0.x版本来实现的,比如0.98版 ...
- Azure PowerShell (3) 上传证书
<Windows Azure Platform 系列文章目录> 本文介绍的是国外的Azure Global Update 2015-09-01 发现一个新的命令,在Azure PowerS ...
- Azure PowerShell (4) 使用PowerShell管理多个订阅
<Windows Azure Platform 系列文章目录> 笔者手上有两个Azure账户. - Azure Global (windowsazure.com)账户.有两个订阅. - 世 ...
- Azure PowerShell (5) 使用Azure PowerShell创建简单的Azure虚拟机和Linux虚拟机
<Windows Azure Platform 系列文章目录> 本文介绍的是国外的Azure Global.如果是国内由世纪互联运维的Azure China,请参考这篇文档: Azure ...
随机推荐
- 关于python协程的一个例子的学习
例子来自https://blog.tonyseek.com/post/event-manage-with-greenlet/ 加了一些注释看懂了: 注释中的数字表示执行的顺序,这个简单的例子用到了py ...
- 二十六、【开源框架】EFW框架Winform前端开发之Grid++Report报表、条形码、Excel导出、图表控件
回<[开源]EFW框架系列文章索引> EFW框架源代码下载V1.2:http://pan.baidu.com/s/1hcnuA EFW框架实例源代码下载:http://pan ...
- WPA字典锦集
1.xiemimendictionary 字典下载(第二季),500W整理过后还有282W条不重复的密码 字典下载,600W整理过后还有400W条不重复的密码 历次泄+常用弱口令字典集合[无中文去重复 ...
- RESTful API 设计指南【转】
网络应用程序,分为前端和后端两个部分.当前的发展趋势,就是前端设备层出不穷(手机.平板.桌面电脑.其他专用设备......). 因此,必须有一种统一的机制,方便不同的前端设备与后端进行通信.这导致AP ...
- 斜堆(一)之 C语言的实现
概要 本章介绍斜堆.和以往一样,本文会先对斜堆的理论知识进行简单介绍,然后给出C语言的实现.后续再分别给出C++和Java版本的实现:实现的语言虽不同,但是原理如出一辙,选择其中之一进行了解即可.若文 ...
- Tips9: Destroy( )函数中的 延迟摧毁 功能
你知道Object.Destroy()函数吗?在脚本中用来摧毁一个游戏物体或组件,可是你知道他能在执行后延迟一段时间后才摧毁物体吗,其实很简单: using UnityEngine; public c ...
- 精品素材:WALK & RIDE 单页网站模板下载
今天,很高兴能向大家分享一个响应式的,简约风格的 HTML5 单页网站模板.Walk & Ride 这款单页网站模板是现代风格的网页模板,简洁干净,像素完美,特别适合用于推广移动 APP 应用 ...
- 一个android应用开发的感悟
对于客户端的开发,以我个人现在的水准,很难进行一个系统的讲解,只能分享下遇到的几个问题点好了! 1:对于tabhost的使用,这个东西真的是过时了:第一个版本,我是用的tabhost确实是很难用,不过 ...
- SpringMVC核心——映射问题
一.SpringMVC 使用 RequestMapping 来解决映射问题. 二.在学习 RequestMapping 之前,首先来看一张图. 这张图表示的是发送一次 http 请求时,所包含的请求 ...
- 重构第24天 分解复杂的判断(Remove Arrowhead Antipattern)
理解: 当你的代码中有很深的嵌套条件时,花括号就会在代码中形成一个长长的箭头.我们经常在不同的代码中看到这种情况,并且这种情况也会扰乱代码的可读性. 如下代码所示,HasAccess方法里面包含一些嵌 ...