-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathAKVSQLRotationHttp.cs
More file actions
32 lines (26 loc) · 1.07 KB
/
AKVSQLRotationHttp.cs
File metadata and controls
32 lines (26 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
namespace Microsoft.KeyVault
{
public static class AKVSQLRotationHttp
{
[FunctionName("AKVSQLRotationHttp")]
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");
}
}
}