{"id":13739006,"url":"https://github.com/cloudyspells/carbon-appinsights","last_synced_at":"2025-05-07T00:41:16.471Z","repository":{"id":157278703,"uuid":"631582511","full_name":"cloudyspells/carbon-appinsights","owner":"cloudyspells","description":"Azure Function for logging PSElectricityMaps results for Azure regions to Application Insights","archived":false,"fork":false,"pushed_at":"2023-04-30T21:29:36.000Z","size":279,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T04:37:19.996Z","etag":null,"topics":["azure","bicep","carbon-emissions","carbon-footprint","cloud","green-software","powershell"],"latest_commit_sha":null,"homepage":"","language":"Bicep","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","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":null,"support":null,"governance":null}},"created_at":"2023-04-23T13:35:10.000Z","updated_at":"2025-03-30T00:50:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"b3d00e6a-0917-454f-911f-728226f2054d","html_url":"https://github.com/cloudyspells/carbon-appinsights","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"a3bc602c645758dd8c49d415233b0ed4c1247d30"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudyspells%2Fcarbon-appinsights","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudyspells%2Fcarbon-appinsights/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudyspells%2Fcarbon-appinsights/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudyspells%2Fcarbon-appinsights/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudyspells","download_url":"https://codeload.github.com/cloudyspells/carbon-appinsights/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252793544,"owners_count":21805053,"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","bicep","carbon-emissions","carbon-footprint","cloud","green-software","powershell"],"created_at":"2024-08-03T04:00:22.907Z","updated_at":"2025-05-07T00:41:16.455Z","avatar_url":"https://github.com/cloudyspells.png","language":"Bicep","funding_links":[],"categories":["Green Software Awesome List"],"sub_categories":["Contents"],"readme":"Carbon AppInsights\n==================\n\nLog ElectricityMaps Emissions data for Azure regions to AppInsights\n-------------------------------------------------------------------\n\nThis is a simple Azure Function App that logs the emissions data for Azure\nregions to AppInsights. From Application Insights and the configured Log\nAnalytics workspace, you can create dashboards and alert rules to use in scaling\noperations and feature flags.\n\nThe function is triggered by a timer every 20 minutes. The function will log\na metric `{region}CarbonIntensity` for each region in the configured list of\nregions. The metric value is the carbon intensity in grams of CO2 per kWh.\n\nSample use cases can be found in the\n[carbon-appinsights-samples](https://github.com/cloudyspells/carbon-appinsights-samples)\nrepository.\n\n![Example AppInsights Dashboard](./docs/images/log-weu-co2-insights-dev.png)\n\n### Usage\n\nThis function is designed to be deployed to Azure as a Function App with the\nincluded _GitHub Workflow_ using bicep. See [the local guide](docs/usage-local.md)\nfor instructions your local workstation.\nTo deploy the function, you will need fork this repository and create a new\nGitHub repository secret named `AZURE_CREDENTIALS` with the value of the output\nfrom the following command:\n\n```bash\naz ad sp create-for-rbac --name \"CarbonAppInsights\" --sdk-auth --role contributor --scopes /subscriptions/\u003cSUBSCRIPTION_ID\u003e\n```\n\nYou will also need a secret named `AZURE_SUBSCRIPTION_ID` with the value of your\nAzure subscription ID.\n\nYou will need to register for an API token at ElectricityMaps and add it as a\nsecret named `EMTOKEN` to your repository.\n\nThen run the deployment workflow by running the _Deploy Bicep code_ workflow\nconfigured in your forked repository from the file\n`.github/workflows/deploy-bicep.yml`.\n\n### Configuration\n\nTo configure your own deployment, you will need to edit the\n`src/bicep/main.parameters.json` with your own desired configuration.\n\n#### Parameters\n\n| Name | Type | Default | Description |\n| --- | --- | --- | --- |\n|`projectName`|`string`|`carbon-appinsights`|The name of the project. Used in naming resources|\n|`environment`|`string`|`dev`|The name of the environment. Used in naming resources|\n|`location`|`string`|`westeurope`|The Azure region to deploy the resources to|\n|`emToken`|`securestring`|`null`|The ElectricityMaps API token. Should be specified in cmdline with env var|\n|`emissionRegions`|`string`|\"westeurope\",\"norwayeast\",\"northeurope\"|The list of regions to log emissions data for|\n\n### Deployed resources\n\nThe following resources are deployed by the bicep template:\n\n| Type | Description |\n| --- | --- |\n|KeyVault|A KeyVault to store the ElectricityMaps API key|\n|FunctionApp|An Azure Function App to run the PowerShell function|\n|ApplicationInsights|An Application Insights instance to log the emissions data|\n|LogAnalyticsWorkspace|A Log Analytics workspace to store the emissions data|\n|StorageAccount|A Storage Account to store the Function App code|\n|AppServicePlan|An App Service Plan to host the Function App|\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudyspells%2Fcarbon-appinsights","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudyspells%2Fcarbon-appinsights","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudyspells%2Fcarbon-appinsights/lists"}