Power Outage Data in Power Automate

To get power outage data into Power Automate, build a scheduled cloud flow: a Recurrence trigger every 15 minutes, an HTTP action that calls the PowerOutage.us v2 REST API with your key read from an Azure Key Vault secret, and a Parse JSON action that turns the answer into dynamic content. The flow keeps a SharePoint list of the counties above your threshold, so it posts to a Microsoft Teams channel or sends an Outlook email only when a county crosses it, and removes the county from the list when it drops back. The HTTP action is a premium connector, so the flow needs a premium licence.

What you'll have

  • A Teams message or Outlook email listing each county that reaches your customers-out threshold, once per crossing rather than every 15 minutes.
  • A SharePoint list that always holds the counties currently above the threshold, for people who prefer to check a list.
  • The API key in Azure Key Vault, read at run time and hidden from the flow run history.
  • One request every 15 minutes, filtered by the API to the states and threshold you choose.

What you need

An API key (request one with the form below) and these endpoints. Full details are in the API reference.

EndpointMethodUsed forPackage
/outages/countiesGETCustomers out per county in the states you choose, filtered with minCustomersOut so only counties over your threshold come back.Core

Step 1: Check licences, environment and access

The HTTP action and the Microsoft Dataverse action that reads the key are premium, so the flow's owner needs Power Automate Premium, or the flow needs a Process licence; the Free licence covers standard connectors only. Build the flow in a solution, in an environment with Dataverse, because environment variables live in solutions. For the key you need an Azure subscription and a Key Vault in the same Microsoft Entra tenant as Power Platform, with the Microsoft.PowerPlatform resource provider registered on the subscription, and rights to add role assignments on the vault. You also need a SharePoint site where you can create a list, and for Teams posts the Workflows app must be allowed in the Teams admin center. /outages/counties is in the Core package.

Step 2: Store the key in Azure Key Vault

Add the API key to the vault as a secret, for example poweroutage-api-key. In the vault's Access control (IAM), assign the Key Vault Secrets User role to yourself and to the Dataverse service principal, application ID 00000007-0000-0000-c000-000000000000; Microsoft recommends the Azure role-based access control permission model for the vault. If the vault's firewall is on, allow the Power Platform IP ranges, because Power Platform is not one of the trusted services the firewall can let through.

Step 3: Create a secret environment variable

At make.powerapps.com, open Solutions and your unmanaged solution, then New > More > Environment variable. Give it a display name such as PowerOutage API key, set Data Type to Secret and Secret Store to Azure Key Vault, choose New Azure Key Vault value reference, and enter the subscription ID, resource group name, vault name and secret name from the vault's Overview page. Save, and note the variable's unique name, which starts with your publisher's prefix, such as new_PowerOutageApiKey. Secret variables don't appear in a flow's dynamic content, so the flow reads them with a Dataverse action instead.

Step 4: Create the SharePoint list

The list is the flow's memory of which counties it has already announced. Create a list named Power outage counties and add these columns, with names exactly as shown and no spaces, so their internal names match the expressions below. The county id is stored as text because the comparison in step 7 matches text.

text
SharePoint list: Power outage counties
column          type                  what the flow writes
Title           Single line of text   name, the county name
CountyId        Single line of text   string(item()?['id']), the county id as text
StateId         Number                stateId
CustomersOut    Number                customersOut when the county crossed the threshold
LastUpdatedAt   Single line of text   lastUpdatedAt, in UTC

Step 5: Add the trigger, the key and the HTTP action

In the solution, select New > Automation > Cloud flow > Scheduled, and set the Recurrence trigger's Interval to 15 and Frequency to Minute. The data updates every minute, so an Interval of 1 or 2 gets the latest answers, at the cost of many more actions against your Power Platform request limits. In the trigger's settings, turn on Concurrency control with a degree of parallelism of 1, so two runs never update the list at once. Below the trigger, add a Scope action (under Control) named Check outages, and add the actions in this step and the next three inside it, so one failure alert at the end can catch them all. Inside the scope, add the Microsoft Dataverse action Perform an unbound action, choose RetrieveEnvironmentVariableSecretValue, enter the variable's unique name, rename the action Get API key, and turn on Secure outputs in its settings. Then add the HTTP action with the values below. In its settings, turn on Secure inputs so the key never shows in run history, and set the Retry policy to Fixed interval, 2 retries, PT10S: the API's Retry-After is never more than 10 seconds. This is what the action's code view shows once it is set up; change stateId to your states, using ids from /outages/states, and minCustomersOut to your threshold.

json
{
  "type": "Http",
  "inputs": {
    "method": "GET",
    "uri": "https://poweroutage.us/api/v2/outages/counties",
    "queries": {
      "stateId": "44,45",
      "minCustomersOut": "1000"
    },
    "headers": {
      "Authorization": "Bearer @{body('Get_API_key')?['EnvironmentVariableSecretValue']}"
    },
    "retryPolicy": {
      "type": "fixed",
      "count": 2,
      "interval": "PT10S"
    }
  },
  "runAfter": {
    "Get_API_key": ["Succeeded"]
  },
  "runtimeConfiguration": {
    "secureData": {
      "properties": ["inputs"]
    }
  }
}

