Example #1
0
        private static async Task <SecretBundle> WriteKeyVault(CreateSecret Obj)// string szPFX, string szCER, string szPassword)
        {
            SecretBundle     bundle  = null;
            SecretAttributes attribs = new SecretAttributes
            {
                Enabled = true //,
                               //Expires = DateTime.UtcNow.AddYears(2), // if you want to expire the info
                               //NotBefore = DateTime.UtcNow.AddDays(1) // if you want the info to
                               // start being available later
            };

            /*  IDictionary<string, string> alltags = new Dictionary<string, string>();
             * alltags.Add("Test1", "This is a test1 value");
             * alltags.Add("Test2", "This is a test2 value");
             * alltags.Add("CanBeAnything", "Including a long encrypted string if you choose");
             * string TestName = "TestSecret";
             * string TestValue = "searchValue"; // this is what you will use to search for the item later
             * string contentType = "SecretInfo"; // whatever you want to categorize it by; you name it
             */

            IDictionary <string, string> alltags = Obj.KeyValue;
            string TestName    = Obj.SecretName;
            string TestValue   = Obj.SecretValue; // this is what you will use to search for the item later
            string contentType = Obj.ContenType;

            bundle = await kvc.SetSecretAsync
                         (BASESECRETURI, TestName, TestValue, alltags, contentType, attribs);

            return(bundle);

            //kvc.GetKeyAsync(BASESECRETURI, "");
            // Console.WriteLine("Bundle:" + bundle.Tags["Test1"].ToString());
        }
Example #2
0
        public string CreateSecretinAzure(CreateSecret Obj)
        {
            kvc = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(GetToken));

            //write
            Task <SecretBundle> bundle = Task.Run(() => WriteKeyVault(Obj));

            return("published version:" + bundle.ConfigureAwait(true).GetAwaiter().GetResult().SecretIdentifier.Version);
        }
Example #3
0
 protected override void Execute(CodeActivityContext context)
 {
     try
     {
         CreateSecret obj = new CreateSecret();
         obj.SecretName  = SecretName.Get(context);
         obj.SecretValue = SecretValue.Get(context);
         obj.ContenType  = "dev-Action-secret";
         string output = CreateSecretinAzure(obj);
         PublishedVersion.Set(context, output);
     }
     catch (Exception ex)
     {
         throw new InvalidWorkflowException("exception in action" + ex.Message, ex.InnerException);
     }
 }