How to run scheduled Azure SQL Procedure

How to run scheduled Azure SQL Procedure
Azure Automation with runbook

1.Problem

Azure Managed SQL 에서는 설치형 MSSQL DB와 달리 스케줄 잡을 실행할 수 없습니다.

참고: https://learn.microsoft.com/en-us/azure/azure-sql/managed-instance/job-automation-managed-instance?view=azuresql

2.Solution

Azure Automation AccountPowerShell 로 DB Procedure 실행하는 Job을 등록해서 매일 특정시간에 동작하게 하면 됩니다. 이 외에도 Azure Function을 만들어 주기적으로 실행하는 방법도 있지만 Microsoft 제품인 만큼 생산성을 위해 파워셸을 사용해 간단한 코드로 해결하였습니다.

Write-Output "Run started"

# Instantiate the connection to the SQL Database

$sqlConnection = new-object System.Data.SqlClient.SqlConnection


$sqlConnection.ConnectionString = "Data Source=servername.database.windows.net;Initial Catalog=database;Integrated Security=False;User ID=userid;Password=password;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False"


$sqlConnection.Open()


Write-Output "Azure SQL database connection opened"


# Define the SQL command to run

$sqlCommand = new-object System.Data.SqlClient.SqlCommand

$sqlCommand.CommandTimeout = 120

$sqlCommand.Connection = $sqlConnection


Write-Output "Issuing command to run stored procedure"


# Execute the SQL command

$sqlCommand.CommandText= 'exec [dbo].[storedProcedure]'

$result = $sqlCommand.ExecuteNonQuery()


Write-Output "Stored procedure execution completed"


# Close the SQL connection

$sqlConnection.Close()


Write-Output "Run completed"

참고: https://global.hitachi-solutions.com/blog/azure-sql-databases-stored-procedure/

Read more

[React Native] WebView 안드로이드 로그인 유지

증상 * 안드로이드 앱에서 로그인 유지가 의도한 것 보다 짧게 유지 되거나 로그인 정보가 날라가는 오류가 있었습니다 원인 * 로그인 인증을 위한 쿠키가 메모리에서 디스크로 이동하는데 일정 간격이 있어서 실시간으로 동기화 되지 않았기 때문입니다 조치 * 안드로이드에서 쿠키를 디스크(영구 저장소)로 저장하는 메소드를 앱이 백그라운드로 이동할 때 호출하여 해결하였습니다 * React native의 쿠키관리

By Taehwan Go