刪除訂用帳戶中的原則定義。
此作業會刪除指定訂用帳戶中具有指定名稱的原則定義。
DELETE https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}?api-version=2023-04-01
URI 參數
名稱 |
位於 |
必要 |
類型 |
Description |
policyDefinitionName
|
path |
True
|
string
pattern: ^[^<>*%&:\?.+/]*[^<>*%&:\?.+/ ]+$
|
要刪除的原則定義名稱。
|
subscriptionId
|
path |
True
|
string
(uuid)
|
目標訂用帳戶的標識碼。 此值必須是 UUID。
|
api-version
|
query |
True
|
string
minLength: 1
|
要用於這項作業的 API 版本。
|
回應
名稱 |
類型 |
Description |
200 OK
|
|
還行
|
204 No Content
|
|
無內容
|
Other Status Codes
|
CloudError
|
描述作業失敗原因的錯誤回應。
|
安全性
azure_auth
Azure Active Directory OAuth2 Flow。
類型:
oauth2
Flow:
implicit
授權 URL:
https://login.microsoftonline.com/common/oauth2/authorize
範圍
名稱 |
Description |
user_impersonation
|
模擬您的用戶帳戶
|
範例
Delete a policy definition
範例要求
DELETE https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming?api-version=2023-04-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.resource import PolicyClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-resource
# USAGE
python delete_policy_definition.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = PolicyClient(
credential=DefaultAzureCredential(),
subscription_id="ae640e6b-ba3e-4256-9d62-2993eecfa6f2",
)
client.policy_definitions.delete(
policy_definition_name="ResourceNaming",
)
# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicyDefinition.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armpolicy_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicyDefinition.json
func ExampleDefinitionsClient_Delete() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armpolicy.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
_, err = clientFactory.NewDefinitionsClient().Delete(ctx, "ResourceNaming", nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
定義
CloudError
Object
原則作業的錯誤回應。
名稱 |
類型 |
Description |
error
|
ErrorResponse
|
錯誤回應
所有 Azure Resource Manager API 的常見錯誤回應,以傳回失敗作業的錯誤詳細數據。 (這也遵循 OData 錯誤回應格式。)
|
ErrorAdditionalInfo
Object
資源管理錯誤其他資訊。
名稱 |
類型 |
Description |
info
|
object
|
其他資訊。
|
type
|
string
|
其他信息類型。
|
ErrorResponse
Object
錯誤回應