Force cancelation of subscription in Azure with REST call

Normally you can only cancel/disable a subscription by code if the subscription is empty.

If you add IgnoreResourceCheck=true and thereby still cancel the subscription. This give you the grace time before deletion. Remember to change {subscriptionId} in the URI

https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel?IgnoreResourceCheck=true&api-version=2021-10-01

Documentation on grace period

https://docs.microsoft.com/en-us/azure/cost-management-billing/manage/cancel-azure-subscription#what-happens-after-subscription-cancellation