Azure SQL Database Deployment task - azure-devops

We have a set of Azure SQL Database Deployment tasks set up in Azure Devops, deploy type SQL DACPAC File using Hosted VS2017. Most pass however some result in error:
2019-04-04T23:51:59.1581965Z Initializing deployment (Start)
2019-04-04T23:52:26.0452995Z Initializing deployment (Complete)
2019-04-04T23:52:26.0453268Z Analyzing deployment plan (Start)
2019-04-04T23:52:26.1340183Z Analyzing deployment plan (Complete)
2019-04-04T23:52:26.1346216Z Updating database (Start)
2019-04-04T23:52:31.2433080Z Creating Name...
2019-04-04T23:52:37.8176073Z Updating database (Failed)
2019-04-04T23:52:37.9828381Z ##[error]*** Could not deploy package.
2019-04-04T23:52:37.9918864Z ##[error]Error SQL72014: .Net SqlClient Data Provider: Msg 42019, Level 16, State 4, Line 1 CREATE DATABASE operation failed. Internal service error.
Error SQL72045: Script execution error. The executed script:
CREATE DATABASE [$(D
2019-04-04T23:52:38.0103747Z ##[error]atabaseName)] COLLATE SQL_Latin1_General_CP1_CI_AS;
Error SQL72014: .Net SqlClient Data Provider: Msg 0, Level 20, State 0, Line 0 A severe error occurred on the current command. The results, if any, should be discarded.
Error SQL72045: Script execution error. The executed script:
CREATE DATABASE [$(DatabaseName)] COLLATE SQL_Latin1_General_CP1_CI_AS;
Each of these tasks utilise the same:
Authentication Type
Azure SQL Server
Login
Password
Firewall set IPAddressRange 0.0.0.0 / 255.255.255.255
Not sure why this is occurring when the same login details are used and deploys to some but not others.
We have deployed the dacpac locally and works with no issues.
Any ideas as to why this is occurring?

Related

Postgres Server Migration on Azure

I am performing a postgres server migration on azure but I keep getting a failure. Every time I migrate it fails on extensions with the following error:
Data migration could not be started for one or more of the DBSets. Error details: PGv2RestoreError: PG Restore failed for database 'DATABASE_NAME' with exit code '1' and error message 'error: could not execute query: ERROR: must be owner of extension hypopg'.
Any ideas? The data appears to be in the tables, but the migration in the Azure portal just says failed. This is happening on two servers.

Local SqlServer Database connection for API tests in azure devops pipeline build

I have a .Net Core 3.0 API and
a sql server 2019 database, running on the machine I develop on.
I have 2 API tests that need to connect to db, passing in visual studio test explorer
But on azure devops my pipeline build fails on those 2 API tests
I have set sqlserver for sharedmemory, named pipes and tcp/ip
did not change port 1433
have enabled remote connections in sql server
made a login and a schema for database login
connected my ssms through sql server authentication
have used the vs2019 sql server object explorer properties tab on the database to get the connection string for the db connected with sql server authentication
have stopped and restarted all sql services at regular times. Also my windows firewall is disconnected))
the failing build task in yml
- task: DotNetCoreCLI#2
displayName: 'Running Tests'
inputs:
command: test
projects: '**/*Tests.csproj'
arguments: '--configuration $(buildConfiguration) --collect "Code coverage"'
get following error:
Microsoft.Data.SqlClient.SqlException : A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40
- Could not open a connection to SQL Server)
---- System.ComponentModel.Win32Exception : The network path was not found.
connectionstring:
"Data Source=LAPTOP-SOMERANDOM-NAME;Initial Catalog=DBName;User ID=Admin;Password=*****;
Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
And if I add the port '1433' after Data Source I get following error:
Microsoft.Data.SqlClient.SqlException : A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - No such host is known.)
---- System.ComponentModel.Win32Exception : No such host is known.
Can I make it work?
Do I need a clone of my db of some sort in my pipeline?
Unfortunately I don't have a credit card and no more free credits for azure resource groups
also I don't work with keyvault, I'm trying to make the connection first, will make it safer later :)
Big Thanks in advance for reading and helping!

