Adding weather forecasting information to Microsoft OMS

This is the third in a six part series which will provide details on a solution I have been working on which will gather information from a variety of sources to forecast how much electricity will be generated by a residential solar panel system. This example shows how OMS can be used to gather data from multiple sources, how to visualize this data in Power BI and how to use a variety of data sources in OMS to forecast likely future results. This series includes the following posts:

  1. Gathering weather data into Microsoft OMS (the script details are available here)
  2. Using Power BI to visualize weather data from Microsoft OMS
  3. How to add weather forecasting information into Microsoft OMS
  4. How to add SolarCity electricity generation information into Microsoft OMS
  5. How to use Power BI to cross multiple custom log types
  6. How to bring this all together and forecast electricity generation

How to add weather forecasting information into Microsoft OMS

In the first blog post we showed how a scheduled Azure Automation PowerShell runbook can be used to gather weather data and store this data in Microsoft OMS. From there the data can be directly visualized in OMS or it can be exported to Power BI for additional visualization options. To gather weather forecasting information we can use the same process with a slightly different script.

Create the runbook

The runbook is very similar to the one which was created to gather weather information available here. This script has three automation variables which need to be created with the correct information (for examples see the previous blog posts). These are: CustomerID, SharedKey, OpenWeatherMapKey. The only significant difference between this script and the original one is the command which gathers the weather data:

$GetWeather = Invoke-RestMethod -uri “$City&APPID=$OpenWeatherMapKey&units=$Units”

The fields which are used are different:

[String]$Location = $

[String]$ForecastTemp = $GetWeather.list.main.temp[$ForecastOffset]

[String]$ForecastWeather = $[$ForecastOffset]

[String]$ForecastDescription = $[$ForecastOffset]

[String]$ForecastTimeTxt = $GetWeather.list.dt_txt[$ForecastOffset]

And the return of the results are different:

$weatherData = @{

‘City’ = $Location

‘ForecastTemp’ = $ForecastTemp

‘ForecastWeather’ = $ForecastWeather

‘ForecastTimeDate’ = $ForecastTime

‘ForecastDescription’ = $ForecastDescription


Once we have created the runbook we save it and publish it so it’s available. Test the runbook to make sure it’s functional and the save it and make sure it’s published.

Schedule the runbook

Once the runbook has been added and it is functional, it should be scheduled to run once a day to gather the weather forecast information. My example configuration is shown below where it starts approximately one hour before solar generation would begin.

Visualize the weather forecasting information

This solution writes the weather forecasting information to a custom list named “OpenWeatherForecast_CL”. A sample query for this data is:


We can visualize this information using a query such as this one:

(Type=OpenWeatherForecast_CL) | measure Count() by ForecastDescription_s

Which results in a view such as this:

This can also be integrated into the original dashboard which was designed for the weather solution (the new dashboard section is labeled “Weather Forecast” below.

Summary: In this blog post we have shown how we can use a PowerShell script running in Azure Automation to run on a scheduled basis and send weather forecasting information into OMS. From there we can query and visualize this data and we can integrate this into the visualizations which were originally created for weather over time. In the next part of this blog series we will see how we can add SolarCity electricity generation information into Microsoft OMS.

Leave a Reply