コード例 #1
0
        /// <summary>
        /// Delete the web app
        /// </summary>
        /// <param name="bearerToken">Azure bearer token</param>
        /// <param name="appUri">ResourceUri to the web app</param>
        /// <param name="alsoDeleteMetrics">Set TRUE to also delete the web app metrics</param>
        /// <param name="alsoDeleteAppServicePlanIfEmpty">Set TRUE to also delete the App Service Plan if there are no more apps left in the plan</param>
        /// <returns>True if the app was accepted for deletion, false if it failed validation/etc, NULL if there was an exception</returns>
        public static async Task <bool?> Delete(string bearerToken, ResourceUri appUri, bool alsoDeleteMetrics = false, bool alsoDeleteAppServicePlanIfEmpty = false)
        {
            if (string.IsNullOrWhiteSpace(bearerToken))
            {
                throw new ArgumentNullException(nameof(bearerToken));
            }

            RestApiResponse response = await RestApiClient.DELETE(
                bearerToken,
                $"https://management.azure.com/{appUri.ToAbsoluteAzureRMEndpointUri()}",
                CLIENT_API_VERSION,
                new Dictionary <string, string>()
            {
                { "deleteMetrics", (alsoDeleteMetrics ? "true" : "false") },
                { "deleteEmptyServerFarm", (alsoDeleteAppServicePlanIfEmpty ? "true" : "false") }
            },
                new int[] { 200, 204, 404 }
                );

            if ((!response.IsExpectedSuccess) || response.WasException)
            {
                return(null);
            }

            return(response.IsExpectedSuccess);
        }
コード例 #2
0
        /// <summary>
        /// Delete a domain registration. The domain registration must be available in the specified Azure subscription.
        /// </summary>
        /// <param name="bearerToken">The Azure bearer token</param>
        /// <param name="subscription">Subscription Id for authorization</param>
        /// <param name="resourceGroupName">Name of the Azure resource group the Azure App Service Domain is homed in</param>
        /// <param name="domainName">Domain registration to delete</param>
        /// <param name="forceDelete">If set, deletes immediately. Otherwise will delete after 24 hours</param>
        /// <returns>True if request was accepted, False if not, NULL if there was an exception</returns>
        public static async Task <bool?> Delete(string bearerToken, Guid subscription, string resourceGroupName, string domainName, bool forceDelete = false)
        {
            if (string.IsNullOrWhiteSpace(bearerToken))
            {
                throw new ArgumentNullException(nameof(bearerToken));
            }
            if (subscription == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(subscription));
            }
            if (string.IsNullOrWhiteSpace(domainName))
            {
                throw new ArgumentNullException(nameof(domainName));
            }
            if (string.IsNullOrWhiteSpace(resourceGroupName))
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }

            RestApiResponse response = await RestApiClient.DELETE(
                bearerToken,
                $"https://management.azure.com/subscriptions/{subscription:d}/resourceGroups/{resourceGroupName}/providers/Microsoft.DomainRegistration/domains/{domainName}",
                CLIENT_API_VERSION,
                new Dictionary <string, string>()
            {
                { "forceHardDeleteDomain", (forceDelete ? "true" : "false") }
            }
                , new int[] { 200, 204 }
                );

            return(response.WasException ? (bool?)null : response.IsExpectedSuccess);
        }
コード例 #3
0
        /// <summary>
        /// Delete a certificate associated with the given certificate order
        /// </summary>
        /// <param name="bearerToken">The Azure bearer token</param>
        /// <param name="subscription">Subscription Id for authorization</param>
        /// <param name="resourceGroupName">Name of the resource group the certificate exists in</param>
        /// <param name="orderNickname">A nickname for the order, specified during order creation</param>
        /// <param name="certificateName">Name of the certificate (usually the same as the order nickname)</param>
        /// <returns>Certificates or NULL</returns>
        public static async Task <bool?> DeleteCertificate(string bearerToken, Guid subscription, string resourceGroupName, string orderNickname, string certificateName)
        {
            if (string.IsNullOrWhiteSpace(bearerToken))
            {
                throw new ArgumentNullException(nameof(bearerToken));
            }
            if (subscription == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(subscription));
            }
            if (string.IsNullOrWhiteSpace(resourceGroupName))
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (string.IsNullOrWhiteSpace(orderNickname))
            {
                throw new ArgumentNullException(nameof(orderNickname));
            }
            if (string.IsNullOrWhiteSpace(certificateName))
            {
                throw new ArgumentNullException(nameof(certificateName));
            }

            RestApiResponse response = await RestApiClient.DELETE(
                bearerToken,
                $"https://management.azure.com/subscriptions/{subscription:d}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{orderNickname}/certificates/{certificateName}",
                CLIENT_API_VERSION,
                null,
                new int[] { 200, 204 }
                );

            return(response.WasException ? (bool?)null : response.IsExpectedSuccess);
        }
コード例 #4
0
        /// <summary>
        /// Delete tag. This method does not check for existence of the tag.
        /// </summary>
        /// <param name="bearerToken">Authorization bearer token</param>
        /// <param name="subscription">Guid of the subscription</param>
        /// <param name="tagName">Name of the tag</param>
        /// <returns>True if deleted, False if not.</returns>
        public static async Task <bool> Delete(string bearerToken, Guid subscription, string tagName)
        {
            if (string.IsNullOrWhiteSpace(bearerToken))
            {
                throw new ArgumentNullException(nameof(bearerToken));
            }
            if ((subscription == Guid.Empty) || (subscription == default))
            {
                throw new ArgumentNullException(nameof(subscription));
            }
            if (string.IsNullOrWhiteSpace(tagName))
            {
                throw new ArgumentNullException(nameof(tagName));
            }

            RestApiResponse response = await RestApiClient.DELETE(
                bearerToken,
                $"https://management.azure.com/subscriptions/{subscription:d}/tagNames/{tagName}",
                CLIENT_API_VERSION,
                null,
                new int[] { 200, 204 }
                );

            if ((!response.IsExpectedSuccess) || response.WasException)
            {
                return(false);
            }

            return(true);
        }
コード例 #5
0
        /// <summary>
        /// Delete a resource. Resources are queued for async deletion and status will be available only later.
        /// </summary>
        /// <param name="bearerToken">Authorization bearer token</param>
        /// <param name="resourceUri">Absolute resource Id</param>
        /// <returns>True if accepted for deletion, false if not or there was a problem</returns>
        public static async Task <bool> Delete(string bearerToken, ResourceUri resourceUri)
        {
            if (string.IsNullOrWhiteSpace(bearerToken))
            {
                throw new ArgumentNullException(nameof(bearerToken));
            }
            if ((resourceUri == null) || (!resourceUri.IsValid))
            {
                throw new ArgumentNullException(nameof(resourceUri));
            }

            RestApiResponse response = await RestApiClient.DELETE(
                bearerToken,
                resourceUri.ToAbsoluteAzureRMEndpointUri(string.Empty),
                CLIENT_API_VERSION,
                null,
                new int[] { 200, 202, 204 }
                );

            if ((!response.IsExpectedSuccess) || response.WasException)
            {
                return(false);
            }

            return(true);
        }
コード例 #6
0
        /// <summary>
        /// Delete a storage account
        /// </summary>
        /// <param name="bearerToken">Azure bearer token</param>
        /// <param name="subscription">Subscription for authorization</param>
        /// <param name="resourceGroupName">Name of the resource group the account is placed in</param>
        /// <param name="storageAccountName">Name of the storage account to delete</param>
        /// <returns>True if the task was accepted. False if not. NULL if there is a problem</returns>
        public static async Task <bool?> Delete(string bearerToken, Guid subscription, string resourceGroupName, string storageAccountName)
        {
            if (string.IsNullOrWhiteSpace(bearerToken))
            {
                throw new ArgumentNullException(nameof(bearerToken));
            }
            if (string.IsNullOrWhiteSpace(resourceGroupName))
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (string.IsNullOrWhiteSpace(storageAccountName))
            {
                throw new ArgumentNullException(nameof(storageAccountName));
            }

            RestApiResponse response = await RestApiClient.DELETE(
                bearerToken,
                $"https://management.azure.com/subscriptions/{subscription:d}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{storageAccountName}",
                CLIENT_API_VERSION,
                null,
                new int[] { 200, 204 }
                );

            if ((!response.IsExpectedSuccess) || response.WasException)
            {
                return(null);
            }

            return(response.WasException ? (bool?)null : response.IsExpectedSuccess);
        }