Last active
December 26, 2017 19:22
-
-
Save cerealskill/fb288d848fe46abcd0ba53cfefc2a8f0 to your computer and use it in GitHub Desktop.
PowerShell Execute Procedure on webjobs in WebApps (Azure)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Write-Output "JOB START" | |
| # Create connection to Master DB | |
| $MasterDatabaseConnection = New-Object System.Data.SqlClient.SqlConnection | |
| $MasterDatabaseConnection.ConnectionString = "Data Source=_DBNAME_.database.windows.net;Initial Catalog=_DBCATALOG_;Integrated Security=False;User ID=_USERDB_;Password=_PASSDB_;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False" | |
| $MasterDatabaseConnection.Open() | |
| Write-Output "CONNECTION OPEN" | |
| # Create command | |
| $MasterDatabaseCommand = New-Object System.Data.SqlClient.SqlCommand | |
| $MasterDatabaseCommand.Connection = $MasterDatabaseConnection | |
| $MasterDatabaseCommand.CommandText = "_NAME_PROCEDURE_TO_EXECUTE_" | |
| Write-Output "DATABASE COMMAND TEXT ASSIGNED" | |
| # Execute the query | |
| $MasterDatabaseCommand.ExecuteNonQuery() | |
| Write-Output "EXECUTING QUERY" | |
| # Close connection to Master DB | |
| $MasterDatabaseConnection.Close() | |
| Write-Output "CONNECTION CLOSED" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment