Поделиться через


Tutorial: Remove a Service Fabric cluster running in Azure

This tutorial is part five of a series, and shows you how to delete a Service Fabric cluster running in Azure. To completely delete a Service Fabric cluster you also need to delete the resources used by the cluster. You have two options: either delete the resource group that the cluster is in (which deletes the cluster resource and all other resources in the resource group) or specifically delete the cluster resource and it's associated resources (but not other resources in the resource group).

В этом руководстве описано, как:

  • Delete a resource group and all it's resources
  • Selectively delete resources from a resource group

Из этого цикла руководств вы узнаете, как выполнять следующие задачи:

Примечание.

Мы рекомендуем использовать модуль Azure Az PowerShell для взаимодействия с Azure. Сведения о начале работы см. в статье "Установка Azure PowerShell". Чтобы узнать, как перейти на модуль Az PowerShell, см. статью Миграция Azure PowerShell с AzureRM на Az.

Предпосылки

Перед началом работы с этим руководством выполните следующие действия:

Delete the resource group containing the Service Fabric cluster

Самый простой способ удалить кластер и все используемые ресурсы — удалить группу ресурсов.

Войдите в Azure и выберите идентификатор подписки, с помощью которого требуется удалить кластер. You can find your subscription ID by logging in to the Azure portal. Delete the resource group and all the cluster resources using the Remove-AzResourceGroup cmdlet or az group delete command.

Connect-AzAccount
Set-AzContext -SubscriptionId <guid>
$groupname = "sfclustertutorialgroup"
Remove-AzResourceGroup -Name $groupname -Force
az login
az account set --subscription <guid>
ResourceGroupName="sfclustertutorialgroup"
az group delete --name $ResourceGroupName

Selectively delete the cluster resource and the associated resources

If your resource group has only resources that are related to the Service Fabric cluster you want to delete, then it is easier to delete the entire resource group. If you want to selectively delete the resources in your resource group, and keep resources not associated with the cluster, then follow these steps.

List the resources in the resource group:

Connect-AzAccount
Set-AzContext -SubscriptionId <guid>
$groupname = "sfclustertutorialgroup"
Get-AzResource -ResourceGroupName $groupname | ft
az login
az account set --subscription <guid>
ResourceGroupName="sfclustertutorialgroup"
az resource list --resource-group $ResourceGroupName

For each of the resources you want to delete, run the following script:

Remove-AzResource -ResourceName "<name of the Resource>" -ResourceType "<Resource Type>" -ResourceGroupName $groupname -Force
az resource delete --name "<name of the Resource>" --resource-type "<Resource Type>" --resource-group $ResourceGroupName

To delete the cluster resource, run the following script:

Remove-AzResource -ResourceName "<name of the Resource>" -ResourceType "Microsoft.ServiceFabric/clusters" -ResourceGroupName $groupname -Force
az resource delete --name "<name of the Resource>" --resource-type "Microsoft.ServiceFabric/clusters" --resource-group $ResourceGroupName

Дальнейшие действия

Из этого руководства вы узнали, как:

  • Delete a resource group and all it's resources
  • Selectively delete resources from a resource group

Now that you've completed this tutorial, try the following: