public async override Task <(string deletedHostLocation, string errorMessage)> DeleteHostingResources() { if (_azure == null) { _azure = new AzureAutomation(GetAzureAppServiceConfig(AdditionalConfigs), _azureUtils, _deployUtils, Logger); } var subscriptionId = ""; if (AdditionalConfigs.ContainsKey("SubscriptionId") && !string.IsNullOrEmpty(AdditionalConfigs["SubscriptionId"])) { subscriptionId = AdditionalConfigs["SubscriptionId"]; } else { return(null, "Subscription Id is not provided"); } var resourceGroupName = ""; if (AdditionalConfigs.ContainsKey("ResourceGroupName") && !string.IsNullOrEmpty(AdditionalConfigs["ResourceGroupName"])) { resourceGroupName = AdditionalConfigs["ResourceGroupName"]; } else { return(null, "Resource group name is not provided"); } var appServiceName = ProjectName; if (AdditionalConfigs.ContainsKey("AppServiceName") && !string.IsNullOrEmpty(AdditionalConfigs["AppServiceName"])) { appServiceName = AdditionalConfigs["AppServiceName"]; } var deploymentSlot = ""; if (AdditionalConfigs.ContainsKey("DeploymentSlot") && !string.IsNullOrEmpty(AdditionalConfigs["DeploymentSlot"])) { deploymentSlot = AdditionalConfigs["DeploymentSlot"]; } return(await _azure.DeleteWebsite(subscriptionId, resourceGroupName, appServiceName, deploymentSlot)); }
public override async Task <(string hostLocation, Dictionary <string, string> outputValues, string errorMessage)> Deploy() { if (_azure == null) { _azure = new AzureAutomation(GetAzureAppServiceConfig(AdditionalConfigs), _azureUtils, _deployUtils, Logger); } var subscriptionId = ""; if (AdditionalConfigs.ContainsKey("SubscriptionId") && !string.IsNullOrEmpty(AdditionalConfigs["SubscriptionId"])) { subscriptionId = AdditionalConfigs["SubscriptionId"]; } var resourceGroupName = ""; if (AdditionalConfigs.ContainsKey("ResourceGroupName") && !string.IsNullOrEmpty(AdditionalConfigs["ResourceGroupName"])) { resourceGroupName = AdditionalConfigs["ResourceGroupName"]; } bool allowAutomaticRename = true; if (AdditionalConfigs.ContainsKey("AllowAutomaticRename")) { bool.TryParse(AdditionalConfigs["AllowAutomaticRename"], out allowAutomaticRename); } var appServiceName = ProjectName; if (AdditionalConfigs.ContainsKey("AppServiceName") && !string.IsNullOrEmpty(AdditionalConfigs["AppServiceName"])) { appServiceName = AdditionalConfigs["AppServiceName"]; } else { // if the app service name is not defined, the allow rename should always be true allowAutomaticRename = true; } var deploymentSlot = ""; if (AdditionalConfigs.ContainsKey("DeploymentSlot") && !string.IsNullOrEmpty(AdditionalConfigs["DeploymentSlot"])) { deploymentSlot = AdditionalConfigs["DeploymentSlot"]; } var connectionString = ""; if (AdditionalConfigs.ContainsKey("ConnectionString") && !string.IsNullOrEmpty(AdditionalConfigs["ConnectionString"])) { connectionString = AdditionalConfigs["ConnectionString"]; } var region = "southcentralus"; if (AdditionalConfigs.ContainsKey("Region") && !string.IsNullOrEmpty(AdditionalConfigs["Region"])) { region = AdditionalConfigs["Region"]; } var appServicePlan = ""; if (AdditionalConfigs.ContainsKey("AppServicePlan") && !string.IsNullOrEmpty(AdditionalConfigs["AppServicePlan"])) { appServicePlan = AdditionalConfigs["AppServicePlan"]; } var artifactLocation = Config.ArtifactLocation ?? Path.Combine(Config.WorkingLocation, "artifact", $"{ProjectName}.zip"); if (!Path.IsPathRooted(artifactLocation)) { artifactLocation = Path.Combine(Config.WorkingLocation, artifactLocation); } var(hostLocation, error) = await _azure.DeployWebsite(artifactLocation, subscriptionId, resourceGroupName, appServiceName, deploymentSlot, connectionString, region, appServicePlan, allowAutomaticRename); if (!string.IsNullOrEmpty(error)) { return("", null, error); } return(hostLocation, null, ""); }