public override void ExecuteCmdlet()
        {
            if (this.IsParameterBound(c => c.WorkspaceObject))
            {
                this.ResourceGroupName = new ResourceIdentifier(this.WorkspaceObject.Id).ResourceGroupName;
                this.WorkspaceName     = this.WorkspaceObject.Name;
            }

            if (this.IsParameterBound(c => c.InputObject))
            {
                var resourceIdentifier = new ResourceIdentifier(this.InputObject.Id);
                this.ResourceGroupName = resourceIdentifier.ResourceGroupName;
                this.WorkspaceName     = resourceIdentifier.ParentResource;
                this.WorkspaceName     = this.WorkspaceName.Substring(this.WorkspaceName.LastIndexOf('/') + 1);
                this.Name = resourceIdentifier.ResourceName;
            }

            if (this.IsParameterBound(c => c.ResourceId))
            {
                var resourceIdentifier = new ResourceIdentifier(this.ResourceId);
                this.ResourceGroupName = resourceIdentifier.ResourceGroupName;
                this.WorkspaceName     = resourceIdentifier.ParentResource;
                this.WorkspaceName     = this.WorkspaceName.Substring(this.WorkspaceName.LastIndexOf('/') + 1);
                this.Name = resourceIdentifier.ResourceName;
            }

            if (string.IsNullOrEmpty(this.ResourceGroupName))
            {
                this.ResourceGroupName = this.SynapseAnalyticsClient.GetResourceGroupByWorkspaceName(this.WorkspaceName);
            }

            SqlPool existingSqlPool = null;

            try
            {
                existingSqlPool = this.SynapseAnalyticsClient.GetSqlPool(this.ResourceGroupName, this.WorkspaceName, this.Name);
            }
            catch
            {
                existingSqlPool = null;
            }

            if (existingSqlPool == null)
            {
                throw new SynapseException(string.Format(Resources.FailedToDiscoverSqlPool, this.Name, this.ResourceGroupName, this.WorkspaceName));
            }

            if (this.ShouldProcess(this.Name, string.Format(Resources.SuspendingSynapseSqlPool, this.Name, this.ResourceGroupName, this.WorkspaceName)))
            {
                this.SynapseAnalyticsClient.PauseSqlPool(this.ResourceGroupName, this.WorkspaceName, this.Name);
                var result = new PSSynapseSqlPool(this.ResourceGroupName, this.WorkspaceName, this.SynapseAnalyticsClient.GetSqlPool(this.ResourceGroupName, this.WorkspaceName, this.Name));
                WriteObject(result);
            }
        }
예제 #2
0
        public override void ExecuteCmdlet()
        {
            if (this.IsParameterBound(c => c.WorkspaceObject))
            {
                this.ResourceGroupName = new ResourceIdentifier(this.WorkspaceObject.Id).ResourceGroupName;
                this.WorkspaceName     = this.WorkspaceObject.Name;
            }

            if (string.IsNullOrEmpty(this.ResourceGroupName))
            {
                this.ResourceGroupName = this.SynapseAnalyticsClient.GetResourceGroupByWorkspaceName(this.WorkspaceName);
            }

            var existingWorkspace = this.SynapseAnalyticsClient.GetWorkspaceOrDefault(this.ResourceGroupName, this.WorkspaceName);

            if (existingWorkspace == null)
            {
                throw new AzPSResourceNotFoundCloudException(string.Format(Resources.WorkspaceDoesNotExist, this.WorkspaceName));
            }

            var createParams = new SqlPool
            {
                Location = existingWorkspace.Location
            };

            switch (this.ParameterSetName)
            {
            case RestoreFromBackupIdByNameParameterSet:
            case RestoreFromBackupIdByParentObjectParameterSet:
                createParams.CreateMode            = SynapseSqlPoolCreateMode.Recovery;
                createParams.RecoverableDatabaseId = this.ResourceId;
                break;

            case RestoreFromRestorePointIdByNameParameterSet:
            case RestoreFromRestorePointIdByParentObjectParameterSet:
                createParams.CreateMode         = SynapseSqlPoolCreateMode.PointInTimeRestore;
                createParams.SourceDatabaseId   = this.ResourceId;
                createParams.RestorePointInTime = this.RestorePoint.ToUniversalTime().ToString("o");
                createParams.Sku = new Sku
                {
                    Name = this.PerformanceLevel
                };

                break;

            default: throw new AzPSInvalidOperationException(string.Format(Resources.InvalidParameterSet, this.ParameterSetName));
            }

            if (this.ShouldProcess(this.Name, string.Format(Resources.RestoringSynapseSqlPool, this.ResourceId, this.ResourceGroupName, this.WorkspaceName, this.Name)))
            {
                var result = new PSSynapseSqlPool(this.ResourceGroupName, this.WorkspaceName, this.SynapseAnalyticsClient.CreateSqlPool(this.ResourceGroupName, this.WorkspaceName, this.Name, createParams));
                WriteObject(result);
            }
        }
