sql/open-firewall-to-your-ip/README.md #100
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
on: | |
schedule: | |
- cron: '0 4 * * 1' | |
workflow_dispatch: | |
name: 'sql/open-firewall-to-your-ip/README.md' | |
jobs: | |
validate: | |
runs-on: 'ubuntu-latest' | |
steps: | |
- uses: 'azure/login@v1' | |
with: | |
subscription-id: '${{ secrets.AZURE_SUBSCRIPTION_ID }}' | |
client-id: '${{ secrets.AZURE_CLIENT_ID }}' | |
tenant-id: '${{ secrets.AZURE_TENANT_ID }}' | |
- uses: 'actions/checkout@v3' | |
- run: | | |
if [[ -z $REGION ]]; then | |
export REGION=westus2 | |
fi | |
if [[ -z $REGION ]]; then | |
export REGION=westus | |
fi | |
if [[ -z $RESOURCE_GROUP ]]; then | |
export RESOURCE_GROUP=joazrg-$RANDOM | |
echo "Using '"$RESOURCE_GROUP"' as resource group" | |
fi | |
az group create --name $RESOURCE_GROUP --location $REGION | |
if [[ -z $MSSQL_NAME ]]; then | |
export MSSQL_NAME=mssql-$RANDOM | |
export MSSQL_USERNAME=mssql | |
export MSSQL_PASSWORD=p#ssw0rd-$RANDOM | |
fi | |
az sql server create \ | |
--admin-user $MSSQL_USERNAME \ | |
--admin-password $MSSQL_PASSWORD \ | |
--name $MSSQL_NAME \ | |
--resource-group $RESOURCE_GROUP | |
export LOCAL_IP=`curl -s whatismyip.akamai.com` | |
az sql server firewall-rule create \ | |
--resource-group $RESOURCE_GROUP \ | |
--server $MSSQL_NAME \ | |
--name AllowMyLocalIP \ | |
--start-ip-address $LOCAL_IP \ | |
--end-ip-address $LOCAL_IP | |
permissions: | |
contents: 'read' | |
id-token: 'write' |