Azure / Azure/sql-action

Support SqlPackage Access Token Authentication

Offen
#262 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
need-to-triage
Vorherrschende Sprache
TypeScript
Sterne
142
Forks
73
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, die Validierung der Verbindungszeichenfolge und die Argumentverarbeitung der action nachzuverfolgen, und reproduziere anschließend den Workflow mit der gezeigten Verbindungszeichenfolge und dem Argument /at token. Vergleiche ihr Verhalten mit dem direkten sqlpackage-Befehl. Als erledigt gilt die Aufgabe, wenn die action mit der Access-Token-Authentifizierung von SqlPackage bereitstellen kann, wenn kein Wert für Authentication, User oder User Id vorhanden ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
azure, github-actions, sql, typescript
Bereich
ci-cd, cloud, database
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.