powershell - 如何为 Azure RM 订阅设置默认存储帐户

标签 powershell azure azure-powershell azure-resource-manager azure-storage-account

我正在尝试将 Azure Rm 订阅 (Get-AzureRMSubscription) CurrentStorageAccount 设置为特定的 Arm 存储帐户 (Get-AzureRmStorageAccount),但我无法找到cmdlet 可以做到这一点。

使用常规的旧 azure cmdlet,我可以执行以下操作将 CurrentStorageAccount 设置为

$subscription = Get-AzureSubscription
Set-AzureSubscription -SubscriptionName $subscription.SubscriptionName -CurrentStorageAccountName "somestorageaccount"

Get-AzureSubscription | select * 

就这一套了。但我无法在arm cmdlet 内执行此操作。

另一件令人困惑的事情是我使用相同的订阅,例如。 Visual Studio 企业版。使用arm和常规cmdlet get-azuresubscription我得到相同的订阅,但为什么一个订阅显示-CurrentStorageAccount而另一个订阅不显示-CurrentStorageAccount。

最佳答案

要在 PowerShell 中为当前 session 设置默认 RM 订阅,请使用

Get-AzureRmSubscription –SubscriptionName "MyFavSubscription" | Select-AzureRmSubscription

并为当前 session 设置默认 RM 存储上下文

Set-AzureRmCurrentStorageAccount –ResourceGroupName "MyFavResourceGroup" `
                                 –StorageAccountName "MyFavStorageAccountName"

关于powershell - 如何为 Azure RM 订阅设置默认存储帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36803474/

相关文章:

string - Get-Content 真正输出什么,一个字符串或几个属性?

powershell - 如何将 PowerShell cmdlet 或函数添加到我的计算机以使其始终可用?

python - 无法使用 azure 注册登录 IMP4 Outlook 电子邮件

azure - 使用 Azure WebRole 一段时间后,JSON 内容压缩将停止工作

powershell - 安装模块并删除所有以前的 powershell

azure - 在 Runbook 中使用时找不到 'Start-AzVM' 命令

c# - Powershell - 从 C# Cmdlet 获取变量

windows - 如何在 Windows 2012 Server 任务计划程序中提取所有计划作业的列表?

azure - Azure 的 DiagnosticMonitorConfiguration 的生命周期是多长?

asp.net - MSB4018 错误 Visual Studio 2015 ASP.Net 和错误将 Web 应用程序发布到 Azure