Example #1
0
        public override void ExecuteCmdlet()
        {
            switch (ParameterSetName)
            {
            case ParameterSet1Name:
                string webAppName, slotName;
                if (CmdletHelpers.TryParseAppAndSlotNames(Name, out webAppName, out slotName))
                {
                    Name = webAppName;

                    // We have to choose between the slot name embedded in the name parameter or the slot parameter.
                    // The choice for now is to prefer the embeeded slot name over the slot parameter.
                    Slot = slotName;
                }
                break;

            case ParameterSet2Name:
                string rg, name, slot;
                CmdletHelpers.TryParseWebAppMetadataFromResourceId(WebApp.Id, out rg, out name, out slot);

                ResourceGroupName = rg;
                Name = name;
                Slot = slot;
                break;
            }
        }
        protected override void ProcessRecord()
        {
            switch (ParameterSetName)
            {
            case ParameterSet1Name:
                string webAppName, slotName;
                if (CmdletHelpers.TryParseAppAndSlotNames(Name, out webAppName, out slotName))
                {
                    Name = webAppName;

                    // We have to choose between the slot name embedded in the name parameter or the slot parameter.
                    // The choice for now is to prefer the embeeded slot name over the slot parameter.
                    Slot = slotName;
                }
                break;

            case ParameterSet2Name:
                string rg, name, slot;
                CmdletHelpers.TryParseWebAppMetadataFromResourceId(WebApp.Id, out rg, out name, out slot);
                if (string.IsNullOrEmpty(slot))
                {
                    throw new ValidationMetadataException("Input object is a production web app. It should be deployment slot");
                }

                ResourceGroupName = rg;
                Name = name;
                Slot = slot;
                break;
            }
        }