Hello !
Thank you for posting on Microsoft Learn Q&A.
What I understood is that -Setting is being passed a JSON string but the Service Fabric cmdlet expects a PowerShell object also Azure Diagnostics needs public and protected settings and your sinks names don’t line up.
# --- variables you set ---
$rgName = "XXXXXX-px-msfc-usnc1-rg"
$clusterName = "XXXXXX-px-msfc"
$nodeTypeName = "app1" # repeat for other node types
$publisher = "Microsoft.Azure.Diagnostics"
$extType = "IaaSDiagnostics"
$extName = "IaaSDiagnostics-$nodeTypeName"
$extVersion = "1.5"
$aiKeyOrConn = "00000000-0000-0000-0000-000000000000" # your AI instrumentation key (or connection string if you use that format)
$saName = "mystorageaccount"
$saKey = "<storage-account-key>"
$saEndpoint = "https://core.windows.net" # default
# --- PUBLIC settings: hashtable, not JSON string ---
$public = @{
"StorageAccount" = $saName
"WadCfg" = @{
"DiagnosticMonitorConfiguration" = @{
"overallQuotaInMB" = 50000
"SinksConfig" = @{
"Sink" = @(
@{
"name" = "AISink"
"ApplicationInsights" = $aiKeyOrConn # instrumentation key or connection string
}
)
}
"PerformanceCounters" = @{
"scheduledTransferPeriod" = "PT1M"
"sinks" = "AISink" # must match the Sink.name above
"PerformanceCounterConfiguration" = @(
@{
"counterSpecifier" = "\Processor(_Total)\% Processor Time"
"sampleRate" = "PT1M"
"unit" = "percent"
}
)
}
"Directories" = @{
"scheduledTransferPeriod" = "PT5M"
"IISLogs" = @{ "containerName" = "iislogs" }
"FailedRequestLogs" = @{ "containerName" = "iisfailed" }
}
"EtwProviders" = @{
"EtwEventSourceProviderConfiguration" = @(
@{
"provider" = "Microsoft-ServiceFabric-Actors"
"scheduledTransferKeywordFilter" = "1"
"scheduledTransferPeriod" = "PT5M"
"DefaultEvents" = @{ "eventDestination" = "ServiceFabricReliableActorEventTable" }
},
@{
"provider" = "Microsoft-ServiceFabric-Services"
"scheduledTransferPeriod" = "PT5M"
"DefaultEvents" = @{ "eventDestination" = "ServiceFabricReliableServiceEventTable" }
}
)
"EtwManifestProviderConfiguration" = @(
@{
"provider" = "cbd93bc2-71e5-4566-b3a7-XXXXXXXXXXXX"
"scheduledTransferLogLevelFilter" = "Information"
"scheduledTransferKeywordFilter" = "4611686018427387928"
"scheduledTransferPeriod" = "PT5M"
"DefaultEvents" = @{ "eventDestination" = "ServiceFabricSystemEventTable" }
},
@{
"provider" = "02d06793-efeb-48c8-8f7f-XXXXXXXXXXXX"
"scheduledTransferLogLevelFilter" = "Information"
"scheduledTransferKeywordFilter" = "4611686018427387928"
"scheduledTransferPeriod" = "PT5M"
"DefaultEvents" = @{ "eventDestination" = "ServiceFabricSystemEventTable" }
}
)
"WindowsEventLog" = @{
"scheduledTransferPeriod" = "PT5M"
"DataSource" = @(
@{ "name" = "System!*[System[Provider[@Name='Microsoft Antimalware']]]" },
@{ "name" = "System!*[System[Provider[@Name='NTFS'] and (EventID=55)]]" },
@{ "name" = "System!*[System[Provider[@Name='disk'] and (EventID=7 or EventID=52 or EventID=55)]]" }
)
}
}
}
}
}
# --- PROTECTED settings: storage secrets live here ---
$protected = @{
"StorageAccount" = @{
"name" = $saName
"key" = $saKey
"endpoint" = $saEndpoint
}
}
# --- apply the extension to a node type ---
Add-AzServiceFabricManagedNodeTypeVMExtension `
-ResourceGroupName $rgName `
-ClusterName $clusterName `
-NodeTypeName $nodeTypeName `
-Name $extName `
-Publisher $publisher `
-Type $extType `
-TypeHandlerVersion $extVersion `
-Setting $public `
-ProtectedSetting $protected `
-AutoUpgradeMinorVersion -Verbose