예제 #3
0
        public async Task TestGet()
        {
            SqlPoolsClient        client = CreateClient();
            SqlPoolInfoListResult pools  = await client.ListAsync();

            foreach (SqlPool pool in pools.Value)
            {
                SqlPool actualPool = await client.GetAsync(pool.Name);

                Assert.AreEqual(pool.Id, actualPool.Id);
                Assert.AreEqual(pool.Name, actualPool.Name);
                Assert.AreEqual(pool.Status, actualPool.Status);
            }
        }
예제 #4
0
 public PSSynapseSqlPool(SqlPool sqlPool)
     : base(sqlPool?.Location, sqlPool?.Id, sqlPool?.Name, sqlPool?.Type, sqlPool?.Tags)
 {
     this.Sku                   = sqlPool?.Sku != null ? new PSSynapseSku(sqlPool.Sku) : null;
     this.MaxSizeBytes          = sqlPool?.MaxSizeBytes;
     this.Collation             = sqlPool?.Collation;
     this.SourceDatabaseId      = sqlPool?.SourceDatabaseId;
     this.RecoverableDatabaseId = sqlPool?.RecoverableDatabaseId;
     this.ProvisioningState     = sqlPool?.ProvisioningState;
     this.Status                = sqlPool?.Status;
     this.RestorePointInTime    = sqlPool?.RestorePointInTime;
     this.CreateMode            = sqlPool?.CreateMode;
     this.CreationDate          = sqlPool?.CreationDate;
 }
예제 #5
0
        public PSSynapseSqlPool(string resourceGroupName, string workspaceName, SqlPool sqlPool)
            : base(sqlPool?.Location, sqlPool?.Id, sqlPool?.Name, sqlPool?.Type, sqlPool?.Tags)
        {
            this.ResourceGroupName = resourceGroupName;
            this.WorkspaceName     = workspaceName;
            this.Sku                   = sqlPool?.Sku != null ? new PSSynapseSku(sqlPool.Sku) : null;
            this.MaxSizeBytes          = sqlPool?.MaxSizeBytes;
            this.Collation             = sqlPool?.Collation;
            this.SourceDatabaseId      = sqlPool?.SourceDatabaseId;
            this.RecoverableDatabaseId = sqlPool?.RecoverableDatabaseId;
            this.ProvisioningState     = sqlPool?.ProvisioningState;
            this.Status                = sqlPool?.Status;
            this.CreateMode            = sqlPool?.CreateMode;
            this.CreationDate          = sqlPool?.CreationDate;

            if (sqlPool?.RestorePointInTime != null)
            {
                this.RestorePointInTime = DateTime.Parse(sqlPool.RestorePointInTime);
            }
        }
        private void UpdateSqlPool(SqlPool existingSqlPool)
        {
            SqlPoolPatchInfo sqlPoolPatchInfo = new SqlPoolPatchInfo
            {
                Tags = this.IsParameterBound(c => c.Tag) ? TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true) : existingSqlPool.Tags,
                Sku  = !this.IsParameterBound(c => c.PerformanceLevel) ? existingSqlPool.Sku : new Sku
                {
                    Name = this.PerformanceLevel
                }
            };

            if (this.ShouldProcess(this.Name, string.Format(Resources.UpdatingSynapseSqlPool, this.Name, this.ResourceGroupName, this.WorkspaceName)))
            {
                this.SynapseAnalyticsClient.UpdateSqlPool(this.ResourceGroupName, this.WorkspaceName, this.Name, sqlPoolPatchInfo);
                if (this.PassThru.IsPresent)
                {
                    var result = this.SynapseAnalyticsClient.GetSqlPool(this.ResourceGroupName, this.WorkspaceName, this.Name);
                    WriteObject(result);
                }
            }
        }
