コード例 #1
0
        /// <summary>
        /// Call to the shard set driver when an existing shard is being synchronized.
        /// </summary>
        /// <param name="shard">The shard.</param>
        /// <param name="shardSetConfig">The shard set configuration.</param>
        public void SyncShard(ShardBase shard, ShardSetConfig shardSetConfig)
        {
            // get the settings for dac pac publishing from the shard set setting
            // use the sync settings

            // Retrieve storage account from connection string.
            var connectionString = ConfigurationManager.ConnectionStrings["AzureStorage"];

            if (connectionString == null)
            {
                throw new InvalidOperationException("Connection string to azure storage is required in your app.config");
            }

            var dacPacBlobName            = shardSetConfig.GetShardSetSetting(_dacPacBlobNameKey);
            var dacPacSyncProfileBlobName = shardSetConfig.GetShardSetSetting(_dacPacSyncProfileBlobNameKey);
            var dacPacShouldDeployOnSync  = shardSetConfig.GetShardSetSetting(_dacPacShouldDeployOnSyncKey);

            var dacPacsPath = DownloadDacpacsFromBlobStore(connectionString, shardSetConfig.ShardSetName);

            var isNewDb = dacPacShouldDeployOnSync.ToLower() == "true" &&
                          PublishDacPac(shard, shardSetConfig, dacPacsPath + @"\" + dacPacBlobName,
                                        dacPacsPath + @"\" + dacPacSyncProfileBlobName);

            UpdateReferenceData(shard, isNewDb);
        }
コード例 #2
0
        /// <summary>
        /// Call to the shard set driver when a shard is to be first created..
        /// </summary>
        /// <param name="shard">The shard.</param>
        /// <param name="shardSetConfig">The shard set configuration.</param>
        public void CreateShard(ShardBase shard, ShardSetConfig shardSetConfig)
        {
            // Retrieve storage account from connection string.
            var connectionString = ConfigurationManager.ConnectionStrings["AzureStorage"];

            if (connectionString == null)
            {
                throw new InvalidOperationException("Connection string to azure storage is required in your app.config");
            }

            var dacPacBlobName = shardSetConfig.GetShardSetSetting(_dacPacBlobNameKey);
            var dacPacDeployProfileBlobName = shardSetConfig.GetShardSetSetting(_dacPacProfileBlobNameKey);

            var dacPacsPath = DownloadDacpacsFromBlobStore(connectionString, shardSetConfig.ShardSetName);

            var isNewDb = PublishDacPac(shard, shardSetConfig, dacPacsPath + @"\" + dacPacBlobName,
                                        dacPacsPath + @"\" + dacPacDeployProfileBlobName);

            UpdateReferenceData(shard, isNewDb);
        }