【问题标题】:New-AzureRmEventHub gives error in PowerShellNew-AzureRmEventHub 在 PowerShell 中给出错误
【发布时间】:2018-02-25 00:25:35
【问题描述】:

我正在尝试运行 PowerShell 脚本,但在这一行出现错误:

$eventHub = New-AzureRmEventHub -ResourceGroupName $eventHubConfig.resourceGroupName -NamespaceName $eventHubConfig.namespace -Location $location -EventHubName $hubConfig.Value.name

错误是这样的:

New-AzureRmEventHub :无法使用 指定的命名参数。在 C:\Users\David\Documents\EnvScripts\Components\EventHubs.ps1:108 字符:16 + ... $eventHub = New-AzureRmEventHub -ResourceGroupName $eventHubConfig.re ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [New-AzureRmEventHub], ParameterBindingException + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.Azure.Commands.EventHub.Commands.EventHub.NewAzureRmEven 中心

我传递的参数是这些值:

eventHubConfig.resourceGroupName: MyApp_David eventHubConfig.namespace: myapp-eventhub-david location: Canada East hubConfig.Value.name: myapp-user-position-transactions-Debug

我在同事的环境中运行这个脚本,他没有这个问题...我是否缺少 PowerShell 模块?我在我的 PowerShell 中安装并导入了 AzureRM

【问题讨论】:

  • 您的 Azure PowerShell 版本是什么? Get-Module -ListAvailable -Name Azure -Refresh 使用 cmdlet 检查它。
  • Azure 版本 2.1.0
  • 这是旧版本。当你添加-MessageRetentionInDays 3时,你解决了这个问题吗?
  • 我在我的实验室里测试,我得到了和你一样的错误日志。我添加-MessageRetentionInDays 3,我解决了这个问题。

标签: powershell azure


【解决方案1】:

我在实验室中使用了你的命令,我遇到了与你相同的错误日志。我的 Azure Power Shell 版本是 4.3.1。

我在添加-MessageRetentionInDays 3 时解决了这个问题。

更多信息请参考这个link:Use PowerShell to manage Event Hubs resources

【讨论】:

  • 是的,这解决了。尽管我的脚本仍然为其他命令提供错误,但这可能是相同的原因并且必须添加缺少的属性。奇怪的是它可以在我同事的机器上运行。如何将我的 Azure PowerShell 版本更新到 4.3.1?
  • @Darius 你可以从link下载msi并安装它。
  • 好的,谢谢。我做到了。自从费利佩·比诺托首先回答后,我现在感到很尴尬,但我不在办公室进行测试……对不起,费利佩……也为你 +1.. :/
【解决方案2】:

确保命名空间已经存在并且您使用 -MessageRetentionInDays 和 -PartitionCount 参数。尽管文档说它们不是必需的,但它们似乎是。

【讨论】:

    【解决方案3】:

    升级 AzureRM 模块应该可以解决这个问题。获取最新 AzureRM 模块的链接https://www.powershellgallery.com/packages/AzureRM/6.5.0

    【讨论】:

      猜你喜欢
      • 2015-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多