Azure Powershell对ASM资源的基本操作

本文主要介绍Windows Azure Powershell对ASM资源的基本操作

1.登陆ASM模式,命令:Add-AzureAccount -Environment AzureChinaCloud

2.获取订阅信息,命令:Get-AzureSubscription

3.设置指定的操作订阅及指定的存储账号,命令:

Set-AzureSubscription -SubscriptionId “******” -CurrentStorageAccountName “******”

Select-AzureSubscription -SubscriptionId "******" -Current

4.查看默认的操作订阅或当前的操作订阅,命令:

Get-AzureSubscription -Current
    Get-AzureSubscription -Default

5.获取虚拟机的信息,命令:Get-AzureVM

6.获取存储账号的信息,命令:Get-AzureStorageAccount

7.获取自动化服务的信息,命令:Get-AzureAutomationAccount

8.查询一个陌生的操作命令,示例:get-command get-azurev*

9.获取指定命令的操作手册,示例:Get-Help Get-AzureAutomationAccount -Full

备注:

a.有时安装完Windows Azure Powershell会出现一种比较奇怪的现象,确认已经成功安装了,命令也可以使用Tab键自动补齐,但没有相应的显示参数信息,例如:

PS C:\Users\stone> get-help Add-AzureAccount -full

名称
Add-AzureAccount

语法

参数
无

输入
无

输出
System.Object

别名
无

备注
无

b.出现上述情况后,需要将Azure模块导入当前操作的Powershell,命令:Import-Module -Name Azure;并可以查看当前Powershell所拥有的模块,命令:Get-Module

PS C:\Users\stone> Import-Module -Name Azure
PS C:\Users\stone> Get-Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   4.3.1      Azure                               {Add-AzureAccount, Add-AzureApplicationGatewaySslCertificate, Add-AzureCertificate, Add-AzureDataDisk...}
Manifest   3.3.1      Azure.Storage                       {Get-AzureStorageBlob, Get-AzureStorageBlobContent, Get-AzureStorageBlobCopyState, Get-AzureStorageContainer...}
Manifest   3.3.1      AzureRM.Profile                     {Add-AzureRmAccount, Add-AzureRmEnvironment, Disable-AzureRmDataCollection, Enable-AzureRmDataCollection...}
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}

c.再次运行预操作的命令,可以成功获取到其参数

PS C:\Users\stone> Add-AzureAccount -Environment AzureChinaCloud

Id                                                                                                                           Type
--                                                                                                                           ----
WATSTest03@MicrosoftInternal.partner.onmschina.cn                                                                            User

PS C:\Users\stone> get-help Add-AzureAccount -full

名称
    Add-AzureAccount

摘要
    Adds the Azure account to Windows PowerShell

语法
    Add-AzureAccount [-Environment <String>] [-Credential <PSCredential>] [-Profile <AzureProfile>] [<CommonParameters>]

    Add-AzureAccount [-Environment <String>] [-Credential <PSCredential>] -ServicePrincipal [<SwitchParameter>] -Tenant <String> [-Profile <AzureProfile>] [<CommonParameters>]
时间: 2024-07-31 09:14:16

Azure Powershell对ASM资源的基本操作的相关文章

Azure RBAC管理ASM资源

上一篇文章介绍了Azure基于ARM的RBAC,给不同的用户分配不同的权限. 但目前在国内使用的大部分用户还是以ASM的资源为主.比如:VM.Storage.Network.WebAPP.SQL Azure等等. 如果客户希望对这些资源给不同用户授予不同的权限,基于ARM的RBAC是否可以实现呢? 基于ARM的RBAC是可以对ASM的资源进行授权管理的. 本文将以VM为例子,介绍如何针对ASM中的资源进行授权的配置和管理. 1 建ASM的虚拟机 通过老portal管理界面:http://mana

Azure PowerShell (14) 批量导出Azure ASM ACL和ARM NSG配置信息

<Windows Azure Platform 系列文章目录> 最近有一个客户需求,需要批量导出Azure Classic VM的ACL (Access Control List), 还有ARM VM的NSG (Network Security Group) 设置. 我花了一点时间,写了一个PowerShell脚本,发布在我的GitHub上: https://github.com/leizhang1984/AzureChinaPowerShell/blob/master/ARM/ExportA

Azure运维系列 3:安装和使用Azure PowerShell管理云

前面讲到了很多的管理方式,包括Azure中国最近更新的预览版管理门户和Azure云助理,都是非常不错的管理Azure的方式,今天我们再来介绍一种更加高效的管理方式Azure PowerShell.熟悉命令行的朋友都知道,Linux之所以那么好用是因为其强大的命令行工具,可以简单直接的管理我们的服务器.应用等.然而在很早之前微软也推出了自己的命令行渠道,没错就是我们大名鼎鼎的PowerShell. 为什么说PowerShell那么强大呢?因为从Windows 8之后的产品.2007之后的服务端系统

Microsoft Azure系列之四 Micorosft Azure Powershell 管理

Microsoft Azure 提供以下两种方式管理azure服务和资源 一. Azure 门户 二. Azure Powershell 你需使用一个或多个与Azure 订阅相关的 Microsoft 帐户或组织帐户进行登录. 本篇我们来看下如何使用Azure Powershell 工欲善其事,必先利其器. 首先下载azure powershell 命令行工具 下载地址:https://www.azure.cn/downloads/ 查看azure模块是否可用 查看所有azure 命令数目 下面

Azure Powershell使用已有Image创建ARM非托管磁盘虚拟机

生成Image映像文件,记录好Image的URL(下面URL为测试URL,具体请参考实际):ImageURL:https://hlmrgstoragen.blob.core.chinacloudapi.cn/vhdscopy/hlmn4sysclocap-os-2017-09-21-2CE40CEE.vhd 安装和配置Azure Powershell的步骤请参考对应的安装文档.安装配置完成后,使用下面的命令进行创建(#为注释,忽略对应的说明): #指定虚拟机名称 $vmname = "hlmsy

Azure Powershell

Azure PowerShell is a powerful scripting environment that you can use to control and automate the deployment and management of your workloads in Azure. Whether you are experienced with Windows PowerShell or a new user, instructions are available to h

Windows 上安装 Azure PowerShell及Azure PowerShell部署虚拟机

一.Azure PowerShell部署 1.使用 PowerShellGet 在 Windows 上安装 Azure PowerShell 从 Azure PowerShell 版本 6.0 开始,Azure PowerShell 需要 PowerShell 版本 5.0. 若要查看在计算机上运行的 PowerShell 的版本,运行以下命令: #$PSVersionTable.PSVersion 2.Windows PowerShell升级 https://docs.microsoft.co

Azure 中国篇--1如何使用azure powershell连接到azure

1.下载Azure SDK.安装azure powershell http://azure.microsoft.com/zh-cn/downloads/?rnd=1 2.下载azure公共设置文件 Get-AzurePublishSettingsFile -Environment "AzureChinaCloud"(中国版).Get-AzurePublishSettingsFile -Environment "AzureCloud"(国际版) 运行后自动打开IE,使

Azure PowerShell (10) 使用PowerShell导出订阅下所有的Azure VM和Cloud Service的高可用情况

<Windows Azure Platform 系列文章目录> 本文介绍的是国内由世纪互联运维的Azure China服务. 该脚本下载地址在http://files.cnblogs.com/files/threestone/SingleInstanceVM.rar 运行前提: 1.我们需要一个Azure China的账户 2.在Azure China账户下部署了若干虚拟机和Cloud Service 3.我们还需要下载Azure PowerShell 如何运行该PowerShell 1.首先