Dacpac publish how to ignore create database statement?

Due to shared database, we don't have admin privs. Only we have schema id.
In dacpac build or sqlpackage.exe publish is there anyway to ignore the Create database statement ?
2020-03-23T21:48:54.5875811Z ##[error]*** Could not deploy package.
2020-03-23T21:48:54.5930784Z ##[error]Error SQL72014: .Net SqlClient Data Provider: Msg 262, Level 14, State 1, Line 1 CREATE DATABASE permission denied in database 'master'.
Error SQL72045: Script execution error. The executed script:
CREATE DATABASE [$(Datab
2020-03-23T21:48:54.6200608Z ##[error]aseName)] COLLATE SQL_Latin1_General_CP1_CI_AS
i tried with below option in sqlpackage.exe and it's not working
/p:CreateNewDatabase=False /p:ExcludeObjectTypes=Users;Logins;RoleMembership;Permissions;Credentials;DatabaseScopedCredentials
is it possible to hack the dacpac sql script comment the create database and from next version it should able to skip because of incremental load? Appreciate your idea.
For Azure sql datawarehouse is there any alternative to DACPAC deployment ?
You can use sqlpackage.exe to generate update scripts (/a:Script) between your dacpac and target database. Then you can remove unneeded instruction. Here is example to create pipeline: Azure Pipelines - Generating DB Script with SqlPackage.exe

Azure SQL Database DevOps Release pipeline returns Error CREATE DATABASE permission denied

I have created build and release pipelines for Azure SQL Database according to these instructions.
I am able to publish my database project directly from Visual Studio.
My Build pipeline works without problems.
However on release pipeline I am getting the following error:
Error SQL72014: .Net SqlClient Data Provider: Msg 262, Level 14, State 1, Line 1 CREATE DATABASE permission denied in database 'master'.
Error SQL72045: Script execution error. The executed script:
CREATE DATABASE [$(Datab
aseName)] COLLATE SQL_Latin1_General_CP1_CI_AS;
Any idea what I may be doing wrong or how to find where the problem is?
Feeling a bit stupid right about now. I finally found how to debug the pipeline (variable system.debug = true) and it was telling me that it can't find the database defined. Which I had mistyped.
However the error without the debugging option was NOT helpful :D So if anyone is getting this error they should recheck connection information.

Getting org.postgresql.util.PSQLException: FATAL: database "null" does not exist in SpringCloudDataFlow

I'm getting "org.postgresql.util.PSQLException: FATAL: database “null” does not exist" in connecting PostgreSQL to my SpringCloudDataFlow Server App in PCF environment.
I have successfully performed following steps.
Deployed SCDF(Spring-Cloud-Dataflow) server in PCF (1.7.3 version)
Created PostgreSQL service instance with 'Standalone' plan. Note: I don't have any other database service available in PCF marketplace.
Connect to that instance (using host (IP) and autogenerated credentials) by a third party software and create database using script 'CREATE DATABASE scdf'
Bind 'PostgreSQL service instance' with 'SCDF server app'.
Set environment variables
spring_datasource_driver_class_name = org.postgresql.Driver
spring_datasource_username [PostgreSQL_Instance_Autogenerated_Username]
spring_datasource_password [PostgreSQL_Instance_Autogenerated_Password]
spring_datasource_url "jdbc:postgresql://10.254.48.231:5432/scdf"
After setting environment variables, when I restart SCDF server app, it gives exception and crash the app
org.postgresql.util.PSQLException: FATAL: database “null” does not exist
Can anyone help please.
A good first step is to make sure the PostgreSQL service-instance is functional on PCF.
Perhaps you could connect to the host/user/pass from outside of PCF via a DB client tool or from other applications. If this is successful standalone, then there's something wrong in supplying the credentials to the SCDF-server.
It is unclear how you're supplying database properties to SCDF. You may have to wrap those "datasource" properties as a well-defined JSON, and provided as the value for SPRING_APPLICATION_JSON property attached to the SCDF-server. If you continue to see issues, please update the description with manifest.yml and other information about the environment.