Skip to content

Invoke-Sqlcmd throws Method not found error #108

@gergo-molnar-at-abacus-medicine

Description

I have a release pipeline in Azure DevOps that includes tasks of the built-in type "Azure SQL Database deployment". These steps run SQL script files with a few parameters against an Azure SQL database. Internally, the task uses Invoke-Sqlcmd (that is an implementation detail I can't control, but it's visible in the logs).

Starting from the early afternoon (UTC) on June 17th — which coincides exactly with the release of version 22.4.5.1 — these tasks began failing with the following error (some unrelated parts omitted):

2025-06-17T14:23:51.4621731Z ==============================================================================
2025-06-17T14:23:51.4621858Z Task         : Azure SQL Database deployment
2025-06-17T14:23:51.4621946Z Description  : Deploy an Azure SQL Database using DACPAC or run scripts using SQLCMD
2025-06-17T14:23:51.4622056Z Version      : 1.257.0
2025-06-17T14:23:51.4622132Z Author       : Microsoft Corporation
2025-06-17T14:23:51.4622217Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/sql-azure-dacpac-deployment
2025-06-17T14:23:51.4622335Z ==============================================================================
2025-06-17T14:23:53.9633747Z Added TLS 1.2 in session.
2025-06-17T14:23:54.6270504Z Temporary inline SQL file: C:\Users\AzDevOps\AppData\Local\Temp\tmpA1AF.tmp
2025-06-17T14:23:54.6463018Z Invoke-Sqlcmd -connectionString "**********"  -Inputfile "C:\Users\AzDevOps\AppData\Local\Temp\tmpA1AF.tmp" 
2025-06-17T14:24:06.0488020Z Sql file: C:\a\r1\a\DevOps\UsersAndGroups\UserTest7\CreateUsersAndGroupsInUserTest7.sql
2025-06-17T14:24:06.0512427Z Invoke-Sqlcmd -connectionString "**********"  -Inputfile "C:\a\r1\a\DevOps\xxxx.sql" -Variable "scriptpath=C:\a\r1\a\DevOps\xxxx\", "HANGFIRE_USER_NAME='xxx'", "HANGFIRE_USER_PASSWORD='***'", "ServicePrincipalID='xxxx-1234-1234'", "ServicePrincipalName='abcdrf'"
2025-06-17T14:24:06.2104973Z ##[error]Method not found: 'Microsoft.Identity.Client.PublicClientApplicationBuilder Microsoft.Identity.Client.PublicClientApplicationBuilder.WithParentActivityOrWindow(System.Func`1<System.Windows.Forms.IWin32Window>)'.Check out how to troubleshoot failures at https://aka.ms/sqlazuredeployreadme#troubleshooting-

As a workaround, I added a PowerShell script task before the database deployment step. It uninstalls all existing versions of the SqlServer module and reinstalls version 22.3.0 on the DevOps agent. This resolved the issue for me, which suggests that version 22.4.5.1 introduced a breaking change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions