取得指定資源的使用中診斷設定。
GET https://management.azure.com/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}?api-version=2021-05-01-preview
URI 參數
名稱 |
位於 |
必要 |
類型 |
Description |
name
|
path |
True
|
string
|
診斷設定的名稱。
|
resourceUri
|
path |
True
|
string
|
資源的標識碼。
|
api-version
|
query |
True
|
string
|
用於此作業的 API 版本。
|
回應
安全性
azure_auth
Azure Active Directory OAuth2 Flow
類型:
oauth2
Flow:
implicit
授權 URL:
https://login.microsoftonline.com/common/oauth2/authorize
範圍
名稱 |
Description |
user_impersonation
|
模擬您的用戶帳戶
|
範例
Gets the diagnostic setting
範例要求
GET https://management.azure.com/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6/providers/Microsoft.Insights/diagnosticSettings/mysetting?api-version=2021-05-01-preview
/**
* Samples for DiagnosticSettingsOperation Get.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/
* getDiagnosticSetting.json
*/
/**
* Sample code: Gets the diagnostic setting.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void getsTheDiagnosticSetting(com.azure.resourcemanager.AzureResourceManager azure) {
azure.diagnosticSettings().manager().serviceClient().getDiagnosticSettingsOperations().getWithResponse(
"subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6",
"mysetting", com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/969fd0c2634fbcc1975d7abe3749330a5145a97c/specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSetting.json
func ExampleDiagnosticSettingsClient_Get_getsTheDiagnosticSetting() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewDiagnosticSettingsClient().Get(ctx, "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6", "mysetting", nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.DiagnosticSettingsResource = armmonitor.DiagnosticSettingsResource{
// Name: to.Ptr("mysetting"),
// Type: to.Ptr("Microsoft.Insights/diagnosticSettings"),
// ID: to.Ptr("/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6/providers/microsoft.insights/diagnosticSettings/mysetting"),
// Properties: &armmonitor.DiagnosticSettings{
// EventHubAuthorizationRuleID: to.Ptr("/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule"),
// Logs: []*armmonitor.LogSettings{
// {
// CategoryGroup: to.Ptr("allLogs"),
// Enabled: to.Ptr(true),
// RetentionPolicy: &armmonitor.RetentionPolicy{
// Days: to.Ptr[int32](0),
// Enabled: to.Ptr(false),
// },
// }},
// MarketplacePartnerID: to.Ptr("/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1"),
// Metrics: []*armmonitor.MetricSettings{
// {
// Category: to.Ptr("WorkflowMetrics"),
// Enabled: to.Ptr(true),
// RetentionPolicy: &armmonitor.RetentionPolicy{
// Days: to.Ptr[int32](0),
// Enabled: to.Ptr(false),
// },
// }},
// StorageAccountID: to.Ptr("/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1"),
// WorkspaceID: to.Ptr(""),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Gets the active diagnostic settings for the specified resource.
*
* @summary Gets the active diagnostic settings for the specified resource.
* x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSetting.json
*/
async function getsTheDiagnosticSetting() {
const resourceUri =
"subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6";
const name = "mysetting";
const credential = new DefaultAzureCredential();
const client = new MonitorClient(credential);
const result = await client.diagnosticSettings.get(resourceUri, name);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Monitor.Models;
using Azure.ResourceManager.Monitor;
// Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSetting.json
// this example is just showing the usage of "DiagnosticSettings_Get" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this DiagnosticSettingResource created on azure
// for more information of creating DiagnosticSettingResource, please refer to the document of DiagnosticSettingResource
string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6";
string name = "mysetting";
ResourceIdentifier diagnosticSettingResourceId = DiagnosticSettingResource.CreateResourceIdentifier(resourceUri, name);
DiagnosticSettingResource diagnosticSetting = client.GetDiagnosticSettingResource(diagnosticSettingResourceId);
// invoke the operation
DiagnosticSettingResource result = await diagnosticSetting.GetAsync();
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
DiagnosticSettingData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
範例回覆
{
"id": "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6/providers/microsoft.insights/diagnosticSettings/mysetting",
"type": "Microsoft.Insights/diagnosticSettings",
"name": "mysetting",
"properties": {
"storageAccountId": "/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1",
"workspaceId": "",
"eventHubAuthorizationRuleId": "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule",
"marketplacePartnerId": "/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1",
"metrics": [
{
"category": "WorkflowMetrics",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
],
"logs": [
{
"categoryGroup": "allLogs",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
]
}
}
Gets the diagnostic setting for category
範例要求
GET https://management.azure.com/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6/providers/Microsoft.Insights/diagnosticSettings/mysetting?api-version=2021-05-01-preview
/**
* Samples for DiagnosticSettingsOperation Get.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/
* getDiagnosticSettingCategory.json
*/
/**
* Sample code: Gets the diagnostic setting for category.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void getsTheDiagnosticSettingForCategory(com.azure.resourcemanager.AzureResourceManager azure) {
azure.diagnosticSettings().manager().serviceClient().getDiagnosticSettingsOperations().getWithResponse(
"subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6",
"mysetting", com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/969fd0c2634fbcc1975d7abe3749330a5145a97c/specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSettingCategory.json
func ExampleDiagnosticSettingsClient_Get_getsTheDiagnosticSettingForCategory() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewDiagnosticSettingsClient().Get(ctx, "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6", "mysetting", nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.DiagnosticSettingsResource = armmonitor.DiagnosticSettingsResource{
// Name: to.Ptr("mysetting"),
// Type: to.Ptr(""),
// ID: to.Ptr("/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6/diagnosticSettings/service"),
// Properties: &armmonitor.DiagnosticSettings{
// EventHubAuthorizationRuleID: to.Ptr("/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule"),
// Logs: []*armmonitor.LogSettings{
// {
// Category: to.Ptr("WorkflowRuntime"),
// Enabled: to.Ptr(true),
// RetentionPolicy: &armmonitor.RetentionPolicy{
// Days: to.Ptr[int32](0),
// Enabled: to.Ptr(false),
// },
// }},
// MarketplacePartnerID: to.Ptr("/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1"),
// Metrics: []*armmonitor.MetricSettings{
// {
// Category: to.Ptr("WorkflowMetrics"),
// Enabled: to.Ptr(true),
// RetentionPolicy: &armmonitor.RetentionPolicy{
// Days: to.Ptr[int32](0),
// Enabled: to.Ptr(false),
// },
// }},
// StorageAccountID: to.Ptr("/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1"),
// WorkspaceID: to.Ptr(""),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Gets the active diagnostic settings for the specified resource.
*
* @summary Gets the active diagnostic settings for the specified resource.
* x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSettingCategory.json
*/
async function getsTheDiagnosticSettingForCategory() {
const resourceUri =
"subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6";
const name = "mysetting";
const credential = new DefaultAzureCredential();
const client = new MonitorClient(credential);
const result = await client.diagnosticSettings.get(resourceUri, name);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Monitor.Models;
using Azure.ResourceManager.Monitor;
// Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSettingCategory.json
// this example is just showing the usage of "DiagnosticSettings_Get" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this DiagnosticSettingResource created on azure
// for more information of creating DiagnosticSettingResource, please refer to the document of DiagnosticSettingResource
string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6";
string name = "mysetting";
ResourceIdentifier diagnosticSettingResourceId = DiagnosticSettingResource.CreateResourceIdentifier(resourceUri, name);
DiagnosticSettingResource diagnosticSetting = client.GetDiagnosticSettingResource(diagnosticSettingResourceId);
// invoke the operation
DiagnosticSettingResource result = await diagnosticSetting.GetAsync();
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
DiagnosticSettingData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
範例回覆
{
"id": "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6/diagnosticSettings/service",
"type": "",
"name": "mysetting",
"properties": {
"storageAccountId": "/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1",
"workspaceId": "",
"eventHubAuthorizationRuleId": "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule",
"marketplacePartnerId": "/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1",
"metrics": [
{
"category": "WorkflowMetrics",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
],
"logs": [
{
"category": "WorkflowRuntime",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
]
}
}
定義
createdByType
建立資源的身分識別類型。
名稱 |
類型 |
Description |
Application
|
string
|
|
Key
|
string
|
|
ManagedIdentity
|
string
|
|
User
|
string
|
|
DiagnosticSettingsResource
診斷設定資源。
名稱 |
類型 |
Description |
id
|
string
|
資源的完整資源識別碼。 例如 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
資源的名稱
|
properties.eventHubAuthorizationRuleId
|
string
|
事件中樞授權規則的資源標識碼。
|
properties.eventHubName
|
string
|
事件中樞的名稱。 如果未指定任何專案,則會選取預設事件中樞。
|
properties.logAnalyticsDestinationType
|
string
|
字串,指出導出至 Log Analytics 是否應該使用預設目的地類型,亦即 AzureDiagnostics,或使用建構如下的目的地類型: _。 可能的值為:Dedicated 和 null (null 是 default。)
|
properties.logs
|
LogSettings[]
|
記錄設定的清單。
|
properties.marketplacePartnerId
|
string
|
您要傳送診斷記錄之 Marketplace 資源的完整 ARM 資源識別碼。
|
properties.metrics
|
MetricSettings[]
|
計量設定的清單。
|
properties.serviceBusRuleId
|
string
|
診斷設定的服務總線規則標識碼。 這是為了維持回溯相容性。
|
properties.storageAccountId
|
string
|
您要傳送診斷記錄的記憶體帳戶資源識別碼。
|
properties.workspaceId
|
string
|
要傳送診斷記錄之Log Analytics工作區的完整ARM資源識別碼。 範例:/subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2
|
systemData
|
systemData
|
與這個資源相關的系統元數據。
|
type
|
string
|
資源類型。 例如“Microsoft.Compute/virtualMachines” 或 “Microsoft.Storage/storageAccounts”
|
ErrorResponse
描述錯誤回應的格式。
名稱 |
類型 |
Description |
code
|
string
|
錯誤碼
|
message
|
string
|
錯誤訊息,指出作業失敗的原因。
|
LogSettings
MultiTenantDiagnosticSettings 的一部分。 指定特定記錄檔的設定。
名稱 |
類型 |
Description |
category
|
string
|
套用此設定的資源類型診斷記錄類別名稱。 若要取得資源之診斷記錄類別的清單,請先執行 GET 診斷設定作業。
|
categoryGroup
|
string
|
套用此設定的資源類型診斷記錄類別群組名稱。 若要取得資源之診斷記錄類別的清單,請先執行 GET 診斷設定作業。
|
enabled
|
boolean
|
值,指出是否啟用此記錄檔。
|
retentionPolicy
|
RetentionPolicy
|
此記錄檔的保留原則。
|
MetricSettings
MultiTenantDiagnosticSettings 的一部分。 指定特定計量的設定。
名稱 |
類型 |
Description |
category
|
string
|
套用此設定的資源類型診斷計量類別名稱。 若要取得資源的診斷計量類別清單,請先執行 GET 診斷設定作業。
|
enabled
|
boolean
|
值,指出是否啟用此類別。
|
retentionPolicy
|
RetentionPolicy
|
此類別的保留原則。
|
timeGrain
|
string
|
格式ISO8601計量的timegrain。
|
RetentionPolicy
指定記錄的保留原則。
名稱 |
類型 |
Description |
days
|
integer
|
保留天數的天數。 值為 0 會無限期地保留事件。
|
enabled
|
boolean
|
值,指出是否啟用保留原則。
|
systemData
與建立和上次修改資源相關的元數據。
名稱 |
類型 |
Description |
createdAt
|
string
|
資源建立的時間戳 (UTC) 。
|
createdBy
|
string
|
建立資源的身分識別。
|
createdByType
|
createdByType
|
建立資源的身分識別類型。
|
lastModifiedAt
|
string
|
上次修改的資源時間戳 (UTC)
|
lastModifiedBy
|
string
|
上次修改資源的身分識別。
|
lastModifiedByType
|
createdByType
|
上次修改資源的身分識別類型。
|