你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Get-AzureEnvironment
获取 Azure 环境
注意
本文档中引用的 cmdlet 用于管理使用 Azure Service Manager (ASM) API 的旧式 Azure 资源。 创建新资源时,建议不要使用旧的 PowerShell 模块,因为计划将停用 ASM。 有关详细信息,请参阅 Azure Service Manager 停用。
Az PowerShell 模块是建议用于管理 PowerShell 的 Azure 资源管理器 (ARM) 资源的 PowerShell 模块。
语法
Get-AzureEnvironment
[-Name <String>]
[-Profile <AzureSMProfile>]
[<CommonParameters>]
说明
Get-AzureEnvironment cmdlet 获取可用于 Windows PowerShell 的 Azure 环境。
Azure 环境独立于 azure 部署Microsoft,例如 AzureCloud for global Azure,以及由世纪互联在中国运营的 AzureChinaCloud for Azure。 还可以使用 Azure Pack 和 WAPack cmdlet 创建本地 Azure 环境。 有关详细信息,请参阅 Azure Pack。
Get-AzureEnvironment cmdlet 从订阅数据文件中获取环境,而不是从 Azure 获取环境。 如果订阅数据文件已过时,请运行 Add-AzureAccount 或 Import-PublishSettingsFile cmdlet 以刷新它。
本主题介绍 Microsoft Azure PowerShell 模块的 0.8.10 版本中的 cmdlet。
若要获取正在使用的模块版本,请在 Azure PowerShell 控制台中键入 (Get-Module -Name Azure).Version
。
示例
示例 1:获取所有环境
PS C:\> Get-AzureEnvironment
EnvironmentName ServiceEndpoint ResourceManagerEndpoint PublishSettingsFileUrl
--------------- --------------- ----------------------- ----------------------
AzureCloud https://management.core.wi... https://management.azure.com/ https://go.microsoft.com/fw...
AzureChinaCloud https://management.core.ch... https://not-supported-serv... https://go.microsoft.com/fw...
此命令获取可用于 Windows PowerShell 的所有环境。
示例 2:按名称获取环境
PS C:\> Get-AzureEnvironment -Name AzureCloud
Name : AzureCloud
PublishSettingsFileUrl : https://go.microsoft.com/fwlink/?LinkID=301775
ServiceEndpoint : https://management.core.windows.net/
ResourceManagerEndpoint : https://management.azure.com/
ManagementPortalUrl : https://go.microsoft.com/fwlink/?LinkId=254433
ActiveDirectoryEndpoint : https://login.windows.net/
ActiveDirectoryCommonTenantId : common
StorageEndpointSuffix : core.windows.net
StorageBlobEndpointFormat : {0}://{1}.blob.core.windows.net/
StorageQueueEndpointFormat : {0}://{1}.queue.core.windows.net/
StorageTableEndpointFormat : {0}://{1}.table.core.windows.net/
GalleryEndpoint : https://gallery.azure.com/
此示例获取 AzureCloud 环境。
示例 3:获取所有环境的所有属性
PS C:\> Get-AzureEnvironment | ForEach-Object {Get-AzureEnvironment -Name $_.EnvironmentName}
此命令获取所有环境的所有属性。
该命令使用 Get-AzureEnvironment cmdlet 获取此帐户的所有 Azure 环境。 然后,它使用 Foreach-Object cmdlet 在每个环境中运行具有 Name 参数的 Get-AzureEnvironment 命令。 Name 参数的值是每个环境的 EnvironmentName 属性。
如果没有参数, Get-AzureEnvironment 仅获取环境的选定属性。
参数
-Name
仅获取指定的环境。 键入环境名称。 参数值区分大小写。 不允许使用通配符。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-Profile
指定此 cmdlet 从中读取的 Azure 配置文件。 如果未指定配置文件,此 cmdlet 将从本地默认配置文件中读取。
类型: | AzureSMProfile |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
输入
None
可以通过属性名称(而不是值)通过管道将输入传递给此 cmdlet。
输出
默认情况下, Get-AzureEnvironment 返回自定义对象。
Microsoft.WindowsAzure.Commands.Utilities.Common.WindowsAzureEnvironment
使用 Name 参数运行 Get-AzureEnvironment 时,它将返回 WindowsAzureEnvironment 对象。