你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Select-AzureStorSimpleResource
将资源设置为当前资源。
注意
本文档中引用的 cmdlet 用于管理使用 Azure Service Manager (ASM) API 的旧式 Azure 资源。 创建新资源时,建议不要使用旧的 PowerShell 模块,因为计划将停用 ASM。 有关详细信息,请参阅 Azure Service Manager 停用。
Az PowerShell 模块是建议用于管理 PowerShell 的 Azure 资源管理器 (ARM) 资源的 PowerShell 模块。
语法
Select-AzureStorSimpleResource
-ResourceName <String>
[-RegistrationKey <String>]
[-Profile <AzureSMProfile>]
[<CommonParameters>]
说明
Select-AzureStorSimpleResource cmdlet 将资源设置为当前资源。 选择资源后,其他 cmdlet 将应用于该资源上下文。
示例
示例 1:首次选择资源
PS C:\>Select-AzureStorSimpleResource -ResourceName "Contoso64-Tsqa" -RegistrationKey "<your registration key>"
ResourceId ResourceName
---------- ------------
1909806764156522689 Contoso64-Tsqa
此命令选择名为 Contoso64-Tsqa 的资源作为当前上下文。 在此示例中,计算机以前尚未初始化此上下文,因此,必须为 RegistrationKey 参数指定值。
示例 2:尝试选择资源
This command gets the current context for this computer by using the **Get-AzureStorSimpleResourceContext** cmdlet. The current selected resource is Contoso64-Tsqa. This is consistent with the previous example.
PS C:\>Get-AzureStorSimpleResourceContext
ResourceId ResourceName
---------- ------------
1909806764156522689 Contoso64-Tsqa
This command attempts to reset the resource to be Contoso02-Resource. For this example, this resource has not been previously selected. The registration key is not saved or included in the command. The command cannot select the resource.
PS C:\>Select-AzureStorSimpleResource -ResourceName "Contoso02-Resource"
Select-AzureStorSimpleResource : Could not find the persisted secret. Please use Select-AzureStorSimpleResource and
provide the Registration key once again.
示例 3:选择以前选择的资源
PS C:\>Select-AzureStorSimpleResource -ResourceName "Contoso64-Tsqa"
ResourceId ResourceName
---------- ------------
1909806764156522689 Contoso64-Tsqa
此命令选择名为 Contoso64-Tsqa 的资源作为当前上下文。 在此示例中,该上下文以前已选中,因此,无需为 RegistrationKey 参数指定值。
参数
-Profile
指定 Azure 配置文件。
类型: | AzureSMProfile |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-RegistrationKey
指定注册密钥。 首次选择资源时指定一个键。 在此 cmdlet 选择当前资源后,cmdlet 会根据需要使用此密钥。 有关详细信息,请参阅 Microsoft开发人员网络上获取服务注册密钥 (https://msdn.microsoft.com/en-us/library/azure/dn772346.aspx)。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-ResourceName
指定要选择为当前资源的资源的名称。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
输入
None
输出
StorSimpleResourceContext
此 cmdlet 返回一个 StorSimpleResourceContext 对象,该对象包含资源上下文的详细信息。