public async Task <string> SaveSecretAsync(string secretUri, string secretValue) { SecretUriParser.ParseSecretUri(secretUri, out string keyvaultName, out string secretName); await GetKeyVault().SaveSecretStringAsync(keyvaultName, secretName, secretValue); return(secretUri); }
/// <summary> /// Generate and set the info for the projection file which will be used to generate JobConfig /// </summary> /// <returns></returns> public override async Task <string> Process(FlowDeploymentSession flowToDeploy) { var config = flowToDeploy.Config; var runtimeConfigBaseFolder = flowToDeploy.GetTokenString(PrepareJobConfigVariables.TokenName_RuntimeConfigFolder); Ensure.NotNull(runtimeConfigBaseFolder, "runtimeConfigBaseFolder"); var runtimeKeyVaultName = flowToDeploy.GetTokenString(PortConfigurationSettings.TokenName_RuntimeKeyVaultName); Ensure.NotNull(runtimeKeyVaultName, "runtimeKeyVaultName"); if (runtimeKeyVaultName != "local") { var secretName = $"{config.Name}-projectionfile"; Configuration.TryGet(Constants.ConfigSettingName_SparkType, out string sparkType); var uriPrefix = KeyVaultClient.GetUriPrefix(sparkType); var projectionFileSecret = SecretUriParser.ComposeUri(runtimeKeyVaultName, secretName, uriPrefix); flowToDeploy.SetObjectToken(TokenName_ProjectionFiles, new string[] { projectionFileSecret }); } else { flowToDeploy.SetObjectToken(TokenName_ProjectionFiles, new string[] { flowToDeploy.ResultProperties[PrepareJobConfigVariables.ResultPropertyName_RuntimeConfigFolder].ToString() + "/projection.txt" }); } await Task.CompletedTask; return("done"); }
/// <summary> /// Generate and set the info for the transform file which will be used to generate JobConfig /// </summary> /// <returns></returns> public override async Task <string> Process(FlowDeploymentSession flowToDeploy) { var config = flowToDeploy.Config; var guiConfig = config?.GetGuiConfig(); if (guiConfig == null) { return("no gui input, skipped."); } string queries = string.Join("\n", guiConfig.Process?.Queries); string ruleDefinitions = RuleDefinitionGenerator.GenerateRuleDefinitions(guiConfig.Rules, config.Name); RulesCode rulesCode = CodeGen.GenerateCode(queries, ruleDefinitions, config.Name); Ensure.NotNull(rulesCode, "rulesCode"); // Save the rulesCode object for downstream processing flowToDeploy.SetAttachment(AttachmentName_CodeGenObject, rulesCode); var runtimeKeyVaultName = flowToDeploy.GetTokenString(PortConfigurationSettings.TokenName_RuntimeKeyVaultName); Ensure.NotNull(runtimeKeyVaultName, "runtimeKeyVaultName"); var secretName = $"{config.Name}-transform"; Configuration.TryGet(Constants.ConfigSettingName_SparkType, out string sparkType); var uriPrefix = KeyVaultClient.GetUriPrefix(sparkType); var transformFileSecret = SecretUriParser.ComposeUri(runtimeKeyVaultName, secretName, uriPrefix); flowToDeploy.SetStringToken(TokenName_TransformFile, transformFileSecret); await Task.CompletedTask; return("done"); }
public async Task <string> SaveSecretAsync(string keyvaultName, string secretName, string secretValue, bool hashSuffix = false) { var finalSecretName = hashSuffix ? (secretName + "-" + HashGenerator.GetHashCode(secretValue)) : secretName; await GetKeyVault().SaveSecretStringAsync(keyvaultName, finalSecretName, secretValue); return(SecretUriParser.ComposeUri(keyvaultName, finalSecretName)); }
public async Task <string> SaveSecretAsync(string keyvaultName, string secretUri, string secret, string sparkType) { var uriPrefix = (sparkType != null && sparkType == Constants.SparkTypeDataBricks) ? Constants.PrefixSecretScope : Constants.PrefixKeyVault; await GetKeyVault().SaveSecretStringAsync(keyvaultName, secretUri, secret); return(SecretUriParser.ComposeUri(keyvaultName, secretUri, uriPrefix)); }
public static string SaveSecretToKeyvault(string secretUri, string value) { SecretUriParser.ParseSecretUri(secretUri, out string keyvaultName, out string secretName); var secretValue = KeyVaultUtility.SaveSecretToKeyvault(keyvaultName, secretName, value).Result; return(secretValue); }
public static string GetSecretFromKeyvault(string secretUri) { SecretUriParser.ParseSecretUri(secretUri, out string keyvaultName, out string secretName); var secretValue = GetSecretFromKeyvault(keyvaultName, secretName); return(secretValue); }
public async Task <string> SaveSecretAsync(string keyvaultName, string secretName, string secretValue, string sparkType, bool hashSuffix = false) { var finalSecretName = hashSuffix ? (secretName + "-" + HashGenerator.GetHashCode(secretValue)) : secretName; var uriPrefix = (sparkType != null && sparkType == Constants.SparkTypeDataBricks) ? Constants.PrefixSecretScope : Constants.PrefixKeyVault; await GetKeyVault().SaveSecretStringAsync(keyvaultName, finalSecretName, secretValue); return(SecretUriParser.ComposeUri(keyvaultName, finalSecretName, uriPrefix)); }
public void KeyVaultParseSecretUriTest() { SecretUriParser.ParseSecretUri("keyvault://somekeyvalut/test-input-connectionstring-CD42404D52AD55CCFA9ACA4ADC828AA5", out string keyvault, out string secret); Assert.AreEqual(keyvault, "somekeyvalut"); Assert.AreEqual(secret, "test-input-connectionstring-CD42404D52AD55CCFA9ACA4ADC828AA5"); SecretUriParser.ParseSecretUri("secretscope://somekeyvalut/test-input-connectionstring", out keyvault, out secret); Assert.AreEqual(keyvault, "somekeyvalut"); Assert.AreEqual(secret, "test-input-connectionstring"); }
/// <summary> /// UDFPathResolver resolves the keyvault uri and gets the real path /// </summary> /// <param name="path">path</param> /// <returns>Returns a string </returns> private string UDFPathResolver(string path) { if (path != null && Config.Utility.KeyVaultUri.IsSecretUri(path)) { SecretUriParser.ParseSecretUri(path, out string keyvalut, out string secret); var secretUri = KeyVault.GetSecretFromKeyvault(keyvalut, secret); return(secretUri); } return(path); }
/// <summary> /// Generate and set the info for the input schema file which will be used to generate JobConfig /// </summary> /// <returns></returns> public override async Task <string> Process(FlowDeploymentSession flowToDeploy) { var config = flowToDeploy.Config; var runtimeKeyVaultName = flowToDeploy.GetTokenString(PortConfigurationSettings.TokenName_RuntimeKeyVaultName); Ensure.NotNull(runtimeKeyVaultName, "runtimeKeyVaultName"); var secretName = $"{config.Name}-inputschemafile"; Configuration.TryGet(Constants.ConfigSettingName_SparkType, out string sparkType); var uriPrefix = KeyVaultClient.GetUriPrefix(sparkType); var schemaFileSecret = SecretUriParser.ComposeUri(runtimeKeyVaultName, secretName, uriPrefix); flowToDeploy.SetStringToken(TokenName_InputSchemaFilePath, schemaFileSecret); await Task.CompletedTask; return("done"); }
/// <summary> /// Generate and set the info for the input schema file which will be used to generate JobConfig /// </summary> /// <returns></returns> public override async Task <string> Process(FlowDeploymentSession flowToDeploy) { var config = flowToDeploy.Config; var runtimeKeyVaultName = flowToDeploy.GetTokenString(PortConfigurationSettings.TokenName_RuntimeKeyVaultName); Ensure.NotNull(runtimeKeyVaultName, "runtimeKeyVaultName"); if (runtimeKeyVaultName != "local") { var secretName = $"{config.Name}-inputschemafile"; Configuration.TryGet(Constants.ConfigSettingName_SparkType, out string sparkType); var uriPrefix = KeyVaultClient.GetUriPrefix(sparkType); var schemaFileSecret = SecretUriParser.ComposeUri(runtimeKeyVaultName, secretName, uriPrefix); flowToDeploy.SetStringToken(TokenName_InputSchemaFilePath, schemaFileSecret); } else { flowToDeploy.SetStringToken(TokenName_InputSchemaFilePath, flowToDeploy.ResultProperties[PrepareJobConfigVariables.ResultPropertyName_RuntimeConfigFolder].ToString() + "/inputschema.json"); } await Task.CompletedTask; return("done"); }
public async Task <string> SaveSecretAsync(string keyvaultName, string secretUri, string secret) { await GetKeyVault().SaveSecretStringAsync(keyvaultName, secretUri, secret); return(SecretUriParser.ComposeUri(keyvaultName, secretUri)); }