From d5e125a01dbb10fb2cd2a1b2c8bf4008829a8d2b Mon Sep 17 00:00:00 2001 From: Anu Thomas Chandy Date: Tue, 18 Jun 2019 10:05:34 -0700 Subject: [PATCH] Release 1.22.2 --- Asset/create_resources_with_msi.sh | 4 +- Asset/install_apache.sh | 4 +- Common/Utilities.cs | 244 +++++++++++++++++++++++++++- ManageVirtualMachineScaleSet.csproj | 6 +- README.md | 4 +- 5 files changed, 245 insertions(+), 17 deletions(-) diff --git a/Asset/create_resources_with_msi.sh b/Asset/create_resources_with_msi.sh index 48bf4a1..b6529c7 100644 --- a/Asset/create_resources_with_msi.sh +++ b/Asset/create_resources_with_msi.sh @@ -1,8 +1,8 @@ -#!/bin/bash +#!/bin/bash /usr/bin/yes | sudo apt-get update /usr/bin/yes | sudo apt install python-pip /usr/bin/yes | sudo pip install --upgrade pip sudo pip install azure-cli az login --identity -u $1 -az storage account create -n $2 -g $3 -l $4 --sku Premium_LRS \ No newline at end of file +az storage account create -n $2 -g $3 -l $4 --sku Premium_LRS diff --git a/Asset/install_apache.sh b/Asset/install_apache.sh index 2460cc2..1789520 100644 --- a/Asset/install_apache.sh +++ b/Asset/install_apache.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash sudo apt-get update @@ -6,4 +6,4 @@ sudo apt-get update sudo apt-get -y install apache2 # restart Apache -sudo apachectl restart \ No newline at end of file +sudo service apache2 restart \ No newline at end of file diff --git a/Common/Utilities.cs b/Common/Utilities.cs index 13b3142..048215d 100644 --- a/Common/Utilities.cs +++ b/Common/Utilities.cs @@ -2338,8 +2338,6 @@ public static void Print(IBatchAICluster resource) StringBuilder sb = new StringBuilder("Batch AI cluster: ") .Append("\n\tId: ").Append(resource.Id) .Append("\n\tName: ").Append(resource.Name) - .Append("\n\tResource group: ").Append(resource.ResourceGroupName) - .Append("\n\tRegion: ").Append(resource.RegionName) .Append("\n\tVM Size: ").Append(resource.VMSize) .Append("\n\tVM Priority: ").Append(resource.VMPriority) .Append("\n\tSubnet: ").Append(resource.Subnet) @@ -2361,7 +2359,7 @@ public static void Print(IBatchAICluster resource) sb.Append("\n\tManual scale settings: ") .Append("\n\t\tTarget node count: ").Append(resource.ScaleSettings.Manual.TargetNodeCount) .Append("\n\t\tDeallocation option: ") - .Append(resource.ScaleSettings.Manual.NodeDeallocationOption.GetValueOrDefault()); + .Append(resource.ScaleSettings.Manual.NodeDeallocationOption); } if (resource.NodeStateCounts != null) { @@ -2384,7 +2382,6 @@ public static void Print(IBatchAICluster resource) { sb.Append("\n\tSetup task: ") .Append("\n\t\tCommand line: ").Append(resource.NodeSetup.SetupTask.CommandLine) - .Append("\n\t\tRun elevated: ").Append(resource.NodeSetup.SetupTask.RunElevated) .Append("\n\t\tStdout/err Path Prefix: ").Append(resource.NodeSetup.SetupTask.StdOutErrPathPrefix); } Utilities.Log(sb.ToString()); @@ -2395,19 +2392,250 @@ public static void Print(IBatchAIJob resource) StringBuilder sb = new StringBuilder("Batch AI job: ") .Append("\n\tId: ").Append(resource.Id) .Append("\n\tName: ").Append(resource.Name) - .Append("\n\tResource group: ").Append(resource.ResourceGroupName) - .Append("\n\tRegion: ").Append(resource.RegionName) .Append("\n\tCluster Id: ").Append(resource.Cluster) .Append("\n\tCreation time: ").Append(resource.CreationTime) .Append("\n\tNode count: ").Append(resource.NodeCount) - .Append("\n\tPriority: ").Append(resource.Priority) + .Append("\n\tPriority: ").Append(resource.SchedulingPriority) .Append("\n\tExecution state: ").Append(resource.ExecutionState) .Append("\n\tExecution state transition time: ").Append(resource.ExecutionStateTransitionTime) .Append("\n\tTool type: ").Append(resource.ToolType) - .Append("\n\tExperiment name: ").Append(resource.ExperimentName); + .Append("\n\tExperiment name: ").Append(resource.Experiment.Name); Utilities.Log(sb.ToString()); } + /** + * Print Action group settings. + * + * @param actionGroup action group instance + */ + public static void Print(IActionGroup actionGroup) + { + StringBuilder info = new StringBuilder("Action Group: ") + .Append("\n\tId: ").Append(actionGroup.Id) + .Append("\n\tName: ").Append(actionGroup.Name) + .Append("\n\tShort Name: ").Append(actionGroup.ShortName); + + if (actionGroup.EmailReceivers != null && actionGroup.EmailReceivers.Any()) + { + info.Append("\n\tEmail receivers: "); + foreach (var er in actionGroup.EmailReceivers) + { + info.Append("\n\t\tName: ").Append(er.Name); + info.Append("\n\t\tEMail: ").Append(er.EmailAddress); + info.Append("\n\t\tStatus: ").Append(er.Status); + info.Append("\n\t\t==="); + } + } + + if (actionGroup.SmsReceivers != null && actionGroup.SmsReceivers.Any()) + { + info.Append("\n\tSMS text message receivers: "); + foreach (var er in actionGroup.SmsReceivers) + { + info.Append("\n\t\tName: ").Append(er.Name); + info.Append("\n\t\tPhone: ").Append(er.CountryCode + er.PhoneNumber); + info.Append("\n\t\tStatus: ").Append(er.Status); + info.Append("\n\t\t==="); + } + } + + if (actionGroup.WebhookReceivers != null && actionGroup.WebhookReceivers.Any()) + { + info.Append("\n\tWebhook receivers: "); + foreach (var er in actionGroup.WebhookReceivers) + { + info.Append("\n\t\tName: ").Append(er.Name); + info.Append("\n\t\tURI: ").Append(er.ServiceUri); + info.Append("\n\t\t==="); + } + } + + if (actionGroup.PushNotificationReceivers != null && actionGroup.PushNotificationReceivers.Any()) + { + info.Append("\n\tApp Push Notification receivers: "); + foreach (var er in actionGroup.PushNotificationReceivers) + { + info.Append("\n\t\tName: ").Append(er.Name); + info.Append("\n\t\tEmail: ").Append(er.EmailAddress); + info.Append("\n\t\t==="); + } + } + + if (actionGroup.VoiceReceivers != null && actionGroup.VoiceReceivers.Any()) + { + info.Append("\n\tVoice Message receivers: "); + foreach (var er in actionGroup.VoiceReceivers) + { + info.Append("\n\t\tName: ").Append(er.Name); + info.Append("\n\t\tPhone: ").Append(er.CountryCode + er.PhoneNumber); + info.Append("\n\t\t==="); + } + } + + if (actionGroup.AutomationRunbookReceivers != null && actionGroup.AutomationRunbookReceivers.Any()) + { + info.Append("\n\tAutomation Runbook receivers: "); + foreach (var er in actionGroup.AutomationRunbookReceivers) + { + info.Append("\n\t\tName: ").Append(er.Name); + info.Append("\n\t\tRunbook Name: ").Append(er.RunbookName); + info.Append("\n\t\tAccount Id: ").Append(er.AutomationAccountId); + info.Append("\n\t\tIs Global: ").Append(er.IsGlobalRunbook); + info.Append("\n\t\tService URI: ").Append(er.ServiceUri); + info.Append("\n\t\tWebhook resource Id: ").Append(er.WebhookResourceId); + info.Append("\n\t\t==="); + } + } + + if (actionGroup.AzureFunctionReceivers != null && actionGroup.AzureFunctionReceivers.Any()) + { + info.Append("\n\tAzure Functions receivers: "); + foreach(var er in actionGroup.AzureFunctionReceivers) + { + info.Append("\n\t\tName: ").Append(er.Name); + info.Append("\n\t\tFunction Name: ").Append(er.FunctionName); + info.Append("\n\t\tFunction App Resource Id: ").Append(er.FunctionAppResourceId); + info.Append("\n\t\tFunction Trigger URI: ").Append(er.HttpTriggerUrl); + info.Append("\n\t\t==="); + } + } + + if (actionGroup.LogicAppReceivers != null && actionGroup.LogicAppReceivers.Any()) + { + info.Append("\n\tLogic App receivers: "); + foreach (var er in actionGroup.LogicAppReceivers) + { + info.Append("\n\t\tName: ").Append(er.Name); + info.Append("\n\t\tResource Id: ").Append(er.ResourceId); + info.Append("\n\t\tCallback URL: ").Append(er.CallbackUrl); + info.Append("\n\t\t==="); + } + } + + if (actionGroup.ItsmReceivers != null && actionGroup.ItsmReceivers.Any()) + { + info.Append("\n\tITSM receivers: "); + foreach(var er in actionGroup.ItsmReceivers) + { + info.Append("\n\t\tName: ").Append(er.Name); + info.Append("\n\t\tWorkspace Id: ").Append(er.WorkspaceId); + info.Append("\n\t\tConnection Id: ").Append(er.ConnectionId); + info.Append("\n\t\tRegion: ").Append(er.Region); + info.Append("\n\t\tTicket Configuration: ").Append(er.TicketConfiguration); + info.Append("\n\t\t==="); + } + } + Utilities.Log(info.ToString()); + } + + /** + * Print activity log alert settings. + * + * @param activityLogAlert activity log instance + */ + public static void Print(IActivityLogAlert activityLogAlert) + { + + StringBuilder info = new StringBuilder("Activity Log Alert: ") + .Append("\n\tId: ").Append(activityLogAlert.Id) + .Append("\n\tName: ").Append(activityLogAlert.Name) + .Append("\n\tDescription: ").Append(activityLogAlert.Description) + .Append("\n\tIs Enabled: ").Append(activityLogAlert.Enabled); + + if (activityLogAlert.Scopes != null && activityLogAlert.Scopes.Any()) + { + info.Append("\n\tScopes: "); + foreach (var er in activityLogAlert.Scopes) + { + info.Append("\n\t\tId: ").Append(er); + } + } + + if (activityLogAlert.ActionGroupIds != null && activityLogAlert.ActionGroupIds.Any()) + { + info.Append("\n\tAction Groups: "); + foreach(var er in activityLogAlert.ActionGroupIds) + { + info.Append("\n\t\tAction Group Id: ").Append(er); + } + } + + if (activityLogAlert.EqualsConditions != null && activityLogAlert.EqualsConditions.Any()) + { + info.Append("\n\tAlert conditions (when all of is true): "); + foreach (var er in activityLogAlert.EqualsConditions) + { + info.Append("\n\t\t'").Append(er.Key).Append("' equals '").Append(er.Value).Append("'"); + } + } + Utilities.Log(info.ToString()); + } + + /** + * Print metric alert settings. + * + * @param metricAlert metric alert instance + */ + public static void Print(IMetricAlert metricAlert) + { + + StringBuilder info = new StringBuilder("Metric Alert: ") + .Append("\n\tId: ").Append(metricAlert.Id) + .Append("\n\tName: ").Append(metricAlert.Name) + .Append("\n\tDescription: ").Append(metricAlert.Description) + .Append("\n\tIs Enabled: ").Append(metricAlert.Enabled) + .Append("\n\tIs Auto Mitigated: ").Append(metricAlert.AutoMitigate) + .Append("\n\tSeverity: ").Append(metricAlert.Severity) + .Append("\n\tWindow Size: ").Append(metricAlert.WindowSize) + .Append("\n\tEvaluation Frequency: ").Append(metricAlert.EvaluationFrequency); + + if (metricAlert.Scopes != null && metricAlert.Scopes.Any()) + { + info.Append("\n\tScopes: "); + foreach (var er in metricAlert.Scopes) + { + info.Append("\n\t\tId: ").Append(er); + } + } + + if (metricAlert.ActionGroupIds != null && metricAlert.ActionGroupIds.Any()) + { + info.Append("\n\tAction Groups: "); + foreach (var er in metricAlert.ActionGroupIds) + { + info.Append("\n\t\tAction Group Id: ").Append(er); + } + } + + if (metricAlert.AlertCriterias != null && metricAlert.AlertCriterias.Any()) + { + info.Append("\n\tAlert conditions (when all of is true): "); + foreach (var er in metricAlert.AlertCriterias) + { + var alertCondition = er.Value; + info.Append("\n\t\tCondition name: ").Append(er.Key) + .Append("\n\t\tSignal name: ").Append(alertCondition.MetricName) + .Append("\n\t\tMetric Namespace: ").Append(alertCondition.MetricNamespace) + .Append("\n\t\tOperator: ").Append(alertCondition.Condition) + .Append("\n\t\tThreshold: ").Append(alertCondition.Threshold) + .Append("\n\t\tTime Aggregation: ").Append(alertCondition.TimeAggregation); + if (alertCondition.Dimensions != null && alertCondition.Dimensions.Any()) + { + foreach (var dimon in alertCondition.Dimensions) + { + info.Append("\n\t\tDimension Filter: ").Append("Name [").Append(dimon.Name).Append("] operator [Include] values["); + foreach (var vals in dimon.Values) + { + info.Append(vals).Append(", "); + } + info.Append("]"); + } + } + } + } + Utilities.Log(info.ToString()); + } + public static void CreateCertificate(string domainName, string pfxPath, string password) { if (!IsRunningMocked) diff --git a/ManageVirtualMachineScaleSet.csproj b/ManageVirtualMachineScaleSet.csproj index 1fced8b..27eaafe 100644 --- a/ManageVirtualMachineScaleSet.csproj +++ b/ManageVirtualMachineScaleSet.csproj @@ -18,9 +18,9 @@ - - - + + + diff --git a/README.md b/README.md index 907f6c6..dbc3609 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ --- services: Compute platforms: dotnet -author: selvasingh +author: yaohaizh --- # Getting started on managing virtual machine scale sets in C# # @@ -22,7 +22,7 @@ author: selvasingh To run this sample: -Set the environment variable `AZURE_AUTH_LOCATION` with the full path for an auth file. See [how to create an auth file](https://github.com/Azure/azure-libraries-for-java/blob/master/AUTH.md). +Set the environment variable `AZURE_AUTH_LOCATION` with the full path for an auth file. See [how to create an auth file](https://github.com/Azure/azure-libraries-for-net/blob/master/AUTH.md). git clone https://github.com/Azure-Samples/compute-dotnet-manage-virtual-machine-scale-sets.git