Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Release task fails, stating "Must declare Scalar Variable" #20627

Open
4 of 7 tasks
himslm opened this issue Nov 7, 2024 · 0 comments
Open
4 of 7 tasks

[BUG]: Release task fails, stating "Must declare Scalar Variable" #20627

himslm opened this issue Nov 7, 2024 · 0 comments

Comments

@himslm
Copy link

himslm commented Nov 7, 2024

New issue checklist

Task name

SqlAzureDacpacDeploymentV1

Task version

1.*

Issue Description

When running Azure DevOps Release Task, SqlAzureDacpacDeploymentV1, it fails if an Entity Framework Core migration is used to add a Stored Procedure that contains Parameters, with the error:

2024-11-07T16:35:12.7145513Z ##[error]Incorrect syntax near the keyword 'PROCEDURE'. Must declare the scalar variable "@StartDate"

I have confirmed that all Parameters have default values set.

protected override void Up(MigrationBuilder migrationBuilder)
{
    migrationBuilder.Sql(@"
      CREATE PROCEDURE [dbo].[StoredProcedureName]
  	(
                @StartDate DATETIME = NULL,
  		@EndDate DATETIME = NULL
  	)
      AS
      BEGIN
  		SET @StartDate = coalesce( @StartDate , GETDATE() )
  		SET @EndDate = coalesce( @EndDate , GETDATE() )
  
      SELECT
          ...
      END;
    ",);
}

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Azure DevOps

Relevant log output

2024-11-07T16:34:31.6744752Z ##[section]Starting: Azure SQL App Sql Task
2024-11-07T16:34:31.6753120Z ==============================================================================
2024-11-07T16:34:31.6753341Z Task : Azure SQL Database deployment
2024-11-07T16:34:31.6753461Z Description : Deploy an Azure SQL Database using DACPAC or run scripts using SQLCMD
2024-11-07T16:34:31.6753650Z Version : 1.247.0
2024-11-07T16:34:31.6753746Z Author : Microsoft Corporation
2024-11-07T16:34:31.6753886Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/sql-azure-dacpac-deployment
2024-11-07T16:34:31.6754069Z ==============================================================================
2024-11-07T16:34:54.2079610Z Temporary inline SQL file: C:\Users\VssAdministrator\AppData\Local\Temp\tmp939E.tmp
2024-11-07T16:34:54.2372466Z Invoke-Sqlcmd -ServerInstance ".windows.net" -Database "" -Username "" -Password ****** -Inputfile "C:\Users\VssAdministrator\AppData\Local\Temp\tmp939E.tmp" -ConnectionTimeout 120
2024-11-07T16:35:08.7893483Z Sql file: D:\a\r1\a*\drop\scripts\app_db_sync.sql
2024-11-07T16:35:08.7925387Z Invoke-Sqlcmd -ServerInstance "
.windows.net" -Database "
" -Username """ -Password ****** -Inputfile "D:\a\r1\a*****************\drop\scripts\app_db_sync.sql" -ConnectionTimeout 120
2024-11-07T16:35:12.7145513Z ##[error]Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@StartDate".
Must declare the scalar variable "@EndDate".
Must declare the scalar variable "@StartDate".
Msg 156, Level 15, State 1, Procedure , Line 7.Check out how to troubleshoot failures at https://aka.ms/sqlazuredeployreadme#troubleshooting-
2024-11-07T16:35:12.7356036Z ##[section]Finishing: Azure SQL App Sql Task

Full task logs with system.debug enabled

 [REPLACE THIS WITH YOUR INFORMATION] 

Repro steps

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant