locked
Creating a Unit monitor which calls Azure via Powershell RRS feed

  • Question

  • I can run a command in powershell that lists my resources as so :

    Get-AzureRmResource -ResourceId ...

    And the output can have various values

    provisioningState": "Succeeded|Failed|Cancelled", circuitProvisioningState": "Enabled|Disabled|Enabling|Disabling", serviceProviderProvisioningState": "NotProvisioned|Provisioning|Provisioned|Deprovisioning", serviceProviderProperties": { serviceProviderName": "serviceProviderName", peeringLocation": "<peering location", bandwidthInMbps": 100

    I would like my monitor to check the status of 'provisioningState' and if its Suceeded then be 'Healthy and anything else then be a critical Alert.

    Could someone help point in the right direction on how to achieve pls ?


    Thursday, December 1, 2016 1:49 PM

All replies

  • Hi Sir,

    $api = New-Object -comObject “MOM.ScriptAPI”  
    
    $PropertyBag = $api.CreatePropertyBag()
    
     
    
    $provisioningState = (Get-AzureRmResource -ResourceId xxxx ).provisioningState
    
    $PropertyBag.AddValue(“provisioningState”,$provisioningState)
    
    $PropertyBag

    Then you may select the expression "Property[@Name=”provisioningState”]" equal/not equal "Succeeded".

    It is similar with following article:

    http://blog.coretech.dk/clm/example-of-setting-up-a-custom-monitor-in-scom-with-a-powershell-script-monitor-nic-teams-in-scom/

    Hope it is helpful to you .

    Best Regards,

    Elton


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    • Proposed as answer by Elton_Ji Friday, January 6, 2017 10:19 AM
    Monday, December 5, 2016 11:03 AM