Exemple #1
0
 protected void CreateAutomationClient(MockContext context)
 {
     if (this.automationClient == null)
     {
         var handler = new RecordedDelegatingHandler();
         this.automationClient = context.GetServiceClient <AutomationClient>(false, handler);
     }
 }
 // Constructor
 public MainPage()
 {
     InitializeComponent();
     AutomationClient client = new AutomationClient();
     client.GetMenuCompleted += client_GetMenuCompleted;
     client.GetMenuAsync();
     
     // Sample code to localize the ApplicationBar
     //BuildLocalizedApplicationBar();
 }
Exemple #3
0
        protected override void DoImpl()
        {
            AppSettings[Key] = Value;
            AppSettings.Save();
            var settings = new Dictionary <string, string>();

            settings.Add(Key, Value);
            AutomationClient.RaiseApplicationSettingsChanged(settings);
            SendSuccessResult();
        }
Exemple #4
0
        public CustomAzureOperations(IConfiguration configuration)
        {
            _configuration     = configuration;
            _resourceGroup     = _configuration["AzureSettings:ResourceGroup"];
            _automationAccount = _configuration["AzureSettings:AutomationAccount"];

            Client = new AutomationClient(GetCredentials())
            {
                SubscriptionId = _configuration["AzureSettings:SubscriptionId"]
            };
        }
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            AutomationClient client = new AutomationClient();

            client.GetMenuCompleted += client_GetMenuCompleted;
            client.GetMenuAsync();

            // Sample code to localize the ApplicationBar
            //BuildLocalizedApplicationBar();
        }
 protected override void ProcessRecord()
 {
     this.ConfirmAction(
         this.Force.IsPresent,
         string.Format(CultureInfo.CurrentCulture, Resources.RemovingAzureAutomationResourceWarning, this.Name),
         string.Format(CultureInfo.CurrentCulture, Resources.RemoveAzureAutomationResourceDescription, this.Name),
         this.Name,
         () =>
         {
             AutomationClient.DeleteAutomationAccount(this.ResourceGroupName, this.Name);
         });
 }
 public override void ExecuteCmdlet()
 {
     this.ConfirmAction(
         this.Force.IsPresent,
         string.Format(CultureInfo.CurrentCulture, Resources.RemovingAzureAutomationResourceWarning, this.Name),
         string.Format(CultureInfo.CurrentCulture, Resources.RemoveAzureAutomationResourceDescription, this.Name),
         this.Name,
         () =>
     {
         AutomationClient.DeleteAutomationAccount(this.Name);
     });
 }
Exemple #8
0
 public override void ExecuteCmdlet()
 {
     this.ConfirmAction(
         this.Force.IsPresent,
         string.Format(CultureInfo.CurrentCulture, Resources.RemoveDscNodeWarning),
         string.Format(CultureInfo.CurrentCulture, Resources.RemoveDscNodeDescription, this.Id.ToString()),
         this.Id.ToString(),
         () =>
     {
         AutomationClient.DeleteDscNode(this.ResourceGroupName, this.AutomationAccountName, this.Id);
     });
 }
 protected override void AutomationExecuteCmdlet()
 {
     this.ConfirmAction(
         this.Force.IsPresent,
         string.Format(CultureInfo.CurrentCulture, Resources.RemoveAzureAutomationRunbookWarning),
         string.Format(CultureInfo.CurrentCulture, Resources.RemoveAzureAutomationRunbookDescription),
         this.Name,
         () =>
     {
         AutomationClient.DeleteRunbook(this.AutomationAccountName, this.Name);
     });
 }
        public EmulatorController(string emulatorName)
        {
            this.emulatorVm = EmulatorFactory.Instance.GetVm(emulatorName);

            if (this.emulatorVm == null)
            {
                throw new NullReferenceException(
                          string.Format("Could not get running XDE virtual machine {0}", emulatorName));
            }

            this.client = AutomationClient.CreateAutomationClient(this.emulatorVm.Name);

            this.cursor          = new Point(0, 0);
            this.PhoneScreenSize = this.emulatorVm.GetCurrentResolution();
        }
Exemple #11
0
        public override void ExecuteCmdlet()
        {
            if (ShouldProcess(Path, VerbsData.Import))
            {
                Path = ResolveUserPath(Path);
                var nodeName = System.IO.Path.GetFileNameWithoutExtension(Path);
                var nodeConfigurationName = ConfigurationName + "." + nodeName;
                NodeConfiguration nodeConfigurationModel = null;

                try
                {
                    // if node configuration already exists, ensureuser knows about it.
                    nodeConfigurationModel = AutomationClient.GetNodeConfiguration(ResourceGroupName,
                                                                                   AutomationAccountName,
                                                                                   nodeConfigurationName,
                                                                                   null);
                }
                catch (ResourceNotFoundException)
                {
                    nodeConfigurationModel = null;
                }

                if (nodeConfigurationModel != null && !IncrementNodeConfigurationBuild.IsPresent)
                {
                    if (Force || ShouldContinue(Resources.NodeConfigurationAlreadyExistsConfirmation,
                                                Resources.NodeConfigurationAlreadyExistsCaption))
                    {
                        var nodeConfiguration = AutomationClient.CreateNodeConfiguration(
                            ResourceGroupName, AutomationAccountName, Path, ConfigurationName, false, Force);

                        WriteObject(nodeConfiguration);
                    }
                }
                else
                {
                    var nodeConfiguration = AutomationClient.CreateNodeConfiguration(
                        ResourceGroupName,
                        AutomationAccountName,
                        Path,
                        ConfigurationName,
                        IncrementNodeConfigurationBuild.IsPresent,
                        false);

                    WriteObject(nodeConfiguration);
                }
            }
        }
