<commit_before>﻿using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Dynamic;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;

using Newtonsoft.Json.Linq;

using Microsoft.Deployment.Common.ActionModel;
using Microsoft.Deployment.Common.Actions;
using Microsoft.Deployment.Common.ErrorCode;
using Microsoft.Deployment.Common.Helpers;

namespace Microsoft.Deployment.Actions.AzureCustom.Common
{
    [Export(typeof(IAction))]
    public class DeployNewsFunctionAsset : BaseAction
    {
        public override async Task<ActionResponse> ExecuteActionAsync(ActionRequest request)
        {
            var azureToken = request.DataStore.GetJson("AzureToken", "access_token");
            var subscription = request.DataStore.GetJson("SelectedSubscription", "SubscriptionId");
            var resourceGroup = request.DataStore.GetValue("SelectedResourceGroup");
            var location = request.DataStore.GetJson("SelectedLocation", "Name");
            var apiKey = request.DataStore.GetValue("apiKey");
            var subscriptionKey = request.DataStore.GetValue("subscriptionKey");

            var sitename = request.DataStore.GetValue("FunctionName");

            List<string> appSettings = new List<string>();

            if (request.DataStore.GetJson("AppSettingKeys") != null && !string.IsNullOrEmpty(request.DataStore.GetJson("AppSettingKeys")[0].ToString()))
            {
                foreach (var item in request.DataStore.GetJson("AppSettingKeys"))
                {
                    string key = (string)item;
                    appSettings.Add(key);
                }
            }

            AzureHttpClient client = new AzureHttpClient(azureToken, subscription, resourceGroup);

            dynamic obj = new ExpandoObject();
            obj.subscriptionId = subscription;
            obj.siteId = new ExpandoObject();
            obj.siteId.Name = sitename;
            obj.siteId.ResourceGroup = resourceGroup;
            obj.connectionStrings = new ExpandoObject[2];
            obj.connectionStrings[0] = new ExpandoObject();
            obj.connectionStrings[0].ConnectionString = apiKey;
            obj.connectionStrings[0].Name = "apiKey";
            obj.connectionStrings[0].Type = 2;
            obj.connectionStrings[1] = new ExpandoObject();
            obj.connectionStrings[1].ConnectionString = subscriptionKey;
            obj.connectionStrings[1].Name = "subscriptionKey";
            obj.connectionStrings[1].Type = 2;
            obj.location = location;
<commit_msg>Added Sql connection String settings in for the template<commit_after>﻿using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Dynamic;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;

using Newtonsoft.Json.Linq;

using Microsoft.Deployment.Common.ActionModel;
using Microsoft.Deployment.Common.Actions;
using Microsoft.Deployment.Common.ErrorCode;
using Microsoft.Deployment.Common.Helpers;

namespace Microsoft.Deployment.Actions.AzureCustom.Common
{
    [Export(typeof(IAction))]
    public class DeployNewsFunctionAsset : BaseAction
    {
        public override async Task<ActionResponse> ExecuteActionAsync(ActionRequest request)
        {
            var azureToken = request.DataStore.GetJson("AzureToken", "access_token");
            var subscription = request.DataStore.GetJson("SelectedSubscription", "SubscriptionId");
            var resourceGroup = request.DataStore.GetValue("SelectedResourceGroup");
            var location = request.DataStore.GetJson("SelectedLocation", "Name");
            var apiKey = request.DataStore.GetValue("apiKey");
            var subscriptionKey = request.DataStore.GetValue("subscriptionKey");
            string connectionString = request.DataStore.GetValueAtIndex("SqlConnectionString", "SqlServerIndex");
            var sitename = request.DataStore.GetValue("FunctionName");

            List<string> appSettings = new List<string>();

            if (request.DataStore.GetJson("AppSettingKeys") != null && !string.IsNullOrEmpty(request.DataStore.GetJson("AppSettingKeys")[0].ToString()))
            {
                foreach (var item in request.DataStore.GetJson("AppSettingKeys"))
                {
                    string key = (string)item;
                    appSettings.Add(key);
                }
            }

            AzureHttpClient client = new AzureHttpClient(azureToken, subscription, resourceGroup);

            dynamic obj = new ExpandoObject();
            obj.subscriptionId = subscription;
            obj.siteId = new ExpandoObject();
            obj.siteId.Name = sitename;
            obj.siteId.ResourceGroup = resourceGroup;
            obj.connectionStrings = new ExpandoObject[3];
            obj.connectionStrings[0] = new ExpandoObject();
            obj.connectionStrings[0].ConnectionString = apiKey;
            obj.connectionStrings[0].Name = "apiKey";
            obj.connectionStrings[0].Type = 2;
            obj.connectionStrings[1] = new ExpandoObject();
            obj.connectionStrings[1].ConnectionString = subscriptionKey;
            obj.connectionStrings[1].Name = "subscriptionKey";
            obj.connectionStrings[1].Type = 2;

            obj.connectionStrings[2] = new ExpandoObject();
            obj.connectionStrings[2].ConnectionString = connectionString;
            obj.connectionStrings[2].Name = "ConnectionString";
            obj.connectionStrings[2].Type = 2;
            obj.location = location;

{'fraction_non_alphanumeric': 0.10237923576063446, 'fraction_numerical': 0.005227108868060562, 'mean_word_length': 2.842797783933518, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5567403', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1364, 'n_words': 257}