示例#1
0
        public override void ExecuteCmdlet()
        {
            if (ShouldProcess(Name, "Update Container Registry"))
            {
                var tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true);

                bool?adminUserEnabled = null;

                if (EnableAdminUser || DisableAdminUser)
                {
                    adminUserEnabled = EnableAdminUser || !DisableAdminUser;
                }

                string storageAccountResourceGroup = null;

                if (StorageAccountName != null)
                {
                    storageAccountResourceGroup = ResourceManagerClient.GetStorageAccountResourceGroup(StorageAccountName);
                }

                var registry = RegistryClient.UpdateRegistry(
                    ResourceGroupName, Name, adminUserEnabled, StorageAccountName, storageAccountResourceGroup, tags);
                WriteObject(new PSContainerRegistry(registry));
            }
        }
        public override void ExecuteCmdlet()
        {
            if (ShouldProcess(Name, "Create Container Registry"))
            {
                var registryNameStatus = RegistryClient.CheckRegistryNameAvailability(Name);

                if (registryNameStatus?.NameAvailable != null && !registryNameStatus.NameAvailable.Value)
                {
                    throw new InvalidOperationException(registryNameStatus.Message);
                }

                var tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true);

                if (Location == null)
                {
                    Location = ResourceManagerClient.GetResourceGroupLocation(ResourceGroupName);
                }

                DeploymentExtended result = ResourceManagerClient.CreateRegistry(
                    ResourceGroupName, Name, Location, Sku, EnableAdminUser, StorageAccountName, tags);

                if (result.Properties.ProvisioningState == DeploymentState.Succeeded.ToString())
                {
                    var registry = RegistryClient.GetRegistry(ResourceGroupName, Name);
                    WriteObject(new PSContainerRegistry(registry));
                }
            }
        }
        public override void ExecuteCmdlet()
        {
            if (ShouldProcess(Name, "Create Container Registry"))
            {
                var registryNameStatus = RegistryClient.CheckRegistryNameAvailability(Name);

                if (registryNameStatus?.NameAvailable != null && !registryNameStatus.NameAvailable.Value)
                {
                    throw new InvalidOperationException(registryNameStatus.Message);
                }

                var tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true);

                if (Location == null)
                {
                    Location = ResourceManagerClient.GetResourceGroupLocation(ResourceGroupName);
                }

                var registry = new Registry
                {
                    Sku = new Microsoft.Azure.Management.ContainerRegistry.Models.Sku(Sku),
                    AdminUserEnabled = EnableAdminUser,
                    Tags             = tags,
                    Location         = Location
                };

                var createdRegistry = RegistryClient.CreateRegistry(ResourceGroupName, Name, registry);
                WriteObject(new PSContainerRegistry(createdRegistry));
            }
        }
        public override void ExecuteCmdlet()
        {
            if (ShouldProcess(Name, "Create Container Registry"))
            {
                var registryNameStatus = RegistryClient.CheckRegistryNameAvailability(Name);

                if (registryNameStatus?.NameAvailable != null && !registryNameStatus.NameAvailable.Value)
                {
                    throw new InvalidOperationException(registryNameStatus.Message);
                }

                var tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true);

                if (Location == null)
                {
                    Location = ResourceManagerClient.GetResourceGroupLocation(ResourceGroupName);
                }

                if (string.Equals(Sku, SkuName.Classic) && StorageAccountName == null)
                {
                    DeploymentExtended result = ResourceManagerClient.CreateClassicRegistry(
                        ResourceGroupName, Name, Location, EnableAdminUser, tags);

                    if (result.Properties.ProvisioningState == DeploymentState.Succeeded.ToString())
                    {
                        var registry = RegistryClient.GetRegistry(ResourceGroupName, Name);
                        WriteObject(new PSContainerRegistry(registry));
                    }
                }
                else
                {
                    var registry = new Registry
                    {
                        Sku = new Microsoft.Azure.Management.ContainerRegistry.Models.Sku(Sku),
                        AdminUserEnabled = EnableAdminUser,
                        Tags             = tags,
                        Location         = Location
                    };

                    if (StorageAccountName != null)
                    {
                        var storageAccountId = ResourceManagerClient.GetStorageAccountId(StorageAccountName);
                        registry.StorageAccount = new StorageAccountProperties(storageAccountId);
                    }

                    var createdRegistry = RegistryClient.CreateRegistry(ResourceGroupName, Name, registry);
                    WriteObject(new PSContainerRegistry(createdRegistry));
                }
            }
        }
        public override void ExecuteCmdlet()
        {
            var tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true);

            bool?adminUserEnabled = null;

            if (EnableAdminUser || DisableAdminUser)
            {
                adminUserEnabled = EnableAdminUser || !DisableAdminUser;
            }

            string storageAccountId = null;

            if (StorageAccountName != null)
            {
                storageAccountId = ResourceManagerClient.GetStorageAccountId(StorageAccountName);
            }

            if (MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(ResourceId))
            {
                string resourceGroup, registryName, childResourceName;
                if (!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName))
                {
                    WriteInvalidResourceIdError(InvalidRegistryResourceIdErrorMessage);
                    return;
                }

                ResourceGroupName = resourceGroup;
                Name = registryName;
            }

            if (ShouldProcess(Name, "Update Container Registry"))
            {
                var registry = RegistryClient.UpdateRegistry(ResourceGroupName, Name, adminUserEnabled, Sku, storageAccountId, NetworkRuleSet, tags);
                WriteObject(new PSContainerRegistry(registry));
            }
        }