public static (int, string) KillAllDotnet(List <string> slaves, string cmd)
        {
            var errCode = 0;
            var result  = "";

            slaves.ForEach(s =>
            {
                (errCode, result) = ShellHelper.Bash(cmd);
                if (errCode != 0)
                {
                    return;
                }
            });

            return(errCode, result);
        }
Example #2
0
        public static (int, string) CloneRepo(List <string> agents, string cmd)
        {
            var errCode = 0;
            var result  = "";

            agents.ForEach(s =>
            {
                (errCode, result) = ShellHelper.Bash(cmd);
                if (errCode != 0)
                {
                    return;
                }
            });

            return(errCode, result);
        }
Example #3
0
        public static (int, string) DeleteSignalr(ArgsOption args)
        {
            var errCode = 0;
            var result  = "";
            var cmd     = "";

            var content = AzureBlobReader.ReadBlob("SignalrConfigFileName");
            var config  = AzureBlobReader.ParseYaml <SignalrConfig>(content);

            var groupName = config.BaseName + "Group";

            // login to azure
            cmd = $"az login --service-principal --username {config.AppId} --password {config.Password} --tenant {config.Tenant}";
            Util.Log($"CMD: signalr service: logint azure");
            (errCode, result) = ShellHelper.Bash(cmd, handleRes: true);

            // delete resource group
            cmd = $"az group delete --name {groupName} --yes";
            Util.Log($"CMD: signalr service: {cmd}");
            (errCode, result) = ShellHelper.Bash(cmd, handleRes: true);

            return(errCode, result);
        }
Example #4
0
        public static (int, string) CreateSignalrService(ArgsOption argsOption, int unitCount)
        {
            var errCode = 0;
            var result  = "";
            var cmd     = "";

            var content = AzureBlobReader.ReadBlob("SignalrConfigFileName");

            Console.WriteLine($"content: {content}");
            var config = AzureBlobReader.ParseYaml <SignalrConfig>(content);

            // login to azure
            cmd = $"az login --service-principal --username {config.AppId} --password {config.Password} --tenant {config.Tenant}";
            Util.Log($"CMD: signalr service: az login");
            (errCode, result) = ShellHelper.Bash(cmd, handleRes: true);

            // change subscription
            cmd = $"az account set --subscription {config.Subscription}";
            Util.Log($"CMD: az account set --subscription");
            (errCode, result) = ShellHelper.Bash(cmd, handleRes: true);

            // var groupName = Util.GenResourceGroupName(config.BaseName);
            // var srName = Util.GenSignalRServiceName(config.BaseName);

            var rnd      = new Random();
            var SrRndNum = (rnd.Next(10000) * rnd.Next(10000)).ToString();

            var groupName = config.BaseName + "Group";
            var srName    = config.BaseName + SrRndNum + "SR";

            cmd = $"  az extension add -n signalr || true";
            Util.Log($"CMD: signalr service: {cmd}");
            (errCode, result) = ShellHelper.Bash(cmd, handleRes: true);

            // create resource group
            cmd = $"  az group create --name {groupName} --location {config.Location}";
            Util.Log($"CMD: signalr service: {cmd}");
            (errCode, result) = ShellHelper.Bash(cmd, handleRes: true);

            //create signalr service
            cmd = $"az signalr create --name {srName} --resource-group {groupName}  --sku {config.Sku} --unit-count {unitCount} --query hostName -o tsv";
            Util.Log($"CMD: signalr service: {cmd}");
            (errCode, result) = ShellHelper.Bash(cmd, handleRes: true);

            var signalrHostName = result;

            Console.WriteLine($"signalrHostName: {signalrHostName}");

            // get access key
            cmd = $"az signalr key list --name {srName} --resource-group {groupName} --query primaryKey -o tsv";
            Util.Log($"CMD: signalr service: {cmd}");
            (errCode, result) = ShellHelper.Bash(cmd, handleRes: true);
            var signalrPrimaryKey = result;

            Console.WriteLine($"signalrPrimaryKey: {signalrPrimaryKey}");

            // combine to connection string
            signalrHostName   = signalrHostName.Substring(0, signalrHostName.Length - 1);
            signalrPrimaryKey = signalrPrimaryKey.Substring(0, signalrPrimaryKey.Length - 1);
            var connectionString = $"Endpoint=https://{signalrHostName};AccessKey={signalrPrimaryKey};";

            Console.WriteLine($"connection string: {connectionString}");
            ShellHelper.Bash($"export AzureSignalRConnectionString='{connectionString}'", handleRes: true);
            return(errCode, connectionString);
        }