public override void ExecuteCmdlet()
        {
            ExecuteClientAction(() =>
            {
                WriteWarning("Update-AzureRmSnapshot: A property of the output of this cmdlet will change in an upcoming breaking change release. " +
                             "The Name property for a Sku will return Standard_LRS and Premium_LRS");

                if (ShouldProcess(this.SnapshotName, VerbsData.Update))
                {
                    string resourceGroupName      = this.ResourceGroupName;
                    string snapshotName           = this.SnapshotName;
                    SnapshotUpdate snapshotupdate = new SnapshotUpdate();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSSnapshotUpdate, SnapshotUpdate>(this.SnapshotUpdate, snapshotupdate);
                    Snapshot snapshot = new Snapshot();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSSnapshot, Snapshot>(this.Snapshot, snapshot);

                    var result = (this.SnapshotUpdate == null)
                                 ? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshot)
                                 : SnapshotsClient.Update(resourceGroupName, snapshotName, snapshotupdate);
                    var psObject = new PSSnapshot();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <Snapshot, PSSnapshot>(result, psObject);
                    WriteObject(psObject);
                }
            });
        }
        protected override void ProcessRecord()
        {
            ComputeAutomationAutoMapperProfile.Initialize();
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.ResourceGroupName, VerbsData.Update))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string snapshotName      = this.SnapshotName;

                    Snapshot snapshotObj = new Snapshot();
                    Mapper.Map <PSSnapshot, Snapshot>(this.Snapshot, snapshotObj);

                    SnapshotUpdate snapshotUpdateObj = new SnapshotUpdate();
                    Mapper.Map <PSSnapshotUpdate, SnapshotUpdate>(this.SnapshotUpdate, snapshotUpdateObj);

                    var result = (this.SnapshotUpdate == null)
                                 ? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshotObj)
                                 : SnapshotsClient.Update(resourceGroupName, snapshotName, snapshotUpdateObj);

                    var psObject = new PSSnapshot();
                    Mapper.Map <Snapshot, PSSnapshot>(result, psObject);

                    WriteObject(psObject);
                }
            });
        }
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();
            ExecuteClientAction(() =>
            {
                Snapshot existingResource;
                try
                {
                    existingResource = SnapshotsClient.Get(this.ResourceGroupName, this.SnapshotName);
                }
                catch
                {
                    existingResource = null;
                }

                if (existingResource != null)
                {
                    throw new Exception(string.Format("A Snapshot with name '{0}' in resource group '{1}' already exists. Please use Update-AzSnapshot to update an existing Snapshot.", this.SnapshotName, this.ResourceGroupName));
                }

                if (ShouldProcess(this.SnapshotName, VerbsCommon.New))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string snapshotName      = this.SnapshotName;
                    Snapshot snapshot        = new Snapshot();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSSnapshot, Snapshot>(this.Snapshot, snapshot);

                    var result   = SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshot);
                    var psObject = new PSSnapshot();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <Snapshot, PSSnapshot>(result, psObject);
                    WriteObject(psObject);
                }
            });
        }
Beispiel #4
0
        protected void ExecuteSnapshotCreateOrUpdateMethod(object[] invokeMethodInputParameters)
        {
            string     resourceGroupName = (string)ParseParameter(invokeMethodInputParameters[0]);
            string     snapshotName      = (string)ParseParameter(invokeMethodInputParameters[1]);
            PSSnapshot snapshot          = (PSSnapshot)ParseParameter(invokeMethodInputParameters[2]);

            var result = SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshot);

            WriteObject(result);
        }
        protected void ExecuteSnapshotUpdateMethod(object[] invokeMethodInputParameters)
        {
            string         resourceGroupName = (string)ParseParameter(invokeMethodInputParameters[0]);
            string         snapshotName      = (string)ParseParameter(invokeMethodInputParameters[1]);
            SnapshotUpdate snapshot          = (SnapshotUpdate)ParseParameter(invokeMethodInputParameters[2]);
            Snapshot       snapshotOrg       = (Snapshot)ParseParameter(invokeMethodInputParameters[3]);

            var result = (snapshot == null)
                         ? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshotOrg)
                         : SnapshotsClient.Update(resourceGroupName, snapshotName, snapshot);

            WriteObject(result);
        }
Beispiel #6
0
        protected override void ProcessRecord()
        {
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.ResourceGroupName, VerbsCommon.New))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string snapshotName      = this.SnapshotName;
                    PSSnapshot snapshot      = this.Snapshot;

                    var result = SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshot);
                    WriteObject(result);
                }
            });
        }
        public override void ExecuteCmdlet()
        {
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.SnapshotName, VerbsCommon.New))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string snapshotName      = this.SnapshotName;
                    Snapshot snapshot        = new Snapshot();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSSnapshot, Snapshot>(this.Snapshot, snapshot);

                    var result   = SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshot);
                    var psObject = new PSSnapshot();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <Snapshot, PSSnapshot>(result, psObject);
                    WriteObject(psObject);
                }
            });
        }
        protected override void ProcessRecord()
        {
            ComputeAutomationAutoMapperProfile.Initialize();
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.ResourceGroupName, VerbsCommon.New))
                {
                    string resourceGroupName = this.ResourceGroupName;
                    string snapshotName      = this.SnapshotName;
                    Snapshot snapshot        = new Snapshot();
                    Mapper.Map <PSSnapshot, Snapshot>(this.Snapshot, snapshot);

                    var result = SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshot);

                    PSSnapshot psResult = new PSSnapshot();
                    Mapper.Map <Snapshot, PSSnapshot>(result, psResult);
                    WriteObject(psResult);
                }
            });
        }
        protected override void ProcessRecord()
        {
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.ResourceGroupName, VerbsData.Update))
                {
                    string resourceGroupName  = this.ResourceGroupName;
                    string snapshotName       = this.SnapshotName;
                    PSSnapshotUpdate snapshot = this.SnapshotUpdate;
                    PSSnapshot snapshotOrg    = this.Snapshot;

                    var result = (snapshot == null)
                                 ? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshotOrg)
                                 : SnapshotsClient.Update(resourceGroupName, snapshotName, snapshot);

                    var psObject = new PSSnapshot();
                    Mapper.Map <Snapshot, PSSnapshot>(result, psObject);

                    WriteObject(psObject);
                }
            });
        }
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();
            ExecuteClientAction(() =>
            {
                if (ShouldProcess(this.SnapshotName, VerbsData.Update))
                {
                    string resourceGroupName      = this.ResourceGroupName;
                    string snapshotName           = this.SnapshotName;
                    SnapshotUpdate snapshotupdate = new SnapshotUpdate();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSSnapshotUpdate, SnapshotUpdate>(this.SnapshotUpdate, snapshotupdate);
                    Snapshot snapshot = new Snapshot();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <PSSnapshot, Snapshot>(this.Snapshot, snapshot);

                    var result = (this.SnapshotUpdate == null)
                                 ? SnapshotsClient.CreateOrUpdate(resourceGroupName, snapshotName, snapshot)
                                 : SnapshotsClient.Update(resourceGroupName, snapshotName, snapshotupdate);
                    var psObject = new PSSnapshot();
                    ComputeAutomationAutoMapperProfile.Mapper.Map <Snapshot, PSSnapshot>(result, psObject);
                    WriteObject(psObject);
                }
            });
        }