{"id":22048893,"url":"https://github.com/chaostoolkit-incubator/chaostoolkit-azure","last_synced_at":"2025-05-08T23:06:42.955Z","repository":{"id":33557957,"uuid":"128663656","full_name":"chaostoolkit-incubator/chaostoolkit-azure","owner":"chaostoolkit-incubator","description":"Chaos Toolkit Extension for Azure","archived":false,"fork":false,"pushed_at":"2024-03-26T13:08:59.000Z","size":333,"stargazers_count":22,"open_issues_count":33,"forks_count":28,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-08T23:06:33.081Z","etag":null,"topics":["chaos-engineering","chaostoolkit","chaostoolkit-extension"],"latest_commit_sha":null,"homepage":"https://chaostoolkit.org/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chaostoolkit-incubator.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-08T17:06:58.000Z","updated_at":"2023-05-27T13:02:38.000Z","dependencies_parsed_at":"2024-06-19T00:09:39.058Z","dependency_job_id":"1d53264b-d579-4720-95db-1d956b5a7b0e","html_url":"https://github.com/chaostoolkit-incubator/chaostoolkit-azure","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaostoolkit-incubator%2Fchaostoolkit-azure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaostoolkit-incubator%2Fchaostoolkit-azure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaostoolkit-incubator%2Fchaostoolkit-azure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaostoolkit-incubator%2Fchaostoolkit-azure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chaostoolkit-incubator","download_url":"https://codeload.github.com/chaostoolkit-incubator/chaostoolkit-azure/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253160777,"owners_count":21863629,"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":["chaos-engineering","chaostoolkit","chaostoolkit-extension"],"created_at":"2024-11-30T14:13:39.683Z","updated_at":"2025-05-08T23:06:42.937Z","avatar_url":"https://github.com/chaostoolkit-incubator.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chaos Toolkit Extension for Azure\n\n[![Build](https://github.com/chaostoolkit-incubator/chaostoolkit-azure/actions/workflows/build.yaml/badge.svg)](https://github.com/chaostoolkit-incubator/chaostoolkit-azure/actions/workflows/build.yaml)\n[![Python versions](https://img.shields.io/pypi/pyversions/chaostoolkit-azure.svg)](https://www.python.org/)\n\nThis project is a collection of [actions][] and [probes][], gathered as an\nextension to the [Chaos Toolkit][chaostoolkit]. It targets the\n[Microsoft Azure][azure] platform.\n\n[actions]: http://chaostoolkit.org/reference/api/experiment/#action\n[probes]: http://chaostoolkit.org/reference/api/experiment/#probe\n[chaostoolkit]: http://chaostoolkit.org\n[azure]: https://azure.microsoft.com/en-us/\n\n## Install\n\nThis package requires Python 3.8+\n\nTo be used from your experiment, this package must be installed in the Python\nenvironment where [chaostoolkit][] already lives.\n\n```\n$ pip install -U chaostoolkit-azure\n```\n\n## Usage\n\nTo use the probes and actions from this package, add the following to your\nexperiment file:\n\n```json\n{\n  \"type\": \"action\",\n  \"name\": \"start-service-factory-chaos\",\n  \"provider\": {\n    \"type\": \"python\",\n    \"module\": \"chaosazure.vm.actions\",\n    \"func\": \"stop_machines\",\n    \"secrets\": [\"azure\"],\n    \"arguments\": {\n      \"parameters\": {\n        \"TimeToRunInSeconds\": 45\n      }\n    }\n  }\n}\n```\n\nThat's it!\n\nPlease explore the code to see existing probes and actions.\n\n### Credentials\n\nThis extension uses the [Azure SDK][sdk] under the hood.\n\n[sdk]: https://github.com/Azure/azure-sdk-for-python\n\n#### Environment Variables\n\nThe extensions uses a chained approach to locating the appropriate\ncredentials, starting from the secrets in the experiment before moving to\n[environment variables](envvar) and so on as per the [Azure documentation][creds].\n\n[creds]: https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.defaultazurecredential?view=azure-python\n[envvar]: https://learn.microsoft.com/fr-fr/python/api/azure-identity/azure.identity.environmentcredential?view=azure-python\n\nIn theory, at the bare minimum you don't need to set anything explicitely \ninto the experiment and let the client figure it out based on the local\nmachine settings.\n\n#### Experiment Secrets\n\nYou may also pass them via the secrets block of the experiment:\n\n  ```json\n  {\n    \"secrets\": {\n      \"azure\": {\n        \"client_id\": \"your-super-secret-client-id\",\n        \"client_secret\": \"your-even-more-super-secret-client-secret\",\n        \"tenant_id\": \"your-tenant-id\"\n      }\n    }\n  }\n  ```\n\n  You can retrieve secretes as well from [environment][env_secrets] or [HashiCorp vault][vault_secrets]. \n\n  \n  If you are not working with Public Global Azure, e.g. China Cloud You can set the cloud environment.\n\n  ```json\n  {\n    \"client_id\": \"your-super-secret-client-id\",\n    \"client_secret\": \"your-even-more-super-secret-client-secret\",\n    \"tenant_id\": \"your-tenant-id\",\n    \"cloud\": \"AZURE_CHINA_CLOUD\"\n  }\n  ```\n\n  Available cloud names:\n\n  - AZURE_CHINA_CLOUD\n  - AZURE_GERMAN_CLOUD\n  - AZURE_PUBLIC_CLOUD\n  - AZURE_US_GOV_CLOUD\n\n  Either of these values can be passed via `AZURE_CLOUD` as well.\n\n  [vault_secrets]: https://docs.chaostoolkit.org/reference/api/experiment/#vault-secrets\n  [env_secrets]: https://docs.chaostoolkit.org/reference/api/experiment/#environment-secrets\n\n### Subscription\n\nAdditionally you need to provide the Azure subscription id.\n\n- As an  environment variable\n  \n  - AZURE_SUBSCRIPTION_ID\n\n- Subscription id in the experiment file\n\n  ```json\n  {\n    \"configuration\": {\n      \"azure_subscription_id\": \"your-azure-subscription-id\"\n    }\n  }\n  ```\n\n  Configuration may be as well retrieved from an [environment][env_configuration].\n\n  An old, but deprecated way of doing it was as follows, this still works\n  but should not be favoured over the previous approaches as it's not the\n  Chaos Toolkit way to pass structured configurations.\n\n  ```json\n  {\n    \"configuration\": {\n      \"azure\": {\n        \"subscription_id\": \"your-azure-subscription-id\"\n      }\n    }\n  }\n  ```\n\n  [env_configuration]: https://docs.chaostoolkit.org/reference/api/experiment/#environment-configurations\n\n- Subscription id in the Azure credential file\n\n  Credential file described in the previous \"Credential\" section contains as well subscription id. If **AZURE_AUTH_LOCATION** is set and subscription id is **NOT** set in the experiment definition, extension will try to load it from the credential file.\n\n  \n\n### Putting it all together\n\nHere is a full example for an experiment containing secrets and configuration: \n\n```json\n{\n  \"version\": \"1.0.0\",\n  \"title\": \"...\",\n  \"description\": \"...\",\n  \"tags\": [\"azure\", \"kubernetes\", \"aks\", \"node\"],\n  \"configuration\": {\n    \"azure_subscription_id\": \"xxx\"\n  },\n  \"secrets\": {\n    \"azure\": {\n      \"client_id\": \"xxx\",\n      \"client_secret\": \"xxx\",\n      \"tenant_id\": \"xxx\"\n    }\n  },\n  \"steady-state-hypothesis\": {\n    \"title\": \"Services are all available and healthy\",\n    \"probes\": [\n      {\n        \"type\": \"probe\",\n        \"name\": \"consumer-service-must-still-respond\",\n        \"tolerance\": 200,\n        \"provider\": {\n          \"type\": \"http\",\n          \"url\": \"https://some-url/\"\n        }\n      }\n    ]\n  },\n  \"method\": [\n    {\n      \"type\": \"action\",\n      \"name\": \"restart-node-at-random\",\n      \"provider\": {\n        \"type\": \"python\",\n        \"module\": \"chaosazure.machine.actions\",\n        \"func\": \"restart_machines\",\n        \"secrets\": [\"azure\"],\n        \"config\": [\"azure_subscription_id\"]\n      }\n    }\n  ],\n  \"rollbacks\": []\n}\n```\n\n## Contribute\n\nIf you wish to contribute more functions to this package, you are more than\nwelcome to do so. Please, fork this project, make your changes following the\nusual [PEP 8][pep8] code style, sprinkling with tests and submit a PR for\nreview.\n\n[pep8]: https://peps.python.org/pep-0008/\n\nThe Chaos Toolkit projects require all contributors must sign a\n[Developer Certificate of Origin][dco] on each commit they would like to merge\ninto the master branch of the repository. Please, make sure you can abide by\nthe rules of the DCO before submitting a PR.\n\n[dco]: https://github.com/probot/dco#how-it-works\n\n### Develop\n\nIf you wish to develop on this project, make sure to install the development\ndependencies.\n\n```console\n$ pdm install --dev\n```\n\nNow, you can edit the files and they will be automatically be seen by your\nenvironment, even when running from the `chaos` command locally.\n\n### Test\n\nTo run the tests for the project execute the following:\n\n```\n$ pdm run test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaostoolkit-incubator%2Fchaostoolkit-azure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchaostoolkit-incubator%2Fchaostoolkit-azure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaostoolkit-incubator%2Fchaostoolkit-azure/lists"}