Azure Monitor의 진단 설정에 대한 Resource Manager 템플릿 샘플
이 문서에는 Azure 리소스에 대한 진단 설정을 만들기 위한 Azure Resource Manager 템플릿 샘플이 포함되어 있습니다. 각 샘플에는 템플릿 파일과 템플릿에 제공할 샘플 값이 포함된 매개 변수 파일이 포함되어 있습니다.
Azure 리소스에 대한 진단 설정을 만들려면 <resource namespace>/providers/diagnosticSettings
형식의 리소스를 템플릿에 추가합니다. 이 문서에서는 일부 리소스 유형에 대한 예제를 제공하지만 동일한 패턴을 다른 리소스 유형에 적용할 수 있습니다. 허용되는 로그 및 메트릭 컬렉션은 리소스 종류마다 다릅니다.
참고 항목
사용 가능한 샘플 목록과 Azure 구독에 배포하는 방법에 대한 지침은 Azure Monitor에 대한 Azure Resource Manager 샘플을 참조하세요.
활동 로그에 대한 진단 설정
다음 샘플에서는 Microsoft.Insights/diagnosticSettings
유형의 리소스를 템플릿에 추가하여 활동 로그에 대한 진단 설정을 만듭니다.
Important
활동 로그에 대한 진단 설정은 Azure 리소스의 설정과 같은 리소스 그룹이 아닌 구독에 대해 생성됩니다. Resource Manager 템플릿을 배포하려면 PowerShell에 대한 New-AzSubscriptionDeployment
또는 Azure CLI에 대한 az deployment sub create
를 사용합니다.
템플릿 파일
targetScope = 'subscription'
@description('The name of the diagnostic setting.')
param settingName string
@description('The resource Id for the workspace.')
param workspaceId string
@description('The resource Id for the storage account.')
param storageAccountId string
@description('The resource Id for the event hub authorization rule.')
param eventHubAuthorizationRuleId string
@description('The name of the event hub.')
param eventHubName string
resource setting 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: settingName
properties: {
workspaceId: workspaceId
storageAccountId: storageAccountId
eventHubAuthorizationRuleId: eventHubAuthorizationRuleId
eventHubName: eventHubName
logs: [
{
category: 'Administrative'
enabled: true
}
{
category: 'Security'
enabled: true
}
{
category: 'ServiceHealth'
enabled: true
}
{
category: 'Alert'
enabled: true
}
{
category: 'Recommendation'
enabled: true
}
{
category: 'Policy'
enabled: true
}
{
category: 'Autoscale'
enabled: true
}
{
category: 'ResourceHealth'
enabled: true
}
]
}
}
매개 변수 파일
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"settingName": {
"value": "Send to all locations"
},
"workspaceId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourcegroups/MyResourceGroup/providers/microsoft.operationalinsights/workspaces/MyWorkspace"
},
"storageAccountId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/MyResourceGroup/providers/Microsoft.Storage/storageAccounts/mystorageaccount"
},
"eventHubAuthorizationRuleId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/MyResourceGroup/providers/Microsoft.EventHub/namespaces/MyNameSpace/authorizationrules/RootManageSharedAccessKey"
},
"eventHubName": {
"value": "my-eventhub"
}
}
}
Azure Data Explorer에 대한 진단 설정
다음 샘플에서는 Microsoft.Kusto/clusters/providers/diagnosticSettings
형식의 리소스를 템플릿에 추가하여 Azure Data Explorer 클러스터에 대한 진단 설정을 만듭니다.
템플릿 파일
param clusterName string
param settingName string
param workspaceId string
param storageAccountId string
param eventHubAuthorizationRuleId string
param eventHubName string
resource cluster 'Microsoft.Kusto/clusters@2022-02-01' existing = {
name: clusterName
}
resource setting 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: settingName
scope: cluster
properties: {
workspaceId: workspaceId
storageAccountId: storageAccountId
eventHubAuthorizationRuleId: eventHubAuthorizationRuleId
eventHubName: eventHubName
metrics: []
logs: [
{
category: 'Command'
categoryGroup: null
enabled: true
retentionPolicy: {
enabled: false
days: 0
}
}
{
category: 'Query'
categoryGroup: null
enabled: true
retentionPolicy: {
enabled: false
days: 0
}
}
{
category: 'Journal'
categoryGroup: null
enabled: true
retentionPolicy: {
enabled: false
days: 0
}
}
{
category: 'SucceededIngestion'
categoryGroup: null
enabled: false
retentionPolicy: {
enabled: false
days: 0
}
}
{
category: 'FailedIngestion'
categoryGroup: null
enabled: false
retentionPolicy: {
enabled: false
days: 0
}
}
{
category: 'IngestionBatching'
categoryGroup: null
enabled: false
retentionPolicy: {
enabled: false
days: 0
}
}
{
category: 'TableUsageStatistics'
categoryGroup: null
enabled: false
retentionPolicy: {
enabled: false
days: 0
}
}
{
category: 'TableDetails'
categoryGroup: null
enabled: false
retentionPolicy: {
enabled: false
days: 0
}
}
]
}
}
매개 변수 파일
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"clusterName": {
"value": "kustoClusterName"
},
"diagnosticSettingName": {
"value": "A new Diagnostic Settings configuration"
},
"workspaceId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourcegroups/MyResourceGroup/providers/microsoft.operationalinsights/workspaces/MyWorkspace"
},
"storageAccountId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/MyResourceGroup/providers/Microsoft.Storage/storageAccounts/mystorageaccount"
},
"eventHubAuthorizationRuleId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/MyResourceGroup/providers/Microsoft.EventHub/namespaces/MyNameSpace/authorizationrules/RootManageSharedAccessKey"
},
"eventHubName": {
"value": "myEventhub"
}
}
}
템플릿 파일: 'audit' 범주 그룹 사용
param clusterName string
param settingName string
param workspaceId string
param storageAccountId string
param eventHubAuthorizationRuleId string
param eventHubName string
resource cluster 'Microsoft.Kusto/clusters@2022-02-01' existing = {
name: clusterName
}
resource setting 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: settingName
scope: cluster
properties: {
workspaceId: workspaceId
storageAccountId: storageAccountId
eventHubAuthorizationRuleId: eventHubAuthorizationRuleId
eventHubName: eventHubName
logs: [
{
category: null
categoryGroup: 'audit'
enabled: true
retentionPolicy: {
enabled: false
days: 0
}
}
]
}
}
Azure Key Vault에 대한 진단 설정
다음 샘플에서는 Microsoft.KeyVault/vaults/providers/diagnosticSettings
형식의 리소스를 템플릿에 추가하여 Azure Key Vault의 인스턴스에 대한 진단 설정을 만듭니다.
Important
Azure Key Vault의 경우 이벤트 허브는 키 자격 증명 모음과 동일한 지역에 있어야 합니다.
템플릿 파일
@description('The name of the diagnostic setting.')
param settingName string
@description('The name of the key vault.')
param vaultName string
@description('The resource Id of the workspace.')
param workspaceId string
@description('The resource Id of the storage account.')
param storageAccountId string
@description('The resource Id for the event hub authorization rule.')
param eventHubAuthorizationRuleId string
@description('The name of the event hub.')
param eventHubName string
resource vault 'Microsoft.KeyVault/vaults@2021-11-01-preview' existing = {
name: vaultName
}
resource setting 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: settingName
scope: vault
properties: {
workspaceId: workspaceId
storageAccountId: storageAccountId
eventHubAuthorizationRuleId: eventHubAuthorizationRuleId
eventHubName: eventHubName
logs: [
{
category: 'AuditEvent'
enabled: true
}
]
metrics: [
{
category: 'AllMetrics'
enabled: true
}
]
}
}
매개 변수 파일
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"settingName": {
"value": "Send to all locations"
},
"vaultName": {
"value": "MyVault"
},
"workspaceId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourcegroups/MyResourceGroup/providers/microsoft.operationalinsights/workspaces/MyWorkspace"
},
"storageAccountId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/MyResourceGroup/providers/Microsoft.Storage/storageAccounts/mystorageaccount"
},
"eventHubAuthorizationRuleId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/MyResourceGroup/providers/Microsoft.EventHub/namespaces/MyNameSpace/authorizationrules/RootManageSharedAccessKey"
},
"eventHubName": {
"value": "my-eventhub"
}
}
}
Azure SQL Database에 대한 진단 설정
다음 샘플에서는 microsoft.sql/servers/databases/providers/diagnosticSettings
형식의 리소스를 템플릿에 추가하여 Azure SQL Database의 인스턴스에 대한 진단 설정을 만듭니다.
템플릿 파일
@description('The name of the diagnostic setting.')
param settingName string
@description('The name of the Azure SQL database server.')
param serverName string
@description('The name of the SQL database.')
param dbName string
@description('The resource Id of the workspace.')
param workspaceId string
@description('The resource Id of the storage account.')
param storageAccountId string
@description('The resource Id of the event hub authorization rule.')
param eventHubAuthorizationRuleId string
@description('The name of the event hub.')
param eventHubName string
resource dbServer 'Microsoft.Sql/servers@2021-11-01-preview' existing = {
name: serverName
}
resource db 'Microsoft.Sql/servers/databases@2021-11-01-preview' existing = {
parent: dbServer
name: dbName
}
resource setting 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: settingName
scope: db
properties: {
workspaceId: workspaceId
storageAccountId: storageAccountId
eventHubAuthorizationRuleId: eventHubAuthorizationRuleId
eventHubName: eventHubName
logs: [
{
category: 'SQLInsights'
enabled: true
}
{
category: 'AutomaticTuning'
enabled: true
}
{
category: 'QueryStoreRuntimeStatistics'
enabled: true
}
{
category: 'QueryStoreWaitStatistics'
enabled: true
}
{
category: 'Errors'
enabled: true
}
{
category: 'DatabaseWaitStatistics'
enabled: true
}
{
category: 'Timeouts'
enabled: true
}
{
category: 'Blocks'
enabled: true
}
{
category: 'Deadlocks'
enabled: true
}
]
metrics: [
{
category: 'Basic'
enabled: true
}
{
category: 'InstanceAndAppAdvanced'
enabled: true
}
{
category: 'WorkloadManagement'
enabled: true
}
]
}
}
매개 변수 파일
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"settingName": {
"value": "Send to all locations"
},
"serverName": {
"value": "MySqlServer"
},
"dbName": {
"value": "MySqlDb"
},
"workspaceId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourcegroups/MyResourceGroup/providers/microsoft.operationalinsights/workspaces/MyWorkspace"
},
"storageAccountId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/MyResourceGroup/providers/Microsoft.Storage/storageAccounts/mystorageaccount"
},
"eventHubAuthorizationRuleId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/MyResourceGroup/providers/Microsoft.EventHub/namespaces/MyNameSpace/authorizationrules/RootManageSharedAccessKey"
},
"eventHubName": {
"value": "my-eventhub"
}
}
}
Azure SQL Managed Instance에 대한 진단 설정
다음 샘플에서는 microsoft.sql/managedInstances/providers/diagnosticSettings
형식의 리소스를 템플릿에 추가하여 Azure SQL Managed Instance의 인스턴스에 대한 진단 설정을 만듭니다.
템플릿 파일
param sqlManagedInstanceName string
param diagnosticSettingName string
param diagnosticWorkspaceId string
param storageAccountId string
param eventHubAuthorizationRuleId string
param eventHubName string
resource instance 'Microsoft.Sql/managedInstances@2021-11-01-preview' existing = {
name: sqlManagedInstanceName
}
resource setting 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: diagnosticSettingName
scope: instance
properties: {
workspaceId: diagnosticWorkspaceId
storageAccountId: storageAccountId
eventHubAuthorizationRuleId: eventHubAuthorizationRuleId
eventHubName: eventHubName
logs: [
{
category: 'ResourceUsageStats'
enabled: true
}
{
category: 'DevOpsOperationsAudit'
enabled: true
}
{
category: 'SQLSecurityAuditEvents'
enabled: true
}
]
}
}
매개 변수 파일
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"sqlManagedInstanceName": {
"value": "MyInstanceName"
},
"diagnosticSettingName": {
"value": "Send to all locations"
},
"diagnosticWorkspaceId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourcegroups/MyResourceGroup/providers/microsoft.operationalinsights/workspaces/MyWorkspace"
},
"storageAccountId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/MyResourceGroup/providers/Microsoft.Storage/storageAccounts/mystorageaccount"
},
"eventHubAuthorizationRuleId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/MyResourceGroup/providers/Microsoft.EventHub/namespaces/MyNameSpace/authorizationrules/RootManageSharedAccessKey"
},
"eventHubName": {
"value": "myEventhub"
}
}
}
Azure SQL Database의 관리되는 인스턴스에 대한 진단 설정
다음 샘플에서는 microsoft.sql/managedInstances/databases/providers/diagnosticSettings
형식의 리소스를 템플릿에 추가하여 Azure SQL Database의 관리되는 인스턴스에 대한 진단 설정을 만듭니다.
템플릿 파일
param sqlManagedInstanceName string
param sqlManagedDatabaseName string
param diagnosticSettingName string
param diagnosticWorkspaceId string
param storageAccountId string
param eventHubAuthorizationRuleId string
param eventHubName string
resource dbInstance 'Microsoft.Sql/managedInstances@2021-11-01-preview' existing = {
name:sqlManagedInstanceName
}
resource db 'Microsoft.Sql/managedInstances/databases@2021-11-01-preview' existing = {
name: sqlManagedDatabaseName
parent: dbInstance
}
resource setting 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: diagnosticSettingName
scope: db
properties: {
workspaceId: diagnosticWorkspaceId
storageAccountId: storageAccountId
eventHubAuthorizationRuleId: eventHubAuthorizationRuleId
eventHubName: eventHubName
logs: [
{
category: 'SQLInsights'
enabled: true
}
{
category: 'QueryStoreRuntimeStatistics'
enabled: true
}
{
category: 'QueryStoreWaitStatistics'
enabled: true
}
{
category: 'Errors'
enabled: true
}
]
}
}
매개 변수 파일
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"sqlManagedInstanceName": {
"value": "MyInstanceName"
},
"sqlManagedDatabaseName": {
"value": "MyManagedDatabaseName"
},
"diagnosticSettingName": {
"value": "Send to all locations"
},
"diagnosticWorkspaceId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourcegroups/MyResourceGroup/providers/microsoft.operationalinsights/workspaces/MyWorkspace"
},
"storageAccountId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/MyResourceGroup/providers/Microsoft.Storage/storageAccounts/mystorageaccount"
},
"eventHubAuthorizationRuleId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/MyResourceGroup/providers/Microsoft.EventHub/namespaces/MyNameSpace/authorizationrules/RootManageSharedAccessKey"
},
"eventHubName": {
"value": "myEventhub"
}
}
}
Recovery Services 자격 증명 모음에 대한 진단 설정
다음 샘플에서는 microsoft.recoveryservices/vaults/providers/diagnosticSettings
형식의 리소스를 템플릿에 추가하여 Azure Recovery Services 자격 증명에 대한 진단 설정을 만듭니다. 이 예제에서는 Azure 리소스 로그에 설명된 대로 컬렉션 모드를 지정합니다. logAnalyticsDestinationType
속성에 대해 Dedicated
또는 AzureDiagnostics
를 지정합니다.
템플릿 파일
param recoveryServicesName string
param settingName string
param workspaceId string
param storageAccountId string
param eventHubAuthorizationRuleId string
param eventHubName string
resource vault 'Microsoft.RecoveryServices/vaults@2021-08-01' existing = {
name: recoveryServicesName
}
resource setting 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: settingName
scope: vault
properties: {
workspaceId: workspaceId
storageAccountId: storageAccountId
eventHubAuthorizationRuleId: eventHubAuthorizationRuleId
eventHubName: eventHubName
logs: [
{
category: 'AzureBackupReport'
enabled: false
}
{
category: 'CoreAzureBackup'
enabled: true
}
{
category: 'AddonAzureBackupJobs'
enabled: true
}
{
category: 'AddonAzureBackupAlerts'
enabled: true
}
{
category: 'AddonAzureBackupPolicy'
enabled: true
}
{
category: 'AddonAzureBackupStorage'
enabled: true
}
{
category: 'AddonAzureBackupProtectedInstance'
enabled: true
}
{
category: 'AzureSiteRecoveryJobs'
enabled: false
}
{
category: 'AzureSiteRecoveryEvents'
enabled: false
}
{
category: 'AzureSiteRecoveryReplicatedItems'
enabled: false
}
{
category: 'AzureSiteRecoveryReplicationStats'
enabled: false
}
{
category: 'AzureSiteRecoveryRecoveryPoints'
enabled: false
}
{
category: 'AzureSiteRecoveryReplicationDataUploadRate'
enabled: false
}
{
category: 'AzureSiteRecoveryProtectedDiskDataChurn'
enabled: false
}
]
logAnalyticsDestinationType: 'Dedicated'
}
}
매개 변수 파일
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"settingName": {
"value": "Send to all locations"
},
"recoveryServicesName": {
"value": "my-vault"
},
"workspaceId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourcegroups/MyResourceGroup/providers/microsoft.operationalinsights/workspaces/MyWorkspace"
},
"storageAccountId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/MyResourceGroup/providers/Microsoft.Storage/storageAccounts/mystorageaccount"
},
"eventHubAuthorizationRuleId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/MyResourceGroup/providers/Microsoft.EventHub/namespaces/MyNameSpace/authorizationrules/RootManageSharedAccessKey"
},
"eventHubName": {
"value": "my-eventhub"
}
}
}
Log Analytics 작업 영역에 대한 진단 설정
다음 샘플에서는 Microsoft.OperationalInsights/workspaces/providers/diagnosticSettings
형식의 리소스를 템플릿에 추가하여 Log Analytics 작업 영역에 대한 진단 설정을 만듭니다. 이 예제에서는 작업 영역에서 실행된 쿼리에 대한 감사 데이터를 동일한 작업 영역으로 보냅니다.
템플릿 파일
param workspaceName string
param settingName string
param workspaceId string
param storageAccountId string
param eventHubAuthorizationRuleId string
param eventHubName string
resource workspace 'Microsoft.OperationalInsights/workspaces@2021-12-01-preview' existing = {
name: workspaceName
}
resource setting 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: settingName
scope: workspace
properties: {
workspaceId: workspaceId
storageAccountId: storageAccountId
eventHubAuthorizationRuleId: eventHubAuthorizationRuleId
eventHubName: eventHubName
logs: [
{
category: 'Audit'
enabled: true
}
]
}
}
매개 변수 파일
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"settingName": {
"value": "Send to all locations"
},
"workspaceName": {
"value": "MyWorkspace"
},
"workspaceId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourcegroups/MyResourceGroup/providers/microsoft.operationalinsights/workspaces/MyWorkspace"
},
"storageAccountId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/MyResourceGroup/providers/Microsoft.Storage/storageAccounts/mystorageaccount"
},
"eventHubAuthorizationRuleId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/MyResourceGroup/providers/Microsoft.EventHub/namespaces/MyNameSpace/authorizationrules/RootManageSharedAccessKey"
},
"eventHubName": {
"value": "my-eventhub"
}
}
}
Azure Storage에 대한 진단 설정
다음 샘플에서는 Azure Storage 계정에서 사용할 수 있는 각 스토리지 서비스 엔드포인트에 대한 진단 설정을 만듭니다. 계정에서 사용할 수 있는 각 개별 스토리지 서비스에 설정이 적용됩니다. 사용할 수 있는 스토리지 서비스는 스토리지 계정 유형에 따라 달라집니다.
이 템플릿은 계정에 대해 존재하는 경우에만 계정에 스토리지 서비스에 대한 진단 설정을 만듭니다. 사용 가능한 각 서비스에 대해 진단 설정은 트랜잭션 메트릭과 읽기, 쓰기 및 삭제 작업을 위한 리소스 로그 컬렉션을 사용하도록 설정합니다.
템플릿 파일
main.bicep
param storageAccountName string
param settingName string
param storageSyncName string
param workspaceId string
module nested './module.bicep' = {
name: 'nested'
params: {
endpoints: reference(resourceId('Microsoft.Storage/storageAccounts', storageAccountName), '2019-06-01', 'Full').properties.primaryEndpoints
settingName: settingName
storageAccountName: storageAccountName
storageSyncName: storageSyncName
workspaceId: workspaceId
}
}
module.bicep
param endpoints object
param settingName string
param storageAccountName string
param storageSyncName string
param workspaceId string
var hasblob = contains(endpoints, 'blob')
var hastable = contains(endpoints, 'table')
var hasfile = contains(endpoints, 'file')
var hasqueue = contains(endpoints, 'queue')
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-09-01' existing = {
name: storageAccountName
}
resource diagnosticSetting 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: settingName
scope: storageAccount
properties: {
workspaceId: workspaceId
storageAccountId: resourceId('Microsoft.Storage/storageAccounts', storageSyncName)
metrics: [
{
category: 'Transaction'
enabled: true
}
]
}
}
resource blob 'Microsoft.Storage/storageAccounts/blobServices@2021-09-01' existing = {
name:'default'
parent:storageAccount
}
resource blobSetting 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = if (hasblob) {
name: settingName
scope: blob
properties: {
workspaceId: workspaceId
storageAccountId: resourceId('Microsoft.Storage/storageAccounts', storageSyncName)
logs: [
{
category: 'StorageRead'
enabled: true
}
{
category: 'StorageWrite'
enabled: true
}
{
category: 'StorageDelete'
enabled: true
}
]
metrics: [
{
category: 'Transaction'
enabled: true
}
]
}
}
resource table 'Microsoft.Storage/storageAccounts/tableServices@2021-09-01' existing = {
name:'default'
parent:storageAccount
}
resource tableSetting 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = if (hastable) {
name: settingName
scope: table
properties: {
workspaceId: workspaceId
storageAccountId: resourceId('Microsoft.Storage/storageAccounts', storageSyncName)
logs: [
{
category: 'StorageRead'
enabled: true
}
{
category: 'StorageWrite'
enabled: true
}
{
category: 'StorageDelete'
enabled: true
}
]
metrics: [
{
category: 'Transaction'
enabled: true
}
]
}
}
resource file 'Microsoft.Storage/storageAccounts/fileServices@2021-09-01' existing = {
name:'default'
parent:storageAccount
}
resource fileSetting 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = if (hasfile) {
name: settingName
scope: file
properties: {
workspaceId: workspaceId
storageAccountId: resourceId('Microsoft.Storage/storageAccounts', storageSyncName)
logs: [
{
category: 'StorageRead'
enabled: true
}
{
category: 'StorageWrite'
enabled: true
}
{
category: 'StorageDelete'
enabled: true
}
]
metrics: [
{
category: 'Transaction'
enabled: true
}
]
}
}
resource queue 'Microsoft.Storage/storageAccounts/queueServices@2021-09-01' existing = {
name:'default'
parent:storageAccount
}
resource queueSetting 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = if (hasqueue) {
name: settingName
scope: queue
properties: {
workspaceId: workspaceId
storageAccountId: resourceId('Microsoft.Storage/storageAccounts', storageSyncName)
logs: [
{
category: 'StorageRead'
enabled: true
}
{
category: 'StorageWrite'
enabled: true
}
{
category: 'StorageDelete'
enabled: true
}
]
metrics: [
{
category: 'Transaction'
enabled: true
}
]
}
}
매개 변수 파일
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountName": {
"value": "mymonitoredstorageaccount"
},
"settingName": {
"value": "Send to all locations"
},
"storageSyncName": {
"value": "mystorageaccount"
},
"workspaceId": {
"value": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourcegroups/MyResourceGroup/providers/microsoft.operationalinsights/workspaces/MyWorkspace"
}
}
}