Exemple #1
0
        ///GENMHASH:C11535A65C2F85653353000F3BCCBABE:BA3E680F4190F2624FB5865D26163516
        public SqlFirewallRuleImpl DefineFirewallRule(string name)
        {
            var firewallRule = new SqlFirewallRuleImpl(name, this, new FirewallRuleInner(), this.Manager);

            this.sqlFirewallRulesToCreateOrUpdate.Add(firewallRule);
            return(firewallRule);
        }
Exemple #2
0
        ///GENMHASH:69FD06084D43219AA18CD7D3D99C1279:7D1773A8567ECFFC0A4621517C19EF47
        public SqlServerImpl WithNewFirewallRule(string startIPAddress, string endIPAddress, string firewallRuleName)
        {
            var sqlFirewallRule = new SqlFirewallRuleImpl(firewallRuleName, this, new FirewallRuleInner(), this.Manager);

            sqlFirewallRule.WithStartIPAddress(startIPAddress);
            sqlFirewallRule.WithEndIPAddress(endIPAddress);
            this.sqlFirewallRulesToCreateOrUpdate.Add(sqlFirewallRule);

            return(this);
        }
Exemple #3
0
        ///GENMHASH:9557699E7EE892CCCC89A074E0915333:FA4A38A563B9469CAA6DFA06B860491B
        public async Task BeforeGroupCreateOrUpdateAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            if (this.IsInCreateMode)
            {
                if (allowAzureServicesAccess)
                {
                    var sqlFirewallRule = new SqlFirewallRuleImpl("AllowAllWindowsAzureIps", this, new FirewallRuleInner(), this.Manager);
                    sqlFirewallRule.WithStartIPAddress("0.0.0.0");
                    sqlFirewallRule.WithEndIPAddress("0.0.0.0");
                    this.sqlFirewallRulesToCreateOrUpdate.Add(sqlFirewallRule);
                }
            }
            // validate the new/updated elastic pool items are not in the delete list
            // elastic pools will be deleted in the AfterPostRunAsync() since they depend on databases being deleted first
            foreach (var epName in this.sqlElasticPoolsToDelete)
            {
                foreach (var epItem in this.sqlElasticPoolsToCreateOrUpdate)
                {
                    if (epItem.Name() == epName)
                    {
                        throw new InvalidOperationException($"{epName} is created and removed in the same operation");
                    }
                }
            }

            // populate the "delete" worker and validate the new/updated items are not in the delete list
            var deleteWorkers = this.sqlDatabasesToDelete.Select(async dbName =>
            {
                if (this.sqlDatabasesToCreateOrUpdate.Any(dbItem => dbItem.Name().Equals(dbName, StringComparison.OrdinalIgnoreCase)) ||
                    this.sqlDatabasesWithElasticPoolToCreateOrUpdate.Any(dbItem => dbItem.Name().Equals(dbName, StringComparison.OrdinalIgnoreCase)))
                {
                    throw new InvalidOperationException($"{dbName} is created and removed in the same operation");
                }
                await this.Manager.Inner.Databases.DeleteAsync(this.ResourceGroupName, this.Name, dbName, cancellationToken);
            })
                                .Union(this.sqlFirewallRulesToDelete.Select(async firewallRuleName =>
            {
                if (this.sqlFirewallRulesToCreateOrUpdate.Any(firewallRuleItem => firewallRuleItem.Name().Equals(firewallRuleName, StringComparison.OrdinalIgnoreCase)))
                {
                    throw new InvalidOperationException($"{firewallRuleName} is created and removed in the same operation");
                }
                await this.Manager.Inner.FirewallRules.DeleteAsync(this.ResourceGroupName, this.Name, firewallRuleName, cancellationToken);
            }));
            await Task.WhenAll(deleteWorkers);
        }
        ///GENMHASH:8ACFB0E23F5F24AD384313679B65F404:307943992410821E8848C28E10217FEC
        public SqlFirewallRuleImpl Define(string name)
        {
            SqlFirewallRuleImpl result = new SqlFirewallRuleImpl(name, new Models.FirewallRuleInner(), this.sqlServerManager);

            return((this.sqlServer != null) ? result.WithExistingSqlServer(this.sqlServer) : result);
        }