{"id":22800815,"url":"https://github.com/colindembovsky/azure-webapp-route-traffic","last_synced_at":"2025-03-30T19:26:44.827Z","repository":{"id":42910083,"uuid":"250165400","full_name":"colindembovsky/azure-webapp-route-traffic","owner":"colindembovsky","description":"Action that routes traffic to a slot in a Web App","archived":false,"fork":false,"pushed_at":"2023-01-05T17:13:46.000Z","size":1117,"stargazers_count":2,"open_issues_count":11,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T01:49:02.530Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/colindembovsky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-26T04:59:57.000Z","updated_at":"2024-07-19T04:29:29.000Z","dependencies_parsed_at":"2023-02-04T08:17:23.204Z","dependency_job_id":null,"html_url":"https://github.com/colindembovsky/azure-webapp-route-traffic","commit_stats":{"total_commits":26,"total_committers":1,"mean_commits":26.0,"dds":0.0,"last_synced_commit":"0184a71e9798f7a49424b7975c32ecbf19ed9110"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":"actions/typescript-action","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colindembovsky%2Fazure-webapp-route-traffic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colindembovsky%2Fazure-webapp-route-traffic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colindembovsky%2Fazure-webapp-route-traffic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colindembovsky%2Fazure-webapp-route-traffic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/colindembovsky","download_url":"https://codeload.github.com/colindembovsky/azure-webapp-route-traffic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246367785,"owners_count":20765931,"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":[],"created_at":"2024-12-12T08:08:07.257Z","updated_at":"2025-03-30T19:26:44.809Z","avatar_url":"https://github.com/colindembovsky.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/colindembovsky/azure-webapp-route-traffic\"\u003e\u003cimg alt=\"action status\" src=\"https://github.com/colindembovsky/azure-webapp-route-traffic/workflows/build-test/badge.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# Traffic Manager: Route a Percentage of Traffic to an Azure Web App Slot\n\nUse this action to configure traffic manager on an Azure Web App to direct a percentage of traffic to a slot.\n\n## Usage\n\n```yml\n    # add a login action\n    - name: 'Login via Azure CLI'\n      uses: azure/login@v1\n      with:\n        creds: ${{ secrets.AZURE_CREDENTIALS }}\n    \n    # now you can route traffic\n    - name: 'Route traffic'\n      uses: colindembovsky/azure-webapp-route-traffic@v1.0.1\n      with: \n        resource-group: rg-containing-web-app\n        app-name: web-app-name\n        slot-name: slot-name\n        percentage-traffic: 21 # percentage of traffic to route to slot\n```\n\n\u003e Note: To set up the credentials for the `az login` action, refer to [this repo](https://github.com/marketplace/actions/azure-login).\n\n## Developing\n\n```bash\nyarn install\nyarn run build  # builds the typescript\nyarn lint       # runs linting\nyarn test       # runs the unit test\nyarn run pack   # creates the bundle (the run keywork is important)\n```\n\n### Bug in AuthorizerFactory\nFor some reason, the `azure-actions-webclient/AuthorizerFactory` breaks when it tries to set the access token as a secret in the logs.\n\nTo work around this, replace the `getToken` method in the `dist/index.js` file after running `yarn run pack`:\n```ts\ngetToken(force, args) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (!this._token || force) {\n            try {\n                let azAccessToken = JSON.parse(yield AzureCLIAuthorizer.executeAzCliCommand('account get-access-token', !!args ? args : []));\n                // this try/catch is a hack to fix the error\n                try {\n                    core.setSecret(azAccessToken);\n                } catch(error){\n                    // do nothing\n                }\n                this._token = azAccessToken['accessToken'];\n            }\n            catch (error) {\n                console.log('Failed to fetch Azure access token');\n                console.log(error);\n                throw error;\n            }\n        }\n        return this._token;\n    });\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolindembovsky%2Fazure-webapp-route-traffic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolindembovsky%2Fazure-webapp-route-traffic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolindembovsky%2Fazure-webapp-route-traffic/lists"}