This file contains 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
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() |
This file contains 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
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() |
This file contains 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
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}) |
This file contains 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
# 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 |
This file contains 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
# 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 |
This file contains 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
{ | |
"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", |
This file contains 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
- 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 file contains 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
# This PowerShell script triggers and monitors an Azure data factory pipeline outcome. | |
[CmdletBinding()] | |
param( | |
$resourceGroupName, | |
$dataFactoryName, | |
$DFPipelineName | |
) | |
$RunId = Invoke-AzDataFactoryV2Pipeline ` | |
-DataFactoryName $DataFactoryName ` |
This file contains 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
- task: AzurePowerShell@5 | |
name: filepathPowershelltask | |
inputs: | |
azureSubscription: ${{parameters.azureSubscription}} | |
ScriptType: 'FilePath' | |
ScriptPath: ${{parameters.scriptFilePath}} | |
ScriptArguments: ${{parameters.scriptArguments}} | |
azurePowerShellVersion: 'LatestVersion' |
This file contains 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
-- 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. |
NewerOlder