{"action":"created","comment":{"url":"https://api.github.com/repos/NuGet/NuGet.Jobs/pulls/comments/68085444","id":68085444,"diff_hunk":"@@ -0,0 +1,83 @@\n+﻿// Copyright (c) .NET Foundation. All rights reserved.\n+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\n+\n+using System;\n+using System.Security.Cryptography.X509Certificates;\n+using System.Threading.Tasks;\n+using Microsoft.Azure.KeyVault;\n+using Microsoft.IdentityModel.Clients.ActiveDirectory;\n+\n+namespace NuGet.Services.KeyVault\n+{\n+    public class KeyVaultReader : ISecretReader\n+    {\n+        private readonly KeyVaultConfiguration _configuration;\n+        private readonly string _vault;\n+        private readonly Lazy<KeyVaultClient> _keyVaultClient;\n+\n+        public KeyVaultReader(KeyVaultConfiguration configuration)\n+        {\n+            if (configuration == null)\n+            {\n+                throw new ArgumentNullException(nameof(configuration));\n+            }\n+\n+            _configuration = configuration;\n+            _vault = $\"https://{_configuration.VaultName}.vault.azure.net:443/\";\n+            _keyVaultClient = new Lazy<KeyVaultClient>(InitializeClient);\n+        }\n+\n+        public async Task<string> ReadSecretAsync(string secretName)\n+        {\n+            var secret = await _keyVaultClient.Value.GetSecretAsync(_vault, secretName);\n+            return secret.Value;\n+        }\n+\n+        private KeyVaultClient InitializeClient()","path":"src/NuGet.Services.KeyVault/KeyVaultReader.cs","position":36,"original_position":36,"commit_id":"0f5f449c24500d2a6cd3dd060039f0c8922b6a4f","original_commit_id":"0f5f449c24500d2a6cd3dd060039f0c8922b6a4f","user":{"login":"skofman1","id":16807822,"avatar_url":"https://avatars.githubusercontent.com/u/16807822?v=3","gravatar_id":"","url":"https://api.github.com/users/skofman1","html_url":"https://github.com/skofman1","followers_url":"https://api.github.com/users/skofman1/followers","following_url":"https://api.github.com/users/skofman1/following{/other_user}","gists_url":"https://api.github.com/users/skofman1/gists{/gist_id}","starred_url":"https://api.github.com/users/skofman1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skofman1/subscriptions","organizations_url":"https://api.github.com/users/skofman1/orgs","repos_url":"https://api.github.com/users/skofman1/repos","events_url":"https://api.github.com/users/skofman1/events{/privacy}","received_events_url":"https://api.github.com/users/skofman1/received_events","type":"User","site_admin":false},"body":"In general you are right, it would be a nice design to have a client separated from the reader/writer. However, in this case, there are non plans to create a writer, so this separation will be unnecessary. In the future, if we decide to create a writer, we can easily refactor this code as you suggested. \r\n\r\n---\r\nIn reply to: [68012625](https://github.com/NuGet/NuGet.Jobs/pull/44#discussion_r68012625) [](ancestors = 68012625)","created_at":"2016-06-22T16:20:06Z","updated_at":"2016-06-22T16:20:06Z","html_url":"https://github.com/NuGet/NuGet.Jobs/pull/44#discussion_r68085444","pull_request_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/pulls/44","_links":{"self":{"href":"https://api.github.com/repos/NuGet/NuGet.Jobs/pulls/comments/68085444"},"html":{"href":"https://github.com/NuGet/NuGet.Jobs/pull/44#discussion_r68085444"},"pull_request":{"href":"https://api.github.com/repos/NuGet/NuGet.Jobs/pulls/44"}}},"pull_request":{"url":"https://api.github.com/repos/NuGet/NuGet.Jobs/pulls/44","id":74699942,"html_url":"https://github.com/NuGet/NuGet.Jobs/pull/44","diff_url":"https://github.com/NuGet/NuGet.Jobs/pull/44.diff","patch_url":"https://github.com/NuGet/NuGet.Jobs/pull/44.patch","issue_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/issues/44","number":44,"state":"open","locked":false,"title":"KeyVault reader + integration with JobConfigurationManager","user":{"login":"skofman1","id":16807822,"avatar_url":"https://avatars.githubusercontent.com/u/16807822?v=3","gravatar_id":"","url":"https://api.github.com/users/skofman1","html_url":"https://github.com/skofman1","followers_url":"https://api.github.com/users/skofman1/followers","following_url":"https://api.github.com/users/skofman1/following{/other_user}","gists_url":"https://api.github.com/users/skofman1/gists{/gist_id}","starred_url":"https://api.github.com/users/skofman1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skofman1/subscriptions","organizations_url":"https://api.github.com/users/skofman1/orgs","repos_url":"https://api.github.com/users/skofman1/repos","events_url":"https://api.github.com/users/skofman1/events{/privacy}","received_events_url":"https://api.github.com/users/skofman1/received_events","type":"User","site_admin":false},"body":"1. A package to be commonly used for accessing KeyVault\r\n2. Extension methods that parse a string and replace secret placeholders with real values\r\n3. Integration with JobConfigurationManager\r\n4. Search.GenerateAuxiliaryData support for KeyVault\r\n\r\nNext steps:\r\n1. Check the code (pending certificate generation)\r\n2. Decide how to replace secret in NUGETJOBS_STORAGE_PRIMARY environment variable","created_at":"2016-06-21T23:00:01Z","updated_at":"2016-06-22T16:20:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b6bcc1120527c7a1b25ad89d1d7c2846965272ca","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/pulls/44/commits","review_comments_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/pulls/44/comments","review_comment_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/issues/44/comments","statuses_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/statuses/0f5f449c24500d2a6cd3dd060039f0c8922b6a4f","head":{"label":"NuGet:feature-keyVault","ref":"feature-keyVault","sha":"0f5f449c24500d2a6cd3dd060039f0c8922b6a4f","user":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"repo":{"id":23330255,"name":"NuGet.Jobs","full_name":"NuGet/NuGet.Jobs","owner":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NuGet/NuGet.Jobs","description":"","fork":false,"url":"https://api.github.com/repos/NuGet/NuGet.Jobs","forks_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/forks","keys_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/teams","hooks_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/hooks","issue_events_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/issues/events{/number}","events_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/events","assignees_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/assignees{/user}","branches_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/branches{/branch}","tags_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/tags","blobs_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/git/refs{/sha}","trees_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/statuses/{sha}","languages_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/languages","stargazers_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/stargazers","contributors_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/contributors","subscribers_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/subscribers","subscription_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/subscription","commits_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/commits{/sha}","git_commits_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/git/commits{/sha}","comments_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/comments{/number}","issue_comment_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/issues/comments{/number}","contents_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/contents/{+path}","compare_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/merges","archive_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/downloads","issues_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/issues{/number}","pulls_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/pulls{/number}","milestones_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/milestones{/number}","notifications_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/labels{/name}","releases_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/releases{/id}","deployments_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/deployments","created_at":"2014-08-25T22:01:47Z","updated_at":"2016-02-10T09:24:25Z","pushed_at":"2016-06-22T11:13:30Z","git_url":"git://github.com/NuGet/NuGet.Jobs.git","ssh_url":"git@github.com:NuGet/NuGet.Jobs.git","clone_url":"https://github.com/NuGet/NuGet.Jobs.git","svn_url":"https://github.com/NuGet/NuGet.Jobs","homepage":null,"size":1622,"stargazers_count":5,"watchers_count":5,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":2,"forks":5,"open_issues":2,"watchers":5,"default_branch":"master"}},"base":{"label":"NuGet:dev","ref":"dev","sha":"8982f11692a17c46309c6989fa400141bb40f95b","user":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"repo":{"id":23330255,"name":"NuGet.Jobs","full_name":"NuGet/NuGet.Jobs","owner":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NuGet/NuGet.Jobs","description":"","fork":false,"url":"https://api.github.com/repos/NuGet/NuGet.Jobs","forks_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/forks","keys_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/teams","hooks_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/hooks","issue_events_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/issues/events{/number}","events_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/events","assignees_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/assignees{/user}","branches_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/branches{/branch}","tags_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/tags","blobs_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/git/refs{/sha}","trees_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/statuses/{sha}","languages_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/languages","stargazers_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/stargazers","contributors_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/contributors","subscribers_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/subscribers","subscription_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/subscription","commits_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/commits{/sha}","git_commits_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/git/commits{/sha}","comments_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/comments{/number}","issue_comment_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/issues/comments{/number}","contents_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/contents/{+path}","compare_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/merges","archive_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/downloads","issues_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/issues{/number}","pulls_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/pulls{/number}","milestones_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/milestones{/number}","notifications_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/labels{/name}","releases_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/releases{/id}","deployments_url":"https://api.github.com/repos/NuGet/NuGet.Jobs/deployments","created_at":"2014-08-25T22:01:47Z","updated_at":"2016-02-10T09:24:25Z","pushed_at":"2016-06-22T11:13:30Z","git_url":"git://github.com/NuGet/NuGet.Jobs.git","ssh_url":"git@github.com:NuGet/NuGet.Jobs.git","clone_url":"https://github.com/NuGet/NuGet.Jobs.git","svn_url":"https://github.com/NuGet/NuGet.Jobs","homepage":null,"size":1622,"stargazers_count":5,"watchers_count":5,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":2,"forks":5,"open_issues":2,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NuGet/NuGet.Jobs/pulls/44"},"html":{"href":"https://github.com/NuGet/NuGet.Jobs/pull/44"},"issue":{"href":"https://api.github.com/repos/NuGet/NuGet.Jobs/issues/44"},"comments":{"href":"https://api.github.com/repos/NuGet/NuGet.Jobs/issues/44/comments"},"review_comments":{"href":"https://api.github.com/repos/NuGet/NuGet.Jobs/pulls/44/comments"},"review_comment":{"href":"https://api.github.com/repos/NuGet/NuGet.Jobs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NuGet/NuGet.Jobs/pulls/44/commits"},"statuses":{"href":"https://api.github.com/repos/NuGet/NuGet.Jobs/statuses/0f5f449c24500d2a6cd3dd060039f0c8922b6a4f"}}}}
{"actor":{"display_login":"skofman1"}}