{"id":13739046,"url":"https://github.com/cloudyspells/PSWattTime","last_synced_at":"2025-05-08T18:31:42.412Z","repository":{"id":148806471,"uuid":"609922442","full_name":"cloudyspells/PSWattTime","owner":"cloudyspells","description":"PowerShell module for WattTime API free functions","archived":false,"fork":false,"pushed_at":"2023-03-26T18:03:52.000Z","size":77,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-14T09:12:34.878Z","etag":null,"topics":["azure","carbon-emissions","carbon-footprint","co2","co2-emissions","co2-footprint","deployment","github-actions","green-computing","green-software","powershell","powershell-module","sustainability","sustainable-software"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudyspells.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null}},"created_at":"2023-03-05T16:31:20.000Z","updated_at":"2023-04-06T16:15:28.000Z","dependencies_parsed_at":"2023-05-29T01:00:10.725Z","dependency_job_id":null,"html_url":"https://github.com/cloudyspells/PSWattTime","commit_stats":{"total_commits":54,"total_committers":1,"mean_commits":54.0,"dds":0.0,"last_synced_commit":"0eeb66f281017170044f020cbe1589fd0031032b"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudyspells%2FPSWattTime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudyspells%2FPSWattTime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudyspells%2FPSWattTime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudyspells%2FPSWattTime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudyspells","download_url":"https://codeload.github.com/cloudyspells/PSWattTime/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224758093,"owners_count":17364953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure","carbon-emissions","carbon-footprint","co2","co2-emissions","co2-footprint","deployment","github-actions","green-computing","green-software","powershell","powershell-module","sustainability","sustainable-software"],"created_at":"2024-08-03T04:00:23.854Z","updated_at":"2024-11-15T09:30:18.390Z","avatar_url":"https://github.com/cloudyspells.png","language":"PowerShell","funding_links":[],"categories":["Green Software Awesome List"],"sub_categories":["Contents"],"readme":"PSWattTime\n==========\n\nPowerShell Module for WattTime emission data\n--------------------------------------------\n\n[![PowerShell Module Quality Assurance](https://github.com/cloudyspells/PSWattTime/actions/workflows/qa.yml/badge.svg)](https://github.com/cloudyspells/PSWattTime/actions/workflows/qa.yml)\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/cloudyspells/PSWattTime)\n![PowerShell Gallery Version](https://img.shields.io/powershellgallery/v/PSWattTime)\n![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/PSWattTime)\n\n\nThis PowerShell module is intended for retrieving emissions data from\n[WattTime](https://www.watttime.org/) for a supplied Azure Region during\nresource deployments. This is a lightweight solution making use of only the\nlimited functionality available with a free account at _WattTime_. This means\nthe module is only able to get near-realtime emissions data and no prodictive\nvalues. This means this module is _not_ a real solution for reduced carbon\ndeployments and -software. It _does_ however provide some nice realtime values\nso you can simulate the beheaviour of deployments and software based on \nemissions data without the cost of a paid account for such data. For example in\nlab- or proof of concept environments.\n\nThe intended use of this module is for setting the `Location` parameter\non Azure IaC deployments in GitHub workflows using the included GitHub\naction.\n\nFor a real-world solution with a commercial data provider, check out\nthe [carbon-aware-sdk](https://github.com/Green-Software-Foundation/carbon-aware-sdk)\nby the [Green Software Foundation](https://greensoftware.foundation/)\n\n### Usage\n\n#### PowerShell Module\n\nTo get started with this module you will need an account on\n[WattTime](https://www.watttime.org/). See\n[the manual](https://www.watttime.org/api-documentation/#register-new-user)\non registering an account. The module provides a function `New-WattTimeAccount`\nto create an account if you do not yet have one.\n\nYou will also need the _Az.Resources_ PowerShell Module for Azure installed\nand connected to your Azure account. See\n[the installation manual](https://learn.microsoft.com/en-us/powershell/azure/install-az-ps)\nfor the _Az_ module for instructions.\n\nTo install the module from the [PowerShell Gallery](https://www.powershellgallery.com/packages/PSWattTime/).\n\n```powershell\nInstall-Module -Name PSWattTime\n```\n\nTo register an account with _WattTime_:\n\n```powershell\nNew-WattTimeAccount -Username \u003cYOUR_USERNAME\u003e `\n  -Password '\u003cYOUR_PASSWORD\u003e' `\n  -Email '\u003cyou@domain.com\u003e' `\n  -Organization \u003cYOUR_ORGANIZATION\u003e\n```\n\n\nAuthenticate to the _WattTime_ API:\n\n```powershell\n $token = Get-WattTimeAuthToken -Username '\u003cYOUR_WATTTIME_USERNAME\u003e' `\n  -Password '\u003cYOUR_WATTTIME_PASSWORD\u003e'\n```\n\nGet current percentage of energy with emissions the 'westeurope' Azure region:\n\n```powershell\nPS C:\\\u003e Get-WattTimeForAzureRegion -Region westeurope -AuthToken $token\n\nba         : NL\nfreq       : 300\npercent    : 94\npoint_time : 5-3-2023 13:15:00\nregion     : westeurope\n\n```\n\nDetermine the lowest emissions for the list of northeurope,\nwesteurope, francecentral and uksouth Azure regions:\n\n```powershell\nPS C:\\\u003e Get-AzureRegionWithLowestWattTime -Regions westeurope,uksouth,northeurope,francecentral -AuthToken $token\n\nba         : IE\nfreq       : 300\npercent    : 69\npoint_time : 5-3-2023 14:15:00\nregion     : northeurope\n\n```\n\n##### Module Functions\n\n- [ConvertFrom-AzureRegion](docs/ConvertFrom-AzureRegion.md)\n- [Get-AzureRegionWithLowestWattTime](docs/Get-AzureRegionWithLowestWattTime.md)\n- [Get-WattTime](docs/Get-WattTime.md)\n- [Get-WattTimeAuthToken](docs/Get-WattTimeAuthToken.md)\n- [Get-WattTimeForAzureRegion](docs/Get-WattTimeForAzureRegion.md)\n- [New-WattTimeAccount](docs/New-WattTimeAccount.md)\n\n#### GitHub Action\n\nThis PowerShell module also comes with a _GitHub Action_ you can use\nin your GitHub workflows. Again you will need a pre-existing account\nfor _WattTime_ and an Azure CLI/PowerShell secret configured in your repo\n\n##### Example\n\n```yaml\n\non:\n  pull_request:\n    branches:\n      - 'main'\n      - 'releases/**'\n\nname: Deploy to region with lowest emissions\n\njobs:\n  deploy-to-test:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v3\n\n      - name: Get region with lowest emissions\n        uses: cloudyspells/PSWattTime@main\n        id: watttime_action # Set step id for using output in deployment\n        with:\n          azure_credential: ${{ secrets.AZURE_CREDENTIALS }}\n          watttime_username: ${{ secrets.WATTTIMEUSERNAME }}\n          watttime_password: ${{ secrets.WATTTIMEPASSWORD }}\n          regions: '\"westeurope\",\"northeurope\",\"uksouth\",\"francecentral\",\"germanynorth\"'\n\n      - name: Login to Az PowerShell Module\n        uses: azure/login@v1\n        with:\n          creds: ${{ secrets.AZURE_CREDENTIALS }}\n          enable-AzPSSession: true\n\n      - uses: azure/arm-deploy@v1\n        name: Run Bicep deployment\n        with:\n          subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }}\n          scope: subscription\n          region: ${{ steps.watttime_action.outputs.region }} # The region output from PSWattTime\n          template: src/bicep/main.bicep\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudyspells%2FPSWattTime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudyspells%2FPSWattTime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudyspells%2FPSWattTime/lists"}