Exemple #12
0
        protected override void AutomationProcessRecord()
        {
            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (ParameterSetName)
            {
            case AutomationCmdletParameterSets.ByInputObject:
                if (ShouldProcess(NodeConfigurationName, VerbsLifecycle.Start))
                {
                    if (Force || ShouldContinue(Resources.StartAzureAutomationNodeConfigurationWarning,
                                                Resources.StartAzureAutomationNodeConfigurationDescription))
                    {
                        var nodeConfigurationDeployment = AutomationClient.StartNodeConfigurationDeployment(
                            InputObject.ResourceGroupName,
                            InputObject.AutomationAccountName,
                            InputObject.NodeConfigurationName,
                            NodeName,
                            Schedule);

                        WriteObject(nodeConfigurationDeployment);
                    }
                }
                break;

            case AutomationCmdletParameterSets.ByAll:
                if (ShouldProcess(NodeConfigurationName, VerbsLifecycle.Start))
                {
                    if (Force || ShouldContinue(Resources.StartAzureAutomationNodeConfigurationWarning,
                                                Resources.StartAzureAutomationNodeConfigurationDescription))
                    {
                        var nodeConfigurationDeployment = AutomationClient.StartNodeConfigurationDeployment(ResourceGroupName,
                                                                                                            AutomationAccountName,
                                                                                                            NodeConfigurationName,
                                                                                                            NodeName,
                                                                                                            Schedule);

                        WriteObject(nodeConfigurationDeployment);
                    }
                }
                break;
            }
        }
Exemple #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomAzureOperations"/> class.
        /// </summary>
        /// <param name="configuration">The configuration<see cref="IConfiguration"/></param>
        public CustomAzureOperations(IConfiguration configuration, IMessageSender messageSender)
        {
            _configuration = configuration;
            _messageSender = messageSender;

            //TODO try get this or throw exception
            var settings = _configuration.GetSection("AzureSettings").GetChildren().Where(p => p.Key == "AutomationTag").FirstOrDefault();

            if (settings == null)
            {
                var errorstring = @"The section AutomationTag does not exist in Appsettings in AzureSettings section. Please specify this like so:
                    ""AutomationTag"": {
                          ""Visibility"": {
                            ""Key"": ""FormGenerator:Visibility"",
                            ""Value"": ""Visible""
                          },
                          ""DisplayName"": {
                                        ""Key"": ""FormGenerator:DisplayName""
                          },
                          ""Description"": {
                                        ""Key"": ""FormGenerator:Description""
                          },
                          ""HybridWorkerGroup"": {
                                        ""Key"": ""FormGenerator:HybridWorkerGroup""
                           }
                            
                        }";
                throw new Exception(errorstring);
            }
            _automationTagVisibility        = new KeyValuePair <string, string>(_configuration["AzureSettings:AutomationTag:Visibility:Key"], _configuration["AzureSettings:AutomationTag:Visibility:Value"]);
            _automationTagDisplayName       = new KeyValuePair <string, string>(_configuration["AzureSettings:AutomationTag:DisplayName:Key"], _configuration["AzureSettings:AutomationTag:DisplayName:Value"]);
            _automationTagDescription       = new KeyValuePair <string, string>(_configuration["AzureSettings:AutomationTag:Description:Key"], _configuration["AzureSettings:AutomationTag:Description:Value"]);
            _automationTagHybridWorkerGroup = new KeyValuePair <string, string>(_configuration["AzureSettings:AutomationTag:HybridWorkerGroup:Key"], _configuration["AzureSettings:AutomationTag:HybridWorkerGroup:Value"]);
            Client = new AutomationClient(GetCredentials())
            {
                SubscriptionId = _configuration["AzureSettings:SubscriptionId"]
            };
        }
Exemple #14
0
        protected override void DoImpl()
        {
            try
            {
                // Remove any keys that would be duplicates before starting.
                foreach (var key in this.Settings.Keys.Where(key => AppSettings.Contains(key)))
                {
                    AppSettings.Remove(key);
                }

                foreach (var pair in this.Settings)
                {
                    AppSettings.Add(pair.Key, pair.Value);
                }

                AppSettings.Save();
                AutomationClient.RaiseApplicationSettingsChanged(Settings);
                SendSuccessResult();
            }
            catch (Exception ex)
            {
                SendExceptionFailedResult(ex);
            }
        }
Exemple #15
0
 public CustomAzureOperations(AutomationClient automationClient)
 {
     Client = automationClient;
 }