public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ExecutionContext context, ILogger log) { var config = new ConfigurationBuilder() .SetBasePath(context.FunctionAppDirectory) // This gives you access to your application settings in your local development environment .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true) // This is what actually gets you the application settings in Azure .AddEnvironmentVariables() .Build(); log.LogInformation("C# HTTP trigger function processed a request."); string KeyVault_Name = config["KeyVault_Name"]; string Cert_Name = config["Cert_Name"]; string appOnlyId = config["AppOnlyID"]; string tenant_URL = config["Tenant_URL"]; string siteURL = "https://" + tenant_URL + ".sharepoint.com/teams/scw"; // // parse query parameter string key = req.Query["key"]; string comments = req.Query["comments"]; string status = req.Query["status"]; // // Get request body //dynamic data = await req.Content.ReadAsAsync<object>(); string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); dynamic data = JsonConvert.DeserializeObject(requestBody); // // Set name to query string or body data key = key ?? data?.name.key; comments = comments ?? data?.name.comments; status = status ?? data?.name.status; log.LogInformation("get info" + key); int id = Int32.Parse(key); using (var cc = new OfficeDevPnP.Core.AuthenticationManager().GetAzureADAppOnlyAuthenticatedContext(siteURL, appOnlyId, tenant_URL + ".onmicrosoft.com", KeyVaultAccess.GetKeyVaultCertificate(KeyVault_Name, Cert_Name))) { Web web = cc.Web; List list = cc.Web.Lists.GetByTitle("Space Requests"); ListItem oItem = list.GetItemById(id); oItem["Approved_x0020_Date"] = DateTime.Now; oItem["Reviewer_x0020_Comments"] = comments; oItem["_Status"] = status; oItem.Update(); cc.ExecuteQuery(); string responseMessage = "Create item successfully "; return(new OkObjectResult(responseMessage)); } }
public override void WriteYaml(StreamWriter writer, AssetManager assetManager, ILoggerFactory loggerFactory, int indent = 0) { var spaces = "".PadLeft(indent); writer.Write($"{spaces}aks:\n"); spaces = "".PadLeft(indent + 2); writer.Write($"{spaces}clusterName: {ClusterName}\n"); writer.Write($"{spaces}dnsPrefix: {DnsPrefix}\n"); writer.Write($"{spaces}version: {Version}\n"); writer.Write($"{spaces}vmSize: {VmSize}\n"); writer.Write($"{spaces}nodeCount: {NodeCount}\n"); writer.Write($"{spaces}ownerUpn: {AksOwnerAadUpn}\n"); writer.Write($"{spaces}access:\n"); if (Readers?.Any() == true) { spaces = "".PadLeft(indent + 4); writer.Write($"{spaces}readers:"); spaces = "".PadLeft(indent + 6); foreach (var aadIdentity in Readers) { writer.Write($"{spaces}name: {aadIdentity.Name}\n"); writer.Write($"{spaces}type: {aadIdentity.Type}\n"); } } if (Contributors?.Any() == true) { spaces = "".PadLeft(indent + 4); writer.Write($"{spaces}contributors:"); spaces = "".PadLeft(indent + 6); foreach (var aadIdentity in Contributors) { writer.Write($"{spaces}name: {aadIdentity.Name}\n"); writer.Write($"{spaces}type: {aadIdentity.Type}\n"); } } if (Owners?.Any() == true) { spaces = "".PadLeft(indent + 4); writer.Write($"{spaces}owners:"); spaces = "".PadLeft(indent + 6); foreach (var aadIdentity in Owners) { writer.Write($"{spaces}name: {aadIdentity.Name}\n"); writer.Write($"{spaces}type: {aadIdentity.Type}\n"); } } spaces = "".PadLeft(indent + 2); writer.Write($"{spaces}useDevSpaces: {UseDevSpaces}\n"); writer.Write($"{spaces}useTerraform: {UseTerraform}\n"); writer.Write($"{spaces}useIstio: {UseIstio}\n"); writer.Write($"{spaces}useCertManager: {UseCertManager}\n"); if (KeyVaultAccess?.Any() == true) { spaces = "".PadLeft(indent + 2); writer.Write($"{spaces}keyVaultAccess:\n"); foreach (var option in KeyVaultAccess) { spaces = "".PadLeft(indent + 4); writer.Write($"{spaces}- {option}\n"); } } if (Metrics?.Any() == true) { spaces = "".PadLeft(indent + 2); writer.Write($"{spaces}metrics:\n"); foreach (var option in Metrics) { spaces = "".PadLeft(indent + 4); writer.Write($"{spaces}- {option}\n"); } } if (Logging?.Any() == true) { spaces = "".PadLeft(indent + 2); writer.Write($"{spaces}logging:\n"); foreach (var option in Logging) { spaces = "".PadLeft(indent + 4); writer.Write($"{spaces}- {option}\n"); } } if (Tracing?.Any() == true) { spaces = "".PadLeft(indent + 2); writer.Write($"{spaces}tracing:\n"); foreach (var option in Tracing) { spaces = "".PadLeft(indent + 4); writer.Write($"{spaces}- {option}\n"); } } if (Ingress?.Any() == true) { spaces = "".PadLeft(indent + 2); writer.Write($"{spaces}ingress:\n"); foreach (var option in Ingress) { spaces = "".PadLeft(indent + 4); writer.Write($"{spaces}- {option}\n"); } } if (Certs?.Any() == true) { spaces = "".PadLeft(indent + 2); writer.Write($"{spaces}certs:\n"); foreach (var cert in Certs) { spaces = "".PadLeft(indent + 4); writer.Write($"{spaces}- name: {cert.Name}\n"); if (!string.IsNullOrEmpty(cert.Type)) { writer.Write($"{spaces} type: {cert.Type}\n"); } } } if (Secrets != null) { spaces = "".PadLeft(indent + 2); writer.Write($"{spaces}secrets:\n"); spaces = "".PadLeft(indent + 4); writer.Write($"{spaces}addContainerRegistryAccess: {Secrets.AddContainerRegistryAccess}\n"); writer.Write($"{spaces}addKeyVaultAccess: {Secrets.AddKeyVaultAccess}\n"); writer.Write($"{spaces}addAppInsightsKey: {Secrets.AddAppInsightsKey}\n"); } }