Step 6: Parse the response

Add Parse JSON, set Content to the Body of the HTTP action, and paste this schema. lastUpdatedAt can be null, which the schema allows; without that, the action fails on the first county with no update time. Later actions can then pick name, customersOut and the other fields from dynamic content.

json
{
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" },
          "name": { "type": "string" },
          "stateId": { "type": "integer" },
          "countryCode": { "type": "string" },
          "customersTracked": { "type": "integer" },
          "customersOut": { "type": "integer" },
          "lastUpdatedAt": { "type": ["string", "null"] }
        },
        "required": ["id", "name", "stateId", "customersOut"]
      }
    },
    "meta": {
      "type": "object",
      "properties": {
        "generatedAt": { "type": "string" }
      }
    }
  },
  "required": ["data"]
}

Step 7: Find the new and cleared counties

Get the list's rows, turn both the list and the API answer into arrays of county ids, then filter each against the other. New counties are over the threshold now but not yet in the list; cleared counties are in the list but no longer over the threshold. Enter each value below as an expression, and rename each action as shown so the references match. In the two Filter array rows, enter false on the right through the expression editor as well: typed into the box, it is the text false, which never equals the true or false that contains returns. Alternatively, switch each filter to advanced mode and enter the @not(contains(...)) form. The comparison uses the county id, not the name, because county names repeat across states.

text
Get items (SharePoint)          Site Address: your site
                                List Name: Power outage counties
                                Top Count: 5000

Select: Listed county ids       From: body('Get_items')?['value']
                                Map (switch to text mode): item()?['CountyId']

Select: Current county ids      From: body('Parse_JSON')?['data']
                                Map (text mode): string(item()?['id'])

Filter array: New counties      From: body('Parse_JSON')?['data']
                                contains(body('Listed_county_ids'), string(item()?['id']))
                                is equal to   false   (both sides as expressions)
                    or, in advanced mode:
                                @not(contains(body('Listed_county_ids'), string(item()?['id'])))

Filter array: Cleared counties  From: body('Get_items')?['value']
                                contains(body('Current_county_ids'), item()?['CountyId'])
                                is equal to   false   (both sides as expressions)
                    or, in advanced mode:
                                @not(contains(body('Current_county_ids'), item()?['CountyId']))

Step 8: Record, post and clear

Add each new county to the list, then, if there is at least one, build an HTML table and post it to Teams as the Flow bot or send it with Outlook's Send an email (V2); you can add both. Then delete the list rows for cleared counties, so a county that crosses the threshold again is announced again. Last, below the scope, add a Teams post or an email whose Configure run after is set to has failed and has timed out for Check outages: a revoked key, an expired SharePoint connection or a changed Key Vault permission then reaches someone instead of failing every 15 minutes unseen. The first run announces every county already over the threshold. Test the flow, then check the run history: the HTTP action should show its inputs as secured.

text
Apply to each: body('New_counties')
  Create item (SharePoint)      List Name: Power outage counties
                                Title: item()?['name']
                                CountyId: string(item()?['id'])
                                StateId: item()?['stateId']
                                CustomersOut: item()?['customersOut']
                                LastUpdatedAt: item()?['lastUpdatedAt']

Condition                       length(body('New_counties'))  is greater than  0
  If yes:
    Create HTML table           From: body('New_counties'), Columns: Custom
                                County: item()?['name']
                                State id: item()?['stateId']
                                Customers out: item()?['customersOut']
                                Last update (UTC): item()?['lastUpdatedAt']
    Post message in a chat or channel (Microsoft Teams)
                                Post as: Flow bot   Post in: Channel
                                Team, Channel: yours
                                Message: Counties with 1,000 or more customers out:
                                         <Output of Create HTML table>
    or Send an email (V2) (Office 365 Outlook) with the same table in Body

Apply to each: body('Cleared_counties')
  Delete item (SharePoint)      List Name: Power outage counties
                                Id: item()?['ID']

Below the Check outages scope, outside it:
  Post message in a chat or channel, or Send an email (V2)
                                Configure run after: Check outages
                                  has failed, has timed out
                                Message: The PowerOutage.us county flow failed.
                                         Open its run history in Power Automate.

Tips for Power Automate

  • A run uses about a dozen actions plus two per county that changes, about 1,200 to 2,000 a day at 15-minute intervals, well inside the Power Automate Premium daily action limit.
  • For an all-clear message, add a second Condition on length(body('Cleared_counties')) before the delete loop and post the cleared counties' Title values.
  • Show state names instead of ids by adding a second HTTP action for /outages/states and looking up stateId, or by keeping the flow to one state and writing its name in the message.
  • Records are not zeroed when a utility stops reporting. To skip counties whose data is old, compare lastUpdatedAt with the response's meta.generatedAt in the New counties filter.
  • Use a separate key for the flow, restricted to the states it watches, so other tools never use up its rate limit and a leaked key exposes less.

Used by

Related integrations

FAQ

Here are some commonly asked questions

Request API access

Tell us what you're building and we'll set you up with a trial key.