Windows 服务总线 1.1:寻找要删除的 Powershell 脚本 topic/subscription
Windows Service Bus 1.1: looking for Powershell script to delete topic/subscription
我想通过 power-shell 脚本删除 SB 主题及其订阅。
我可以使用 Microsoft.ServiceBus
命名空间和 NamespaceManager
class.
中可用的 C# 代码进行删除
public void DeleteSubscription(string topicPath, string name);
但是正在寻找 power-shell 脚本?
我得到了删除整个 SB 命名空间的脚本。
Remove-SBNamespace –Name 'ServiceBusDefaultNamespace' -Force
请建议可以删除单个主题及其订阅的脚本。谢谢!
我想使用一些 Azure 版本命令,这里是更新,
我正在使用命令 Remove-AzureRmServiceBusTopic -NamespaceName SB-Example1 -TopicName SB-Topic_exampl1
,它要求 -ResourceGroup
。现在对于本地服务总线,我认为我们不能传递任何`ResourceGroup,请建议
使用适当的方法登录并Select您想要的订阅和资源组,然后继续使用 SB cmdlet。
PowerShell 的登录订阅资源组
Write-Host -ForegroundColor Yellow "Login with your Azure Account"
Add-AzureRmAccount
Write-Host -ForegroundColor Yellow "Your available Subscriptions"
Get-AzureRmSubscription | Format-List -Property Name, Id
$subscriptions = @(Get-AzureRmSubscription | Select-Object -ExpandProperty Id)
$flag = $true
while ($flag) {
Write-Host -ForegroundColor Green 'Enter target Subscription Id: ' -NoNewline
$subscriptionId = Read-Host
if ($subscriptions -contains $subscriptionId) {
Select-AzureRmSubscription -SubscriptionId $subscriptionId
Write-Output "yes"
$flag = $false
break
}
elseif ($flag -eq $true) {
Write-Host "Enter valid Subscription Id"
}
}
Write-Host -ForegroundColor Yellow `r`n'Your Available Resource Groups'
Get-AzureRmResourceGroup | Select-Object -ExpandProperty ResourceGroupName
$resourceGroups = @(Get-AzureRmResourceGroup | Select-Object -ExpandProperty ResourceGroupName)
$flag = $true
while ($flag) {
Write-Host -ForegroundColor Green `r`n'Enter target Resource Group name: ' -NoNewline
$resourceGroupName = Read-Host
if ($resourceGroups -contains $resourceGroupName) {
Set-AzureRmResourceGroup -Name $resourceGroupName -Tag @{}
$flag = $false
break
}
elseif ($flag -eq $true) {
Write-Host `r`n"Enter valid Resource Group name"
}
}
要删除主题,请使用 Remove-AzureRmServiceBusTopic
您可以阅读 here and for removing Subscription you can use Remove-AzureRmServiceBusSubscription
and there is docs available for that too here。
注意: 确保您在模块列表中安装了 AzureRm.ServiceBus 模块,如果没有,则 运行 来自 Admin Powershell Install-Module -Name AzureRM.ServiceBus
我想通过 power-shell 脚本删除 SB 主题及其订阅。
我可以使用 Microsoft.ServiceBus
命名空间和 NamespaceManager
class.
public void DeleteSubscription(string topicPath, string name);
但是正在寻找 power-shell 脚本?
我得到了删除整个 SB 命名空间的脚本。
Remove-SBNamespace –Name 'ServiceBusDefaultNamespace' -Force
请建议可以删除单个主题及其订阅的脚本。谢谢!
我想使用一些 Azure 版本命令,这里是更新,
我正在使用命令 Remove-AzureRmServiceBusTopic -NamespaceName SB-Example1 -TopicName SB-Topic_exampl1
,它要求 -ResourceGroup
。现在对于本地服务总线,我认为我们不能传递任何`ResourceGroup,请建议
使用适当的方法登录并Select您想要的订阅和资源组,然后继续使用 SB cmdlet。
PowerShell 的登录订阅资源组
Write-Host -ForegroundColor Yellow "Login with your Azure Account"
Add-AzureRmAccount
Write-Host -ForegroundColor Yellow "Your available Subscriptions"
Get-AzureRmSubscription | Format-List -Property Name, Id
$subscriptions = @(Get-AzureRmSubscription | Select-Object -ExpandProperty Id)
$flag = $true
while ($flag) {
Write-Host -ForegroundColor Green 'Enter target Subscription Id: ' -NoNewline
$subscriptionId = Read-Host
if ($subscriptions -contains $subscriptionId) {
Select-AzureRmSubscription -SubscriptionId $subscriptionId
Write-Output "yes"
$flag = $false
break
}
elseif ($flag -eq $true) {
Write-Host "Enter valid Subscription Id"
}
}
Write-Host -ForegroundColor Yellow `r`n'Your Available Resource Groups'
Get-AzureRmResourceGroup | Select-Object -ExpandProperty ResourceGroupName
$resourceGroups = @(Get-AzureRmResourceGroup | Select-Object -ExpandProperty ResourceGroupName)
$flag = $true
while ($flag) {
Write-Host -ForegroundColor Green `r`n'Enter target Resource Group name: ' -NoNewline
$resourceGroupName = Read-Host
if ($resourceGroups -contains $resourceGroupName) {
Set-AzureRmResourceGroup -Name $resourceGroupName -Tag @{}
$flag = $false
break
}
elseif ($flag -eq $true) {
Write-Host `r`n"Enter valid Resource Group name"
}
}
要删除主题,请使用 Remove-AzureRmServiceBusTopic
您可以阅读 here and for removing Subscription you can use Remove-AzureRmServiceBusSubscription
and there is docs available for that too here。
注意: 确保您在模块列表中安装了 AzureRm.ServiceBus 模块,如果没有,则 运行 来自 Admin Powershell Install-Module -Name AzureRM.ServiceBus