Create-AzDiagPolicy
2.0
This script takes a SubscriptionID, ResourceType, ResourceGroup as parameters, analyzes the subscription or
specific ResourceGroup defined for the resources specified in $Resources, and builds a custom policy for
diagnostic metrics/logs for Event Hubs and Log Analytics as sink points for selected resource types.
Installation Options
Owners
Copyright
Microsoft
Package Details
Author(s)
- jbritt@microsoft.com
Functions
BuildBody Get-ResourceType Add-IndexNumberToArray New-LogArray New-MetricArray Update-LogAnalyticsJSON Update-EventHubJSON Parse-ResourceType Validate-JSON New-PolicyInitiative Format-JSON Create-Hash
Dependencies
This script has no dependencies.
Release Notes
June 07, 2020 2.0
Significant Updates this version which pushed it to 2.0!
* Special thanks to Dimitri Lider, and Julian Hayward (Microsoft) once again for their constant inputs on this script to improve!
* A HUGE THANK YOU to the ClearDATA crew for their support in bug bashing an early iteration of this 2.0 ver script before going broadly.
-- Thank you Jason Singh for leaning in on support for prioritizing review of this effort
-- And for Rob Sanders (https://github.com/rwsanders) for his isolation of a breaking bug I introduced that was much more easily isolated and resolved with his support!
* Another special call out to Kristian Nese @KristianNese (https://github.com/krnese) and Chris Eggert (https://github.com/pilor) @pilor
* for their technical review and big brain guidance related to approach and technical accuracy in the area of ARM and Policy!
Policy Initiative Support
- Added support for exporting to ARM Template Policy Initiative Artifact
-- Option for customized displayname for Initiative
-- Ability for Custom Azure Policies and Initiative to be idempotent due to creating a unique name via hash
--- Inspiration reference http://xpertkb.com/compute-hash-string-powershell/
User Experience
- Added logic to return to initial subscription context after successfully running the script (useful on Tenant / Management Group analysis)
- Improved token expiration experience for Azure Auth
- Added Total Execution Time to help understand performance of script against environment
- Updated Examples
Visual Updates
- Prettify function added to clean up JSON export
-- Inspiration via reference article / source: https://stackoverflow.com/questions/24789365/prettify-json-in-powershell-3/61988399#61988399
- Added process to clean up exported JSON
-- Credit to https://github.com/DeadPoolHeartsRR for their input on another script to use logic to use regex to clean up non printable chars (thank you! - Dead Pool Rocks BTW :) )
- Updated initial subscriptionId selection to show subscription name on screen.
Feature Enhancement
- Added "Kind" to evaluation to support RPs that leverage kind in category evaluation (Example: Azure SQL DW vs Azure SQL DB)
FileList
- Create-AzDiagPolicy.nuspec
- Create-AzDiagPolicy.ps1
Version History
| Version | Downloads | Last updated |
|---|---|---|
| 2.9 | 3,239 | 9/9/2021 |