Skip to content

Feature request: Decouple using managed identity from updating sql network settings #186

Description

@audunsolemdal

I am trying to apply migrations from a self hosted runner. The runner has network access to the sql server via private endpoint and does not need any new network openings. The SQL server denies public access.

It seems as the sql-action is hard coded to attempt adding network rules if azure/login is found

(...)
  deployToDev:
    needs: [buildandtest]
    runs-on: [self-hosted, my-runner] # Deployment must happen through a self-hosted agent with network access.
    environment: "dev"
    permissions:
      id-token: write
      contents: read
      packages: read
    steps:
      #Run migrations

      - uses: azure/login@v1
        with:
          client-id: ${{ vars.AZURE_SQL_CLIENT_ID }}
          tenant-id: ${{ vars.TENANT_ID }}
          subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}

      - name: "Download migrations script"
        uses: actions/download-artifact@v3
        with:
          name: "migrations"
          path: "./SQLScripts"

      - name: Run migrations script
        uses: azure/sql-action@v2
        with:
          connection-string: "Server=xxxxl;Initial Catalog=yyyyy;Authentication=Active Directory Default; Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
          path: "./SQLScripts/migrations.sql"

I end up with a

The client 'zzzzzzzz' with object id 'zzzzzzzzzzzzzzzz' does not have authorization to perform action 'Microsoft.Sql/servers/firewallRules/write' over scope (..)

I would like there to be an input var to skip this step entirely, as I have no interest in ad-hoc openings towards the sql server.

I also tried not granting the managed identity access to any subscriptions, setting this

      - uses: azure/login@v1
        with:
          client-id: ${{ vars.AZURE_SQL_CLIENT_ID }}
          tenant-id: ${{ vars.TENANT_ID }}
          allow-no-subscriptions: true

this however failed with this error:

Error: The subscription 'MY-TENANT-ID could not be found.
Error: {"statusCode":404,"message":"The subscription 'MY-TENANT-ID' could not be found.","code":"SubscriptionNotFound"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    idleInactive for 14 dayswaiting-for-userWaiting for inputs from user

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions