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));
                }
            }
        }
예제 #4
0
 public override void ExecuteCmdlet()
 {
     WriteObject(RegistryClient.CheckRegistryNameAvailability(Name));
 }