-
Notifications
You must be signed in to change notification settings - Fork 58
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
Introducing sql-action v2 #122
Conversation
* Use tedious mssql library instead of sqlcmd * Fix mssql connection * Fix SqlUtils tests * Use config instead of connection string * Replace conn string builder with mssql config * Connect to master db * Restore connection string validation regex * PR comments, fix error handling * Update main.js * Use try catch for error handling * Fix typo
* Change script action from sqlcmd to mssql query * Update action.yml * Fully qualify Table1 in sql script * Add more debug logging * Clone config before changing db to master * Cleanup * Set TEST_DB name before cleanup * Use runner.temp * Always cleanup * PR comments
* Debug script contents * Fix sed command * Remove debug
…ipal auth (#100) * Use tedious mssql library instead of sqlcmd * Fix mssql connection * Fix SqlUtils tests * Use config instead of connection string * Replace conn string builder with mssql config * Connect to master db * Restore connection string validation regex * AAD auth * Add support for client and tenant IDs * Add more debug messaging * Fix connection string find array * Make client-id and tenant-id action inputs * Fix error handling * More fixes * Use try catch instead * Add tests to pr-check.yml * Change script action from sqlcmd to mssql query * Update action.yml * Fully qualify Table1 in sql script * Add more debug logging * Clone config before changing db to master * Cleanup * Set TEST_DB name before cleanup * Use runner.temp * Always cleanup * Add tests for different auth types * Mask tenant and client IDs * Add AAD password test to pr-check.yml * Fix yaml * Limit max-parallel to 2 * Add test for service principal * PR comments * Fix typo
* Retry with DB connection if master fails * Add tests * Add ConnectionResult interface * Add missing doc comment * PR comments * PR Comments
* Add setup script to download go-sqlcmd * Add sqlcmd call to pr-check.yml * Add bz2 specific extract tar * Move setup code to main * Move setup code to main * Fix casing of Setup.ts
* call go-sqlcmd for script action * Fix auth options not flowing through * Add test cases * Restore sqlcmd variable in cleanup script * Fix pr-check cleanup * Undo changes to pr-check.yml * Undo pr-check.yml changes * PR comments
* Change inputs * Add other publish like actions * Add tests * Fix test * PR comments
@zijchen I am in the middle of testing this out with a Service Principal logging, but v2 keeps on failing with: Action config looks like: database-updates: Where SQL_USERNAME contains SP clientID and SQL_PASSWORD contains clientSecret of the SP. I do have a previous job that has an azure login. But the login is not present in the database-updates job, so I would guess this then defaults to not setting temp FW rules and uses current FW rules. SQL Server in Azure has been setup with allow azure services access. |
So the issue in my case is in the connection string: changed connection string to: connection-string: ${{ format('Server={0};Initial Catalog={1};Authentication="Active Directory Service Principal";User Id={2};Password={3}', needs.deploy-infra.outputs.sqlServerFullyQualifiedDomainName, needs.deploy-infra.outputs.databaseName, secrets.SQL_USERNAME, secrets.SQL_PASSWORD) }} Might want to change that error message to 'Failed to connect to database' instead of 'failed to add FW rule', since that is misleading. Also, might want to add the format of the connectionstring in the README file. Currently I had to look for it in the test cases in the code. Still struggling a bit with the rest of the connection string ... will let you know once I get this working. |
@vermegi Thank you for trying v2. Your connection string should have worked, I have submitted #137 to fix the issue of requiring quotation marks around the authentication option. Could you tell us more about the issue you're still facing after adding the quotation marks? Feel free to share your debug logs with us too. |
Still getting an error: This is the connection string: I tried both clientId and clientId@tenant of the service principal as value for the User Id. The service principal has both contributor and SQL Security Manager permissions on the resource group. Any hints on how to properly make the login work would be appreciated. |
Btw, the actual connection string is this: Full workflow file: https://github.com/vermegi/app-service-networking-samples/blob/givermei-workflow-update/.github/workflows/infradeploy.yml It's just in the action workflow output that 'Password' seems to get fully obfuscated. |
adding connection string format to docs
@vermegi I tried something exactly like your yaml in my own repo and it seemed to work. I have some ideas you can try:
SELECT * FROM sys.database_principals WHERE type = 'E'
|
I probably have a chicken or egg problem there, then, since trying to automate a full setup ... and this is not an issue of this specific action btw, but of SQL Server on Azure in general. |
Login succeeds and works like a charm when I first add my SP as a user in the database. |
That's good to hear. Maybe you can first create an AAD user and run this action with AAD Password auth to create your SP user? |
Well, thing is I don't have the permissions to do that on the tenant I'm using. So will unfortunately not be able to perform that test. |
Merging v2 changes to master branch.
Main changes in v2:
Breaking changes from v1:
For complete documentation for v2, visit the README on v2 branch
project-file
,dacpac-package
,sql-file
parameters are consolidated into a singlepath
parameter. sql-action will determine the appropriate action based on the file extension.action
parameter used to specify the sqlpackage action (when .sqlproj or .dacpac files are used)arguments
andbuild-arguments
for optional arguments