private VirtualMachineDscExtensionStatusContext GetDscExtensionStatusContext(
            VirtualMachineExtension virtualMachineExtension, string resourceGroupName, string vmName)
        {
            var context = new VirtualMachineDscExtensionStatusContext
            {
                ResourceGroupName = resourceGroupName,
                VmName = vmName,
                Version = virtualMachineExtension.TypeHandlerVersion,
            };

            var instanceView = virtualMachineExtension.InstanceView;
            if (instanceView == null) return context;

            var statuses = instanceView.Statuses;
            var substatuses = instanceView.Substatuses;

            if (statuses != null && statuses.Count > 0)
            {
                context.StatusCode = statuses[0].Code;
                context.Status = statuses[0].DisplayStatus;
                context.StatusMessage = statuses[0].Message;
                context.Timestamp = statuses[0].Time == null ? DateTime.MinValue : statuses[0].Time.GetValueOrDefault();
            }

            if (substatuses != null && substatuses.Count > 0)
            {
                context.DscConfigurationLog = !string.Empty.Equals(substatuses[0].Message)
                    ? substatuses[0].Message.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None)
                    : new List<String>().ToArray();
            }

            return context;
        }
        private VirtualMachineDscExtensionStatusContext GetDscExtensionStatusContext(
            VirtualMachineExtension virtualMachineExtension, string resourceGroupName, string vmName)
        {
            var context = new VirtualMachineDscExtensionStatusContext
            {
                ResourceGroupName = resourceGroupName,
                VmName = vmName,
                Version = virtualMachineExtension.TypeHandlerVersion,
            };

            var instanceView = virtualMachineExtension.InstanceView;
            if (instanceView == null) return context;

            var statuses = instanceView.Statuses;
            var substatuses = instanceView.SubStatuses;

            if (statuses != null && statuses.Count > 0)
            {
                context.StatusCode = statuses[0].Code;
                context.Status = statuses[0].DisplayStatus;
                context.StatusMessage = statuses[0].Message;
                context.Timestamp = statuses[0].Time == null ? DateTime.MinValue : statuses[0].Time.GetValueOrDefault();
            }

            if (substatuses != null && substatuses.Count > 0)
            {
                context.DscConfigurationLog = !string.Empty.Equals(substatuses[0].Message)
                    ? substatuses[0].Message.Split(new[] {"\r\n", "\n"}, StringSplitOptions.None)
                    : new List<String>().ToArray();
            }

            return context;
        }