Ola*_*dun 10 powershell cmdlets azure azure-sql-database
我有一个azure订阅,我正在尝试编写一个powershell脚本,以自动获取我目前订阅的所有资源(虚拟机,存储帐户,数据库等)的列表.有没有办法使用azure管理REST API或Azure Cmdlet执行此操作?
如果您使用的是新的Resource Manager模型(2014年推出),则可以使用以下PowerShell脚本.
Login-AzureRmAccount
Get-AzureRmResource | Export-Csv "c:\Azure Resources.csv"
Run Code Online (Sandbox Code Playgroud)
要使用Resource Manager PowerShell命令,您需要AzureRM PowerShell模块(https://docs.microsoft.com/en-us/powershell/azure/install-azurerm-ps).
Install-Module AzureRM
Run Code Online (Sandbox Code Playgroud)
有关Resource Manager和Classic模型之间差异的更多信息,请参阅https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-deployment-model.
对于具有多个订阅的用户:如果要输出多个订阅的内容,则需要在调用Get-AzureRmResource之前调用Select-AzureRmSubscription以切换到另一个订阅.
我不认为只有一个函数(或 PS Cmdlet)可以获取所有这些信息。然而,这些中的每一个都可以通过Windows Azure Service Management REST API和获取Window Azure PowerShell Cmdlets。
Windows Azure 服务管理 REST API:http://msdn.microsoft.com/en-us/library/windowsazure/ee460799.aspx。例如,如果您想列出订阅中的存储帐户,则可以使用:http ://msdn.microsoft.com/en-us/library/windowsazure/ee460787.aspx
Windows Azure PowerShell Cmdlet:http://msdn.microsoft.com/en-us/library/jj554330.aspx。同样,如果您想列出订阅中的存储帐户,您可以使用: http: //msdn.microsoft.com/en-us/library/dn205168.aspx。
| 归档时间: |
|
| 查看次数: |
36605 次 |
| 最近记录: |