Skip to content

Commit

Permalink
Updated and refactored for newest System.Commandline version (#112)
Browse files Browse the repository at this point in the history
- *FIXED:* Update to ensure all Queue messages are retrieved efficiently
- *ADDED:* New utility method `sbm batch dequeue` to remove all messages from the Service Bus Queue topic (without processing them)
- *UPDATED:* Code clean up and refactoring to accommodate latest version of System.CommandLine
- *FIXED:* Issue with SQL text syntax higlighting formatting in .NET 5.0
- **NOTE:** Removed "Construct Command Line" menu options from Windows UI. Users should leverage the generated help docs for sbm.exe
  • Loading branch information
mmckechney authored May 15, 2021
1 parent ac2be13 commit 0738839
Show file tree
Hide file tree
Showing 56 changed files with 1,393 additions and 3,063 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ SQL Build Manager is a multi-faceted tool to allow you to manage the life-cycle
- [Leverage Azure Batch for massively parallel updates](/docs/azure_batch.md)
- [Change notes](docs/change_notes.md)
- For contributors: [Notes on Building and Unit Testing](/docs/setup_azure_environment.md)
- For users of the Windows Form app: [SQL Build Manager Manual](docs/SqlBuildManagerManual.md)\
(Note: this isn't 100% up to date, so the screen shots may vary from the current app)

----

Expand Down
54 changes: 13 additions & 41 deletions docs/SqlBuildManagerManual.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Michael McKechney
([[email protected]](mailto:[email protected])) \
[www.SqlBuildManager.com](https://mmckechney.github.io/SqlBuildManager/) \
Copyright 2004-2020
Copyright 2004-2021

------

Expand Down Expand Up @@ -637,28 +637,27 @@ Basic Command Line Execution
## Command Line Arguments 

Sql Build Manager can be run directly via command line or through the
SqlBuildManager.Console.exe helper application. The advantage of using
`sbm` application. The advantage of using
the "console" application is that you will be able to record exit code
values as well as stream the standard output and error text into any
automation or scheduling software that you may be using.

The command line also has the ability to run on Linux and/or run massively parallel updates leveraging Azure Batch

### For command line details go [here](commandline.md)

## Command Line Examples

## Command Line Examples 
**Run standard unattended Sql build**

**Run standard unattended Sql build****\
**Runs the specified .sbm build file on the designated server using the
Runs the specified .sbm build file on the designated server using the
parameters and target databases defined in the project. The command line
execution uses Windows authentication of the executing process to
connect to the server and database(s). As with in interactive execution,
the results are saved in the .sbm file for review.

- SqlBuildManager.Console.exe /Action=Build /PackageName=".sbm file name"
/server=myserver 

```
SqlBuildManager.Console.exe /Action=Build /PackageName="ProjectUpdate.sbm" /server=ProdServer 
``` bash
sbm build --packagename "ProjectUpdate.sbm" --server ProdServer 
```

**Run an unattended Sql build with manual database override
Expand All @@ -670,11 +669,8 @@ The command line execution uses Windows authentication of the executing
process to connect to the server and database(s). As with in interactive
execution, the results are saved in the .sbm file for review.

- SqlBuildManager.Console.exe /Action=Build /PackageName=".sbm file name" /server=server
/override=default,override

```
SqlBuildManager.Console.exe /Action=Build /PackageName="ProjectUpdate.sbm" /server=ProdServer /override=Main,Copy1
``` bash
sbm build --packagename "ProjectUpdate.sbm" --server ProdServer  --override "Main,Copy1"
```

Note that multiple overrides may be set if the build file contains more
Expand All @@ -688,13 +684,10 @@ authentication of the executing process to connect to the server and
database(s). As with in interactive execution, the results are saved in
the .sbm file for review.

```
SqlBuildManager.Console.exe /Action=Build /PackageName="ProjectUpdate.sbm" /override="prod release.multiDb"
``` bash
sbm build --packagename "ProjectUpdate.sbm" --override "prod release.multiDb"
```

See [Advanced Command Line Execution](#Advanced-Command-Line-Execution) for
return codes.

Targeting Multiple Servers and Databases
========================================

Expand Down Expand Up @@ -815,9 +808,6 @@ configuration file. You will then be prompted to save the query as a
generated configuration setting will be loaded in the Multiple Database
Run Configuration window.


-

Threaded Multi-Server Database Execution
----------------------------------------

Expand Down Expand Up @@ -859,24 +849,6 @@ For each database you want to execute against, add an additional line in
the configuration file (i.e. each line equates to an additional thread).
Finally, save the file with a .cfg extension

See [Advanced Command Line Execution](#AdvancedCommandLineExecution) for
the command line syntax to execute your threaded builds.

Remote Service Execution and Deployment
=======================================

While the tool has the feature for [Targeting Multiple Servers and
Databases](#TargetingMultipleServersandDatabases), you can take that
multi-target, multi-threaded execution one step further and distribute
that load across multiple -->Execution Servers--> as well. It builds on the
multiple server functionality and extends it to send build requests via
a remote service call to remote computers that will handle the actual
processing of the SQL scripts. You can spit the load amongst all of your
execution servers for maximum efficiency and minimum deployment time.

Overview
--------

Advanced Script Handling
========================

Expand Down
8 changes: 8 additions & 0 deletions docs/change_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
# SQL Build Manager Change Notes


### Version 13.0.2

- *FIXED:* Update to ensure all Queue messages are retrieved efficiently
- *ADDED:* New utility method `sbm batch dequeue` to remove all messages from the Service Bus Queue topic (without processing them)
- *UPDATED:* Code clean up and refactoring to accommodate latest version of System.CommandLine
- *FIXED:* Issue with SQL text syntax higlighting formatting in .NET 5.0
- **NOTE:** Removed "Construct Command Line" menu options from Windows UI. Users should leverage the generated help docs for sbm.exe

### Version 13.0.1

- *FIXED:* Updated distribution algorithm for `--concurrencytype` of `Server` and `MaxPerServer` when number of Batch nodes is very close to the number of SQL Server targets. Was yielding less than the number of nodes.
Expand Down
202 changes: 202 additions & 0 deletions docs/templates/azuredeploy.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
@description('Prefix to prepend to account names')
param namePrefix string
@allowed([
'Basic'
'Standard'
])
@description('The messaging tier for service Bus namespace')
param eventhubSku string = 'Standard'

@allowed([
1
2
4
])
@description('MessagingUnits for premium namespace')
param skuCapacity int = 1

@description('Location for all resources.')
param location string = resourceGroup().location

var batchAccountName_var = '${namePrefix}batchacct'
var storageAccountName_var = '${namePrefix}storage'
var namespaceName_var = '${namePrefix}eventhubnamespace'
var eventHubName = '${namePrefix}eventhub'
var serviceBusName_var = '${namePrefix}servicebus'


resource storageAccountName 'Microsoft.Storage/storageAccounts@2018-07-01' = {
name: storageAccountName_var
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
properties: {
networkAcls: {
bypass: 'AzureServices'
virtualNetworkRules: []
ipRules: []
defaultAction: 'Allow'
}
supportsHttpsTrafficOnly: false
encryption: {
services: {
file: {
enabled: true
}
blob: {
enabled: true
}
}
keySource: 'Microsoft.Storage'
}
accessTier: 'Hot'
}
}

resource batchAccountName 'Microsoft.Batch/batchAccounts@2017-09-01' = {
name: batchAccountName_var
location: location
properties: {
autoStorage: {
storageAccountId: storageAccountName.id
}
poolAllocationMode: 'BatchService'
}
dependsOn:[
storageAccountName
]
}

resource eventHubNamespace 'Microsoft.EventHub/namespaces@2017-04-01' = {
name: namespaceName_var
location: location
sku: {
name: eventhubSku
tier: eventhubSku
capacity: skuCapacity
}
}

resource eventHubNamespace_eventHubName 'Microsoft.EventHub/namespaces/eventhubs@2017-04-01' = {
name: '${eventHubNamespace.name}/${eventHubName}'
properties: {
messageRetentionInDays: 1
partitionCount: 5
status: 'Active'
}
dependsOn: [
eventHubNamespace
]
}

resource namespaceName_eventHubName_batchbuilder 'Microsoft.EventHub/namespaces/eventhubs/authorizationRules@2017-04-01' = {
name: '${eventHubNamespace_eventHubName.name}/batchbuilder'

properties: {
rights: [
'Listen'
'Send'
]
}
dependsOn: [
eventHubNamespace
]
}

resource serviceBusName 'Microsoft.ServiceBus/namespaces@2018-01-01-preview' = {
name: serviceBusName_var
location: location
sku: {
name: 'Standard'
tier: 'Standard'
capacity: 1
}
properties: {
zoneRedundant: false
}
}

resource serviceBusName_RootManageSharedAccessKey 'Microsoft.ServiceBus/namespaces/AuthorizationRules@2017-04-01' = {
name: '${serviceBusName.name}/RootManageSharedAccessKey'
properties: {
rights: [
'Listen'
'Manage'
'Send'
]
}
dependsOn: [
serviceBusName
]
}

resource serviceBusName_sqlbuildmanager 'Microsoft.ServiceBus/namespaces/topics@2018-01-01-preview' = {
name: '${serviceBusName.name}/sqlbuildmanager'
properties: {
defaultMessageTimeToLive: 'P14D'
maxSizeInMegabytes: 4096
requiresDuplicateDetection: false
duplicateDetectionHistoryTimeWindow: 'PT10M'
enableBatchedOperations: true
status: 'Active'
supportOrdering: true
autoDeleteOnIdle: 'P10675199DT2H48M5.4775807S'
enablePartitioning: true
enableExpress: false
}
dependsOn: [
serviceBusName
]
}

resource serviceBusName_sqlbuildmanager_sbmtopicpolicy 'Microsoft.ServiceBus/namespaces/topics/authorizationRules@2018-01-01-preview' = {
name: '${serviceBusName_sqlbuildmanager.name}/sbmtopicpolicy'
properties: {
rights: [
'Manage'
'Listen'
'Send'
]
}
dependsOn: [
serviceBusName
]
}

resource serviceBusName_sqlbuildmanager_sbmsubscription 'Microsoft.ServiceBus/namespaces/topics/subscriptions@2018-01-01-preview' = {
name: '${serviceBusName_sqlbuildmanager.name}/sbmsubscription'
properties: {
lockDuration: 'PT30S'
requiresSession: false
defaultMessageTimeToLive: 'P14D'
deadLetteringOnMessageExpiration: true
deadLetteringOnFilterEvaluationExceptions: true
maxDeliveryCount: 10
status: 'Active'
enableBatchedOperations: true
autoDeleteOnIdle: 'P14D'
}
dependsOn: [
serviceBusName
]
}

resource serviceBusName_sqlbuildmanager_sbmsubscriptionsession 'Microsoft.ServiceBus/namespaces/topics/subscriptions@2018-01-01-preview' = {
name: '${serviceBusName_sqlbuildmanager.name}/sbmsubscriptionsession'
properties: {
lockDuration: 'PT30S'
requiresSession: true
defaultMessageTimeToLive: 'P14D'
deadLetteringOnMessageExpiration: true
deadLetteringOnFilterEvaluationExceptions: true
maxDeliveryCount: 10
status: 'Active'
enableBatchedOperations: true
autoDeleteOnIdle: 'P14D'
}
dependsOn: [
serviceBusName
]
}
4 changes: 2 additions & 2 deletions src/AssemblyVersioning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// These can be found in SqlBuildManager.Setup -> Organize Your Setup -> General Information
// ** Also, don't forget to update the change_notes.xml and .html files!

[assembly: AssemblyVersion("13.0.1")]
[assembly: AssemblyFileVersion("13.0.1")]
[assembly: AssemblyVersion("13.0.2")]
[assembly: AssemblyFileVersion("13.0.2")]


Loading

0 comments on commit 0738839

Please sign in to comment.