Support SqlPackage Access Token Authentication
- Lingua principale
- TypeScript
- Stelle
- 142
- Fork
- 73
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
SqlPackage supports the passing in of an access token as an authentication method, with no `Authentication` key/value pair present in the connection string. When this key is omitted from the action, an error is returned requiring that `User` or `User Id` keys are provided. Below is the example workflow yaml:
```
- name: 'Az CLI login'
uses: azure/login@v1
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- name: Get Access Token
run: |
ACCESS_TOKEN=$(az account get-access-token \
--resource https://database.windows.net/ \
--query accessToken \
--output tsv)
echo "AZ_ACCESS_TOKEN=$ACCESS_TOKEN" >> "$GITHUB_ENV"
- name: build
run: # build db project
- name: Deploy to Azure SQL Database
uses: Azure/sql-action@v2.3
with:
connection-string: 'Server=;Initial Catalog=;Connection timeout=60;Encrypt=True'
path: # dacpac file
action: 'publish'
skip-firewall-check: true
arguments: /at:$AZ_ACCESS_TOKEN
```
The above fails with the error: `Invalid connection string. Please ensure 'User' or 'User ID' is provided in the connection string.`
Replacing the final deployment step with a direct call to sqlpackage and passing in the same arguments successfully deploys the dacpac, like so:
```
sqlpackage /Action:Publish /TargetConnectionString:"Server=;Initial Catalog=;Connection timeout=60;Encrypt=True;" /SourceFile: /at:$AZ_ACCESS_TOKEN
```
The use case for this is that I am deploying to an Azure SQL instance using a user assigned managed identity with federated credentials, running on a self hosted runner which has not been assigned the managed identity. Using `Authentication=Active Directory Managed Identity` requires that the MI has been assigned to the runner machine.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia tracciando la convalida della stringa di connessione e la gestione degli argomenti dell'action, quindi riproduci il workflow usando la stringa di connessione e l'argomento token /at mostrati. Confronta il suo comportamento con il comando sqlpackage diretto. Il lavoro è completato quando l'action può eseguire il deployment con l'autenticazione tramite access token di SqlPackage quando non è presente alcun valore per Authentication, User o User Id.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- azure, github-actions, sql, typescript
- Ambito
- ci-cd, cloud, database
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100