sliit-foss / gists

MIT License
5 stars 2 forks source link

Deletes all topics in a service bus #4

Open GIHAA opened 6 months ago

GIHAA commented 6 months ago
resource_group=your_rg
namespace=your_namespace

topics=$(az servicebus topic list --resource-group $resource_group --namespace-name $namespace)

ids=""

for i in $(seq 0 $(echo "${topics}" | jq '. | length'))
do
   ids="$ids $(echo "${topics}" | jq ".[$i].id")"
done

az servicebus topic delete --resource-group $resource_group --namespace-name $namespace --ids $ids
ThulinaWickramasinghe commented 5 months ago

@QuintusJoyal Can you look into this?

QuintusJoyal commented 5 months ago

To get all topic ids you can use --query global parameter https://learn.microsoft.com/en-us/cli/azure/servicebus/topic?view=azure-cli-latest#az-servicebus-topic-list

ids=$(az servicebus topic list \
    --resource-group $resource_group \
    --namespace-name $namespace \
    --query "[].id" -o tsv)
ThulinaWickramasinghe commented 5 months ago

@QuintusJoyal Okay create the gist with the version using query. If it seems convenient add references, including ones to JMESPath.

cc -: @akalanka47000

ThulinaWickramasinghe commented 4 months ago

@QbicSquid Can you look into this.