예제 #7
0
        public override void ExecuteCmdlet()
        {
            if (this.IsParameterBound(c => c.WorkspaceObject))
            {
                this.ResourceGroupName = new ResourceIdentifier(this.WorkspaceObject.Id).ResourceGroupName;
                this.WorkspaceName     = this.WorkspaceObject.Name;
            }

            if (this.IsParameterBound(c => c.BackupResourceId))
            {
                var resourceIdentifier = new ResourceIdentifier(this.BackupResourceId);
                this.BackupWorkspaceName = resourceIdentifier.ParentResource;
                this.BackupWorkspaceName = this.BackupWorkspaceName.Substring(this.BackupWorkspaceName.LastIndexOf('/') + 1);
                this.BackupSqlPoolName   = resourceIdentifier.ResourceName;
            }

            if (this.IsParameterBound(c => c.BackupSqlPoolObject))
            {
                var resourceIdentifier = new ResourceIdentifier(this.BackupSqlPoolObject.Id);
                this.BackupResourceId    = this.BackupSqlPoolObject.Id;
                this.BackupWorkspaceName = resourceIdentifier.ParentResource;
                this.BackupWorkspaceName = this.BackupWorkspaceName.Substring(this.BackupWorkspaceName.LastIndexOf('/') + 1);
                this.BackupSqlPoolName   = resourceIdentifier.ResourceName;
                this.PerformanceLevel    = this.IsParameterBound(c => c.PerformanceLevel) ? this.PerformanceLevel : this.BackupSqlPoolObject.Sku?.Name;
            }

            if (string.IsNullOrEmpty(this.ResourceGroupName))
            {
                this.ResourceGroupName = this.SynapseAnalyticsClient.GetResourceGroupByWorkspaceName(this.WorkspaceName);
            }

            if (FromBackup.IsPresent || FromRestorePoint.IsPresent)
            {
                // Construct resource id from components.
                if (string.IsNullOrEmpty(this.BackupResourceId))
                {
                    if (string.IsNullOrEmpty(this.BackupResourceGroupName))
                    {
                        this.BackupResourceGroupName = this.SynapseAnalyticsClient.GetResourceGroupByWorkspaceName(this.BackupWorkspaceName);
                    }

                    this.BackupResourceId = ConstructSqlDatabaseResourceId(
                        this.DefaultContext.Subscription.Id,
                        this.BackupResourceGroupName,
                        this.BackupWorkspaceName,
                        this.BackupSqlPoolName,
                        this.FromBackup.IsPresent);
                }
            }

            var existingWorkspace = this.SynapseAnalyticsClient.GetWorkspaceOrDefault(this.ResourceGroupName, this.WorkspaceName);

            if (existingWorkspace == null)
            {
                throw new SynapseException(string.Format(Resources.WorkspaceDoesNotExist, this.WorkspaceName));
            }

            var existingSqlPool = this.SynapseAnalyticsClient.GetSqlPoolOrDefault(this.ResourceGroupName, this.WorkspaceName, this.Name);

            if (existingSqlPool != null)
            {
                throw new SynapseException(string.Format(Resources.SynapseSqlPoolExists, this.Name, this.ResourceGroupName, this.WorkspaceName));
            }

            var createParams = new SqlPool
            {
                Location = existingWorkspace.Location,
                Tags     = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true)
            };

            switch (this.ParameterSetName)
            {
            case RestoreFromBackupNameByNameParameterSet:
            case RestoreFromBackupNameByParentObjectParameterSet:
            case RestoreFromBackupIdByNameParameterSet:
            case RestoreFromBackupIdByParentObjectParameterSet:
            case RestoreFromBackupInputObjectByNameParameterSet:
                createParams.CreateMode            = SynapseSqlPoolCreateMode.Recovery;
                createParams.RecoverableDatabaseId = this.BackupResourceId;
                break;

            case RestoreFromRestorePointNameByNameParameterSet:
            case RestoreFromRestorePointNameByParentObjectParameterSet:
            case RestoreFromRestorePointIdByNameParameterSet:
            case RestoreFromRestorePointIdByParentObjectParameterSet:
            case RestoreFromRestorePointInputObjectByNameParameterSet:
                if (!this.IsParameterBound(c => c.RestorePoint))
                {
                    this.RestorePoint = GetNewestRestorePoint();
                }

                createParams.CreateMode         = SynapseSqlPoolCreateMode.PointInTimeRestore;
                createParams.SourceDatabaseId   = this.SourceResourceId;
                createParams.RestorePointInTime = this.RestorePoint.ToString();
                createParams.Sku = new Sku
                {
                    Name = this.PerformanceLevel
                };

                break;

            default: throw new SynapseException(string.Format(Resources.InvalidParameterSet, this.ParameterSetName));
            }

            if (this.ShouldProcess(this.Name, string.Format(Resources.RestoringSynapseSqlPool, this.BackupSqlPoolName, this.ResourceGroupName, this.WorkspaceName, this.Name)))
            {
                var result = new PSSynapseSqlPool(this.ResourceGroupName, this.WorkspaceName, this.SynapseAnalyticsClient.CreateSqlPool(this.ResourceGroupName, this.WorkspaceName, this.Name, createParams));
                WriteObject(result);
            }
        }
 /// <summary>
 /// Create SQL pool
 /// </summary>
 /// <remarks>
 /// Create a SQL pool
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group. The name is case insensitive.
 /// </param>
 /// <param name='workspaceName'>
 /// The name of the workspace
 /// </param>
 /// <param name='sqlPoolName'>
 /// SQL pool name
 /// </param>
 /// <param name='sqlPoolInfo'>
 /// The SQL pool to create
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <SqlPool> BeginCreateAsync(this ISqlPoolsOperations operations, string resourceGroupName, string workspaceName, string sqlPoolName, SqlPool sqlPoolInfo, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, workspaceName, sqlPoolName, sqlPoolInfo, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Create SQL pool
 /// </summary>
 /// <remarks>
 /// Create a SQL pool
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group. The name is case insensitive.
 /// </param>
 /// <param name='workspaceName'>
 /// The name of the workspace
 /// </param>
 /// <param name='sqlPoolName'>
 /// SQL pool name
 /// </param>
 /// <param name='sqlPoolInfo'>
 /// The SQL pool to create
 /// </param>
 public static SqlPool BeginCreate(this ISqlPoolsOperations operations, string resourceGroupName, string workspaceName, string sqlPoolName, SqlPool sqlPoolInfo)
 {
     return(operations.BeginCreateAsync(resourceGroupName, workspaceName, sqlPoolName, sqlPoolInfo).GetAwaiter().GetResult());
 }
        public override void ExecuteCmdlet()
        {
            if (this.IsParameterBound(c => c.WorkspaceObject))
            {
                this.ResourceGroupName = new ResourceIdentifier(this.WorkspaceObject.Id).ResourceGroupName;
                this.WorkspaceName     = this.WorkspaceObject.Name;
            }

            if (this.IsParameterBound(c => c.InputObject))
            {
                var resourceIdentifier = new ResourceIdentifier(this.InputObject.Id);
                this.ResourceGroupName = resourceIdentifier.ResourceGroupName;
                this.WorkspaceName     = resourceIdentifier.ParentResource;
                this.WorkspaceName     = this.WorkspaceName.Substring(this.WorkspaceName.LastIndexOf('/') + 1);
                this.Name = resourceIdentifier.ResourceName;
            }

            if (this.IsParameterBound(c => c.ResourceId))
            {
                var resourceIdentifier = new ResourceIdentifier(this.ResourceId);
                this.ResourceGroupName = resourceIdentifier.ResourceGroupName;
                this.WorkspaceName     = resourceIdentifier.ParentResource;
                this.WorkspaceName     = this.WorkspaceName.Substring(this.WorkspaceName.LastIndexOf('/') + 1);
                this.Name = resourceIdentifier.ResourceName;
            }

            if (string.IsNullOrEmpty(this.ResourceGroupName))
            {
                this.ResourceGroupName = this.SynapseAnalyticsClient.GetResourceGroupByWorkspaceName(this.WorkspaceName);
            }

            if (this.Version == 3)
            {
                SqlPoolV3 existingSqlPool = null;
                try
                {
                    existingSqlPool = this.SynapseAnalyticsClient.GetSqlPoolV3(this.ResourceGroupName, this.WorkspaceName, this.Name);
                }
                catch
                {
                    existingSqlPool = null;
                }

                if (existingSqlPool == null)
                {
                    throw new SynapseException(string.Format(Resources.FailedToDiscoverSqlPool, this.Name, this.ResourceGroupName, this.WorkspaceName));
                }

                switch (this.ParameterSetName)
                {
                case UpdateByNameParameterSet:
                case UpdateByInputObjectParameterSet:
                case UpdateByParentObjectParameterSet:
                case UpdateByResourceIdParameterSet:
                    UpdateSqlPoolV3(existingSqlPool);
                    break;

                default: throw new SynapseException(string.Format(Resources.InvalidParameterSet, this.ParameterSetName));
                }
            }
            else
            {
                SqlPool existingSqlPool = null;
                try
                {
                    existingSqlPool = this.SynapseAnalyticsClient.GetSqlPool(this.ResourceGroupName, this.WorkspaceName, this.Name);
                }
                catch
                {
                    existingSqlPool = null;
                }

                if (existingSqlPool == null)
                {
                    throw new SynapseException(string.Format(Resources.FailedToDiscoverSqlPool, this.Name, this.ResourceGroupName, this.WorkspaceName));
                }

                switch (this.ParameterSetName)
                {
                case UpdateByNameParameterSet:
                case UpdateByInputObjectParameterSet:
                case UpdateByParentObjectParameterSet:
                case UpdateByResourceIdParameterSet:
                    UpdateSqlPool(existingSqlPool);
                    break;

                case RenameByNameParameterSet:
                case RenameByInputObjectParameterSet:
                case RenameByParentObjectParameterSet:
                case RenameByResourceIdParameterSet:
                    RenameSqlPool();
                    break;

                default: throw new SynapseException(string.Format(Resources.InvalidParameterSet, this.ParameterSetName));
                }
            }
        }
예제 #11
0
 public SqlPool CreateSqlPool(string resourceGroupName, string workspaceName, string sqlPoolName, SqlPool createOrUpdateParams)
 {
     try
     {
         return(_synapseManagementClient.SqlPools.Create(resourceGroupName, workspaceName, sqlPoolName, createOrUpdateParams));
     }
     catch (CloudException ex)
     {
         throw GetSynapseException(ex);
     }
 }
예제 #12
0
    public MyStack()
    {
        var config   = new Pulumi.Config();
        var location = config.Get("location") ?? "WestUS";

        var resourceGroup = new ResourceGroup("synapse-rg");

        var storageAccount = new StorageAccount("synapsesa", new StorageAccountArgs
        {
            ResourceGroupName      = resourceGroup.Name,
            AccessTier             = AccessTier.Hot,
            EnableHttpsTrafficOnly = true,
            IsHnsEnabled           = true,
            Kind = "StorageV2",
            Sku  = new SkuArgs
            {
                Name = "Standard_RAGRS"
            },
        });
        var dataLakeStorageAccountUrl = Output.Format($"https://{storageAccount.Name}.dfs.core.windows.net");

        var users = new BlobContainer("users", new BlobContainerArgs
        {
            ResourceGroupName = resourceGroup.Name,
            AccountName       = storageAccount.Name,
            PublicAccess      = PublicAccess.None
        });

        var workspacePwd = new RandomPassword("workspace-pwd", new RandomPasswordArgs
        {
            Length = 12,
        });

        var workspace = new Workspace("workspace", new WorkspaceArgs
        {
            ResourceGroupName      = resourceGroup.Name,
            DefaultDataLakeStorage = new DataLakeStorageAccountDetailsArgs
            {
                AccountUrl = dataLakeStorageAccountUrl,
                Filesystem = "users"
            },
            Identity = new ManagedIdentityArgs
            {
                Type = ResourceIdentityType.SystemAssigned
            },
            SqlAdministratorLogin         = "******",
            SqlAdministratorLoginPassword = workspacePwd.Result
        });

        var allowAll = new IpFirewallRule("allowAll", new IpFirewallRuleArgs
        {
            ResourceGroupName = resourceGroup.Name,
            WorkspaceName     = workspace.Name,
            EndIpAddress      = "255.255.255.255",
            StartIpAddress    = "0.0.0.0"
        });

        var subscriptionId   = resourceGroup.Id.Apply(id => id.Split('/')[2]);
        var roleDefinitionId = $"/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/ba92f5b4-2d11-453d-a403-e96b0029c9fe";

        var storageAccess = new RoleAssignment("storageAccess", new RoleAssignmentArgs
        {
            RoleAssignmentName = new RandomUuid("roleName").Result,
            Scope            = storageAccount.Id,
            PrincipalId      = workspace.Identity.Apply(identity => identity.PrincipalId).Apply(v => v ?? "<preview>"),
            PrincipalType    = "ServicePrincipal",
            RoleDefinitionId = roleDefinitionId
        });
        var clientConfig = Output.Create(GetClientConfig.InvokeAsync());
        var userAccess   = new RoleAssignment("userAccess", new RoleAssignmentArgs
        {
            RoleAssignmentName = new RandomUuid("userRoleName").Result,
            Scope            = storageAccount.Id,
            PrincipalId      = clientConfig.Apply(v => v.ObjectId),
            PrincipalType    = "User",
            RoleDefinitionId = roleDefinitionId
        });

        var sqlPool = new SqlPool("SQLPOOL1", new SqlPoolArgs
        {
            ResourceGroupName = resourceGroup.Name,
            WorkspaceName     = workspace.Name,
            Collation         = "SQL_Latin1_General_CP1_CI_AS",
            CreateMode        = "Default",
            Sku = new Pulumi.AzureNative.Synapse.Inputs.SkuArgs
            {
                Name = "DW100c"
            },
        });

        var sparkPool = new BigDataPool("Spark1", new BigDataPoolArgs
        {
            ResourceGroupName = resourceGroup.Name,
            WorkspaceName     = workspace.Name,
            AutoPause         = new AutoPausePropertiesArgs
            {
                DelayInMinutes = 15,
                Enabled        = true,
            },
            AutoScale = new AutoScalePropertiesArgs
            {
                Enabled      = true,
                MaxNodeCount = 3,
                MinNodeCount = 3,
            },
            NodeCount      = 3,
            NodeSize       = "Small",
            NodeSizeFamily = "MemoryOptimized",
            SparkVersion   = "2.4"
        });
    }
        public override void ExecuteCmdlet()
        {
            if (this.IsParameterBound(c => c.WorkspaceObject))
            {
                this.ResourceGroupName = new ResourceIdentifier(this.WorkspaceObject.Id).ResourceGroupName;
                this.WorkspaceName     = this.WorkspaceObject.Name;
            }

            if (string.IsNullOrEmpty(this.ResourceGroupName))
            {
                this.ResourceGroupName = this.SynapseAnalyticsClient.GetResourceGroupByWorkspaceName(this.WorkspaceName);
            }

            var existingWorkspace = this.SynapseAnalyticsClient.GetWorkspaceOrDefault(this.ResourceGroupName, this.WorkspaceName);

            if (existingWorkspace == null)
            {
                throw new AzPSResourceNotFoundCloudException(string.Format(Resources.WorkspaceDoesNotExist, this.WorkspaceName));
            }

            if (this.Version == 3)
            {
                var existingSqlPool = this.SynapseAnalyticsClient.GetSqlPoolV3OrDefault(this.ResourceGroupName, this.WorkspaceName, this.Name);
                if (existingSqlPool != null)
                {
                    throw new AzPSInvalidOperationException(string.Format(Resources.SynapseSqlPoolExists, this.Name, this.ResourceGroupName, this.WorkspaceName));
                }

                var createParams = new SqlPoolV3
                {
                    Location = existingWorkspace.Location,
                    Tags     = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true)
                };

                switch (this.ParameterSetName)
                {
                case CreateByNameParameterSet:
                case CreateByParentObjectParameterSet:
                    createParams.Sku = new SkuV3
                    {
                        Name = this.PerformanceLevel
                    };
                    break;

                default: throw new AzPSInvalidOperationException(string.Format(Resources.InvalidParameterSet, this.ParameterSetName));
                }

                if (this.ShouldProcess(this.Name, string.Format(Resources.CreatingSynapseSqlPool, this.ResourceGroupName, this.WorkspaceName, this.Name)))
                {
                    var result = new PSSynapseSqlPoolV3(this.SynapseAnalyticsClient.CreateSqlPoolV3(this.ResourceGroupName, this.WorkspaceName, this.Name, createParams));
                    WriteObject(result);
                }
            }
            else
            {
                var existingSqlPool = this.SynapseAnalyticsClient.GetSqlPoolOrDefault(this.ResourceGroupName, this.WorkspaceName, this.Name);
                if (existingSqlPool != null)
                {
                    throw new AzPSInvalidOperationException(string.Format(Resources.SynapseSqlPoolExists, this.Name, this.ResourceGroupName, this.WorkspaceName));
                }

                var createParams = new SqlPool
                {
                    Location = existingWorkspace.Location,
                    Tags     = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true)
                };

                createParams.CreateMode = SynapseSqlPoolCreateMode.Default;
                createParams.Collation  = this.IsParameterBound(c => c.Collation) ? this.Collation : SynapseConstants.DefaultCollation;
                createParams.Sku        = new Sku
                {
                    Name = this.PerformanceLevel
                };

                if (this.ShouldProcess(this.Name, string.Format(Resources.CreatingSynapseSqlPool, this.ResourceGroupName, this.WorkspaceName, this.Name)))
                {
                    var result = new PSSynapseSqlPool(this.ResourceGroupName, this.WorkspaceName, this.SynapseAnalyticsClient.CreateSqlPool(this.ResourceGroupName, this.WorkspaceName, this.Name, createParams));
                    WriteObject(result);
                }
            }
        }
예제 #14
0
 public void OnPool(ulong pool, string sid, uint state, uint waitCount, uint totalObjects)
 {
     _currPool = new SqlPool(pool, sid, state, waitCount, totalObjects);
     _currGroup.Pools.Add(_currPool);
 }