public async Task <IViewComponentResult> InvokeAsync(string resourceGroup, string automationAccount, string runbookName) { if (string.IsNullOrEmpty(resourceGroup)) { var errorMessage = $"No Resource Group defined. Please set either a static resource group in appsettings on the server or define one in the URL like this<br><br>" + Constants.HelpTipURLParametersAll; return(View("ErrorNoInput", new ErrorViewModel { ErrorMessage = errorMessage, RequestId = System.Diagnostics.Activity.Current?.Id ?? HttpContext.TraceIdentifier })); } if (string.IsNullOrEmpty(automationAccount)) { var errorMessage = $"No Automation Account defined. Please set either a static resource group in appsettings on the server or define one in the URL like this<br><br>" + $"{Constants.HelpTipURLParametersAll}"; return(View("ErrorNoInput", new ErrorViewModel { ErrorMessage = errorMessage, RequestId = System.Diagnostics.Activity.Current?.Id ?? HttpContext.TraceIdentifier })); } if (string.IsNullOrEmpty(runbookName)) { var errorMessage = $"No runbook in URL defined. Please specify Runbook Name in one of the following formats:<br><br>" + Constants.HelpTipURL; return(View("ErrorNoInput", new ErrorViewModel { ErrorMessage = errorMessage, RequestId = System.Diagnostics.Activity.Current?.Id ?? HttpContext.TraceIdentifier })); } Dictionary <string, RunbookParameterSetting> runbookParameterSettings; try { runbookParameterSettings = await _customAzureOperations.GetRunbookParameterSettings(resourceGroup, automationAccount, runbookName); }catch (Exception ex) { var errorMessage = $"{ex.Message}<br><br>" + $"Make sure Runbook Name is correct. Please specify Runbook Name in one of the following formats:<br><br>" + Constants.HelpTipURL; return(View("~/Views/Shared/Error.cshtml", new ErrorViewModel { ErrorMessage = errorMessage, RequestId = System.Diagnostics.Activity.Current?.Id ?? HttpContext.TraceIdentifier })); } ViewBag.RunbookName = runbookName; return(View(runbookParameterSettings)); }
/// <summary> /// Return view with Runbook Name specified in the URL. Take Resource Group Name and Automation Account Name from static configuration /// </summary> /// <param name="runbookName"></param> /// <returns></returns> public async Task <IActionResult> Index(string runbookName) { if (string.IsNullOrEmpty(runbookName)) { ViewBag.NoInput = $"No input in URL defined. Please specify Runbook Name in one of the following formats:<br><br>" + $"http://<website>/?runbookName=<MyRunbookName><br>" + $"http://<website>/?runbookName=<MyRunbookName>?resourceGroup=<MyResourceGroupName>?automationAccount=<automationAccountName>"; return(View()); } ViewBag.RunbookName = runbookName; _runbookName = runbookName; _queryString = this.Request.QueryString.ToUriComponent(); ViewBag.Response = $"ResourceGroup: {_resourceGroup} Automation Account: {_automationAccount} runbook: {runbookName}"; _runbookParameterSettings = await _customAzureOperations.GetRunbookParameterSettings(_resourceGroup, _automationAccount, runbookName); return(View(_runbookParameterSettings)); }