Skip to content

Instantly share code, notes, and snippets.

View ArthurSteijn's full-sized avatar

Arthur Stejin ArthurSteijn

  • HSO
  • Rotterdam, the Netherlands
  • 12:46 (UTC +02:00)
View GitHub Profile
WEBHOOK_URL = "your_teams_webhook_url"
@send_error_to_teams_decorator(WEBHOOK_URL)
def my_function():
try:
raise Exception("This try block always fails!")
except Exception as e:
raise ValueError(f"ValueError: {str(e)}")
my_function()
import requests
def send_error_to_teams(error_message, webhook_url):
""" This function will use the requests library to make a POST request to the webhook URL with the error message as the payload """
payload = {
"text": error_message
}
response = requests.post(webhook_url, json=payload)
response.raise_for_status()
import pyodbc
import struct
def use_token(server_name, access_token):
connection_string = 'Driver={ODBC Driver 17 for SQL Server};server='+server_name+';database=master;'
SQL_COPT_SS_ACCESS_TOKEN = 1256
exptoken = b''
for i in bytes(access_token, "UTF-8"):
exptoken += bytes({i})
# Azure PowerShell
# https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-powershell?view=azure-devops
# Run a PowerShell script within an Azure environment
- task: AzurePowerShell@5
inputs:
azureSubscription: <YourServiceConnection> # Required. Name of Azure Resource Manager service connection
scriptType: 'inlineScript' # Optional. Options: filePath, inlineScript
#scriptPath: # Optional
inline: | # '# You can write your Azure PowerShell scripts inline here. # You can also pass predefined and custom variables to this script using arguments' # Optional
# Import needed modules
# Azure PowerShell
# https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-powershell?view=azure-devops
# Run a PowerShell script within an Azure environment
- task: AzurePowerShell@5
inputs:
azureSubscription: <YourServiceConnection> # Required. Name of Azure Resource Manager service connection
scriptType: 'inlineScript' # Optional. Options: filePath, inlineScript
#scriptPath: # Optional
inline: | # '# You can write your Azure PowerShell scripts inline here. # You can also pass predefined and custom variables to this script using arguments' # Optional
# Import needed modules
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "UpdatedEventExists",
"type": "boolean",
@ArthurSteijn
ArthurSteijn / prodenv-example.yml
Last active July 24, 2021 11:43
yaml deployment job environment included
- stage: deploy
jobs:
- deployment: DeploySyn
displayName: deploy Synapse Workspace
pool:
vmImage: 'Windows-latest'
# creates an environment if it doesn't exist
environment: 'production'
strategy:
runOnce:
# This PowerShell script triggers and monitors an Azure data factory pipeline outcome.
[CmdletBinding()]
param(
$resourceGroupName,
$dataFactoryName,
$DFPipelineName
)
$RunId = Invoke-AzDataFactoryV2Pipeline `
-DataFactoryName $DataFactoryName `
- task: AzurePowerShell@5
name: filepathPowershelltask
inputs:
azureSubscription: ${{parameters.azureSubscription}}
ScriptType: 'FilePath'
ScriptPath: ${{parameters.scriptFilePath}}
ScriptArguments: ${{parameters.scriptArguments}}
azurePowerShellVersion: 'LatestVersion'
-- Create a database master key if one does not already exist, using your own password. This key is used to encrypt the credential secret in next step.
CREATE MASTER KEY ENCRYPTION BY PASSWORD = '<PASSWORD>' ;
-- Create a database scoped credential with Azure storage account key as the secret.
CREATE DATABASE SCOPED CREDENTIAL AzureStorageCredential
WITH IDENTITY='SHARED ACCESS SIGNATURE' ,
SECRET = '<SHARED ACCESS SIGNATURE KEY>'
GO
;
-- Create an external data source with CREDENTIAL option.