{"id":22242638,"url":"https://github.com/gabrielecanepa/azure-vm-actions","last_synced_at":"2025-03-25T10:41:09.762Z","repository":{"id":250126220,"uuid":"833546429","full_name":"gabrielecanepa/azure-vm-actions","owner":"gabrielecanepa","description":"☁️ Actions to start and shut down Azure virtual machines","archived":false,"fork":false,"pushed_at":"2024-09-19T15:31:32.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-30T09:41:59.850Z","etag":null,"topics":["azure","azure-virtual-machine","devops","github-actions"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gabrielecanepa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-07-25T09:14:10.000Z","updated_at":"2024-11-01T11:39:27.000Z","dependencies_parsed_at":"2024-07-25T10:46:18.245Z","dependency_job_id":"7e043db4-ffb9-4351-9285-f04a1349a3a6","html_url":"https://github.com/gabrielecanepa/azure-vm-actions","commit_stats":null,"previous_names":["gabrielecanepa/azure-vm-actions"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabrielecanepa%2Fazure-vm-actions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabrielecanepa%2Fazure-vm-actions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabrielecanepa%2Fazure-vm-actions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabrielecanepa%2Fazure-vm-actions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gabrielecanepa","download_url":"https://codeload.github.com/gabrielecanepa/azure-vm-actions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245449531,"owners_count":20617187,"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","azure-virtual-machine","devops","github-actions"],"created_at":"2024-12-03T04:16:43.144Z","updated_at":"2025-03-25T10:41:09.473Z","avatar_url":"https://github.com/gabrielecanepa.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Azure Virtual Machine Actions\n\n[![](https://github.com/gabrielecanepa/azure-vm-actions/actions/workflows/start-vm.yml/badge.svg)](https://github.com/gabrielecanepa/azure-vm-actions/actions/workflows/start-vm.yml)\n[![](https://github.com/gabrielecanepa/azure-vm-actions/actions/workflows/stop-vm.yml/badge.svg)](https://github.com/gabrielecanepa/azure-vm-actions/actions/workflows/stop-vm.yml)\n\nThis repository contains a collection of GitHub Actions for working with Azure virtual machines.\n\n## Configuration\n\n### Service principal\n\nTo create a service principal and configure its access to Azure resources, open a local or cloud shell and run the following command specifying an arbitrary service principal name (e.g. `auto-shutdown`), the virtual machine subscription ID and resource group name:\n\n```sh\nSERVICE_PRINCIPAL_NAME=\"auto-shutdown\"\nSUBSCRIPTION_ID=\"SUBSCRIPTION_ID\"\nRESOURCE_GROUP_NAME=\"\u003cRESOURCE_GROUP_NAME\u003e\"\n\naz ad sp create-for-rbac \\\n  --name $SERVICE_PRINCIPAL_NAME \\\n  --scopes /subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP_NAME \\\n  --role contributor --sdk-auth\n```\n\nThe response will be a JSON object with the following structure:\n\n```json\n{\n  \"clientId\": \"\u003cCLIENT_ID\u003e\",\n  \"clientSecret\": \"\u003cCLIENT_SECRET\u003e\",\n  \"subscriptionId\": \"\u003cSUBSCRIPTION_ID\u003e\",\n  \"tenantId\": \"\u003cTENANT_ID\u003e\",\n  \"activeDirectoryEndpointUrl\": \"https://login.microsoftonline.com\",\n  \"resourceManagerEndpointUrl\": \"https://management.azure.com/\",\n  \"activeDirectoryGraphResourceId\": \"https://graph.windows.net/\",\n  \"sqlManagementEndpointUrl\": \"https://management.core.windows.net:8443/\",\n  \"galleryEndpointUrl\": \"https://gallery.azure.com/\",\n  \"managementEndpointUrl\": \"https://management.core.windows.net/\"\n}\n```\n\n### GitHub Actions\n\nAdd the following secrets to your GitHub repository:\n\n- `AZURE_CREDENTIALS`: the JSON object from the previous step\n- `VM_NAME`: name of the virtual machine\n- `VM_RESOURCE_GROUP`: name of the virtual machine resource group\n\n## Usage\n  \nOnce configured, you can run the following workflows using GitHub Actions.\n\n| Name                                      | Description                                       | Schedule                    | Trigger                         |\n| ----------------------------------------- | ------------------------------------------------- | --------------------------- | ------------------------------- |\n| [Start VM](.github/workflows/stop-vm.yml) | Start a virtual machine                           | None                        | `workflow_dispatch`             |\n| [Stop VM](.github/workflows/stop-vm.yml)  | Stop (power off and deallocate) a virtual machine | Every day at midnight (UTC) | `schedule`, `workflow_dispatch` |\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabrielecanepa%2Fazure-vm-actions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgabrielecanepa%2Fazure-vm-actions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabrielecanepa%2Fazure-vm-actions/lists"}