public static void Run([EventGridTrigger] EventGridEvent eventGridEvent, ILogger log) { log.LogInformation("C# Event trigger function processed a request."); var secretName = eventGridEvent.Subject; var secretVersion = Regex.Match(eventGridEvent.Data.ToString(), "Version\":\"([a-z0-9]*)").Groups[1].ToString(); var keyVaultName = Regex.Match(eventGridEvent.Topic, ".vaults.(.*)").Groups[1].ToString(); log.LogInformation($"Key Vault Name: {keyVaultName}"); log.LogInformation($"Secret Name: {secretName}"); log.LogInformation($"Secret Version: {secretVersion}"); SecretRotator.RotateSecret(log, secretName, keyVaultName); }
public static IActionResult Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { string keyVaultName = req.Query["KeyVaultName"]; string secretName = req.Query["SecretName"]; if (string.IsNullOrEmpty(keyVaultName) || string.IsNullOrEmpty(secretName)) { return(new BadRequestObjectResult("Please pass a KeyVaultName and SecretName on the query string")); } log.LogInformation(req.ToString()); log.LogInformation("C# Http trigger function processed a request."); SecretRotator.RotateSecret(log, secretName, keyVaultName); return(new OkObjectResult($"Secret Rotated Successfully")); }