Created
August 24, 2017 22:58
-
-
Save briglx/d2ff66737195dd810d4a3b959358ed4f to your computer and use it in GitHub Desktop.
Parse the output from a call to the azure deployment api. Usage: azure group deployment operation list --name deploymentname --resource-group rgname | python parse_azure_deployment.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import json | |
import sys | |
from pprint import pprint | |
import fileinput | |
data = json.load(sys.stdin) | |
for d in data: | |
resourceName = "Null" | |
resourceType = "Null" | |
message = "" | |
if d["properties"]["targetResource"] != None: | |
resourceName = d["properties"]["targetResource"]["resourceName"] | |
resourceType = d["properties"]["targetResource"]["resourceType"] | |
if d["properties"]["provisioningState"] == "Failed": | |
message = d["properties"]["statusMessage"]["message"] | |
print resourceName, ",", resourceType, ",", d["properties"]["provisioningState"], ",", message, ",", d["properties"]["timestamp"], ",", d["operationId"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment