private void DeployCode() { //az login --service-principal -u "http://my-app" -p <password> --tenant <tenant> var loginProcess = ProcessEx.Create(factory.CodePath, az, $"login --service-principal -u {config["client_id"]} -p {config["client_secret"]} --tenant {config["tenant_id"]}"); if (!loginProcess.StopAtError()) { throw new DeployingException(DeployingException.AzureLoginFailed); } Directory.CreateDirectory(factory.PackagePath); foreach (var function in factory.Components.OfType <Function>()) { var functionFolder = $"{factory.CodePath}/{function.FunctionName}"; InstallModules(functionFolder); //az functionapp deployment source config-zip -g test -n test1543 --src /Users/Tooraj/MyFunctionProj/HttpTrigger.zip var packagePath = $"{factory.PackagePath}/{function.FunctionName}.zip"; ZipFile.CreateFromDirectory($"{factory.CodePath}/{function.FunctionName}", packagePath); var rg = config["resource_group"]; var pushCodeProcess = ProcessEx.Create(factory.CodePath, az, $"functionapp deployment source config-zip -g {rg} -n {function.FunctionName} --src {packagePath}"); if (!pushCodeProcess.StopAtError()) { throw new DeployingException(DeployingException.CodePushFailed); } } }
private void RunTf() { var initProcess = ProcessEx.Create(factory.TfPath, terraform, "init"); if (!initProcess.StopAtError()) { throw new DeployingException(DeployingException.DeploymentinitializionFailed); } if (ApplicationSettings.Debug) { initProcess.WaitForExit(); } var applyProcess = ProcessEx.Create(factory.TfPath, terraform, "apply -auto-approve"); if (!applyProcess.StopAtError()) { throw new DeployingException(DeployingException.DeploymentExecutionFailed); } if (ApplicationSettings.Debug) { applyProcess.WaitForExit(); } DeployCloudSpecific(); eventLogger.Log(factory.BuildId, "Deployed all components."); }
private void InstallModules(string functionFolder) { var installProcess = ProcessEx.Create(functionFolder, "npm", "install"); if (!installProcess.StopAtError()) { throw new DeployingException(DeployingException.ModuleInstallationFailed); } }