I have a Script.PostDeployment.sql which references DataFactoryRights.sql
ScriptPostDeployment.sql, build action PostDeploy:
:r .\DataFactoryRights.sql
DataFactoryRights.sql, build action None:
CREATE USER [dataFactory] FROM EXTERNAL PROVIDER;
When I try to build, I get the error:
Severity Code Description Project File Line Suppression State
Error SQL72007: The syntax check failed 'Incorrect syntax near FROM.' in the batch near:
'CREATE USER [dataFactory] FROM EXTERNAL PROVIDER;'
If I comment out like --:r .\DataFactoryRights.sql, it builds ok
The error is caused by the T-SQL action:
CREATE USER [dataFactory] FROM EXTERNAL PROVIDER;
Data Factory is service principals.
Microsoft MSFT confirmed that:
"We currently don't allow service principals to create users in SQL DB. We will update the documentation when this feature is available. Thanks!"
That's why you comment out like --:r .\DataFactoryRights.sql, it builds ok.
Ref:https://github.com/MicrosoftDocs/sql-docs/issues/2323#issuecomment-595417579
Hope this helps.
Related
ORIGINAL QUESTION:
Trying to upgrade a blank database created in a test VM using a .dacpac file, but get the following error message:
Error SQL72014: .Net SqlClient Data Provider: Msg 15401, Level 16, State 1, Line 1 Windows NT user or group 'SOURCE_DOMAIN\SOURCE SQL Readers' not found. Check the name again.
Error SQL72045: Script execution error. The executed script:
CREATE LOGIN [SOURCE_DOMAIN\SOURCE SQL Readers]
FROM WINDOWS WITH DEFAULT_LANGUAGE = [us_english];
(Microsoft.SqlServer.Dac)
------------------------------
Program Location:
at Microsoft.SqlServer.Dac.DeployOperation.ThrowIfErrorManagerHasErrors()
at Microsoft.SqlServer.Dac.DeployOperation.<>c__DisplayClass14.<>c__DisplayClass16.<CreatePlanExecutionOperation>b__13()
at Microsoft.Data.Tools.Schema.Sql.Dac.OperationLogger.Capture(Action action)
at Microsoft.SqlServer.Dac.DeployOperation.<>c__DisplayClass14.<CreatePlanExecutionOperation>b__12(Object operation, CancellationToken token)
at Microsoft.SqlServer.Dac.Operation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.ReportMessageOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.DeployOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.OperationExtension.Execute(IOperation operation, DacLoggingContext loggingContext, CancellationToken cancellationToken)
at Microsoft.SqlServer.Dac.DacServices.InternalDeploy(IPackageSource packageSource, Boolean isDacpac, String targetDatabaseName, DacDeployOptions options, CancellationToken cancellationToken, DacLoggingContext loggingContext, Action`3 reportPlanOperation, Boolean executePlan)
at Microsoft.SqlServer.Dac.DacServices.Deploy(DacPackage package, String targetDatabaseName, Boolean upgradeExisting, DacDeployOptions options, Nullable`1 cancellationToken)
at Microsoft.SqlServer.Management.Dac.DacWizard.UpgradeModel.RunAction()
at Microsoft.SqlServer.Management.Dac.DacWizard.ExecuteDacPage.backgroundWorker1_DoWork(Object sender, DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
Assuming that user existed in the source, but not in the destination. Will creating that user on the VM fix this issue or will I need to use a different approach to get the schema data from the source re-created in a VM destination for testing purposes?
UPDATE TO QUESTION 1:
The .dacpac file is generated on a server which is on a totally different domain and it will not be possible for the test VM to ever be on the same domain. With that in mind, how do I get the .dacpac file to work on the test VM?
If you still have access to VM, you could generate .dacpac again this time ignoring the logins. Depending which tool you use you should have access to option like "Include User Login Mapping".
The most roboust one has the VS: "How to create DACPAC file?" by Kamil Nowinski:
Image source: https://sqlplayer.net/wp-content/uploads/2018/10/visual-studio-extract-dacpac-options.png
You could recreate the proper logins and users afterwards with own SQL script.
Related: Using Publish Profiles to Deploy a DACPAC Database Without User Accounts
The solution to this problem lies in defining an appropriate publish profile for your DACPAC, which then instructs your chosen deployment tool – SQLPackage.exe, Visual Studio, or Azure DevOps – on how to carry out the deployment
The profile is defined as an XML file.
ExcludeUsers
ExcludeLogins
ExcludeDatabaseRoles
By setting these options to True within our publish profile, creation or modification of these objects will be skipped entirely during any database deployment.
One more option is to use dbtools.io - Export-DbaDacPackage
Key point here is:
$exportProperties = "/p:IgnorePermissions=True /p:IgnoreUserLoginMappings=True" # Ignore
and publish.xml:
...
<ExcludeLogins>True</ExcludeLogins>
<IgnorePermissions>True</IgnorePermissions>
<IgnoreLoginSids>True</IgnoreLoginSids>
<IgnoreRoleMembership>True</IgnoreRoleMembership>
Summary:
create a dacpac without login
create a publish.xml file that will ignore permissions
Creating the user inside the VM is one way to solve this issue, but you will need to change 'SOURCE_DOMAIN' to the VM hostname, as the user will be part of the local user database.
Probably the best solution is to fix VM communication to the Domain Controller, so authentication will work and user accounts end up being actually visible within the VM.
Take a look at this,
This error usually occurs because of COMPATIBILITY_LEVEL
I would recommend trying this quarry out:
ALTER DATABASE database_name
SET COMPATIBILITY_LEVEL = 130;
Hope it helps!
If a dacpac contains users or groups that aren’t on the domain where the dacpac is being deployed, then one way to deploy it is using the SqlPackage command line tool, as this allows you to explicitly list the object types you want to exclude.
To exclude users and groups, the PowerShell command would be something like this:
.\SqlPackage.exe `
/a:Publish `
/tsn:"(localdb)\mssqllocaldb" `
/tdn:YourDatabaseName `
/p:ExcludeObjectTypes="Users;RoleMembership;Logins;ServerRoles;ServerRoleMembership;Permissions" `
/sf:YourFile.dacpac
This command uses the following switches:
/a (Action): the action to run, in this case Publish
/tsn (TargetServerName): the name of the server to deploy to
/tdn (TargetDatabaseName): the name of the database to deploy to
/p (Properties): name value pair of action-specific properties, in this case:
ExcludeObjectTypes: a semicolon-delimited list of object types that should be ignored
/sf (SourceFile): the dacpac file to deploy
More details of the syntax for Publish (including a list of the object types that can be exlcuded) are available in the docs for the publish action.
In BigQuery console I created a UDF function (language js) and now trying to call it from a saved query. I tried referencing the UDF with projectID.dataset.UDF_Name (same as I am using the for referencing vies/tables). When I click Run in UI I got an error:
"The project XXX has not enabled BigQuery"
I checked the BigQuery API and it says enabled.
When I only used dataset.UDF_Name for reference the query worked but I can save it as view getting another error: Bad routine reference "dataset.UDF_Name()"; routine references in standard SQL views require explicit project IDs
So clearly, the right approach is to use the projectID.dataset.UDF_Name() format but I can't figure out how to get rid of the "The project XXX has not enabled BigQuery" error.
Any help, much appreciated.
What is the use / purpose of logging menu in the
Settings -> Technical -> Database structure -> Logging
It seems that you can store all the log messages in that view (model ir.logging) as long as you use the parameter --log-db your_database_name when executing odoo-bin in the command line (or add log_db = your_database_name in your Odoo config file).
Check out Odoo 11 info about command line parameters: https://www.odoo.com/documentation/11.0/reference/cmdline.html
--log-db
logs to the ir.logging model (ir_logging table) of the specified database. The database can be the name of a database in the “current” PostgreSQL, or a PostgreSQL URI for e.g. log aggregation
This is the theory, but honestly, I was not able to make it work, and I did not waste much time in trying to know why.
EDIT
As #CZoellner says, it seems that log messages stored in ir_logging table (log messages you see clicking on the menuitem Settings -> Technical -> Database structure -> Logging) come only from scheduled actions. If you create an scheduled action which executes some Python code, you have the following available variables to use in your method code:
env: Odoo Environment on which the action is triggered.
model: Odoo Model of the record on which the action is triggered; is a void recordset.
record: record on which the action is triggered; may be void.
records: recordset of all records on which the action is triggered in multi-mode; may be void.
time, datetime, dateutil, timezone: useful Python libraries.
log: log(message, level='info'): logging function to record debug information in ir.logging table.
Warning: Warning Exception to use with raise To return an action, assign: action = {...}.
If you use the log one, for example:
log('This message will be stored in ir_logging table', level='critical')
That log message and its details will be stored in ir_logging table each time the scheduled action is executed (automatically or manually). This answers your question, but now I am wondering what is the parameter --log-db, as I have tested it and these log messages are stored in ir_logging no matter this parameter is set or not.
I have the following statement in my Startup.cs:
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.ColoredConsole()
.WriteTo.MSSqlServer("Server=(localdb)\\MSSQLLocalDB;Database=myDb.Logging;Trusted_Connection=True;", "Logs", autoCreateSqlTable: true)
.WriteTo.RollingFile(pathFormat: Path.Combine(logPath, "Log-{Date}.txt"))
.CreateLogger();
And in my Configure method:
loggerFactory.AddSerilog();
When I start the application, the table is created so I know the connection works. I get logged output to the console and to the file, however, no output to the database table.
What am I failing to do?
Other information: using asp.net core rc2-final, targeting net461, and using Serilog.Sinks.MSSqlServer 4.0.0-beta-100
At first glance it doesn't look like you're missing anything. It's likely that an exception is being thrown by the SQL Server Sink when trying to write to the table.
Have you tried checking the output from Serilog's self log?
Serilog.Debugging.SelfLog.Enable(msg => Console.WriteLine(msg));
Update:
Looks like a permission issue with you SQL Server/Local DB. This error message suggests the sink is trying to run an ALTER TABLE statement and the user running the application doesn't have permission to execute an ALTER TABLE statement.
Update 2: I suggest you write a simple Console App using the full .NET + Serilog v1.5.14 + Serilog.Sinks.MSSqlServer v3.0.98 to see if you get the same behavior... Just to rule out the possibility that there's a problem with the .NET Core implementation or with the beta sink version you're using
This the scenario have. There's an SSRS server that has a report where the datasource is of type XML and it uses windows authentication, nothing else to it. Inside the report there's a dataset that uses that data source with this for a query "=Code.ReportUser.GetListOfItems()". This calls a method in the custom assembly that connects to the database and returns data in a string formated like this (angle brackets changed to curly for read
"<Query><XmlData><Items>" + xmlDocument.DocumentElement.InnerXml + "</Items></XmlData></Query>"
where sql datatable is written into the xmlDocument. If I go to the reporting server through an IE and run the report everything works as it should. The Problem occures when add this link to Zangle application which runs it as "IEHOST.app 'report's url'". I believe its a foxpro app that opens a browser object and report fails on the dataset that uses my xml data source. There's no question about url or reports correctness because it functions in a different environment.
This is the server error i get:
library!ReportServer_0-8!ca0!02/24/2012-10:18:45::
Call to GetPermissionsAction(path to my report).
library!ReportServer_0-8!e68!02/24/2012-10:18:45::
Call to GetSystemPropertiesAction().
library!ReportServer_0-8!e68!02/24/2012-10:18:45::
Call to GetPropertiesAction(path to my report, PathBased).
library!ReportServer_0-8!10bc!02/24/2012-10:18:45::
Call to GetSystemPermissionsAction().
library!ReportServer_0-8!e68!02/24/2012-10:18:45::
Call to GetSystemPropertiesAction().
processing!ReportServer_0-8!10bc!02/24/2012-10:18:45::
e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: ,
Microsoft.ReportingServices.ReportProcessing.ReportProcessingException:
Error during processing of the CommandText expression of dataset ‘Items’.;
processing!ReportServer_0-8!10bc!02/24/2012-10:18:45::
e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: ,
Microsoft.ReportingServices.ReportProcessing.ReportProcessingException:
Cannot set the command text for dataset 'Items'. ---> Microsoft.ReportingServices.ReportProcessing.ReportProcessingException:
Error during processing of the CommandText expression of dataset ‘Items’.
at Microsoft.ReportingServices.OnDemandProcessing.RuntimeDataSet.RunEmbeddedQuery(Boolean& readerExtensionsSupported, Boolean& readerFieldProperties, List`1 queryParams, Object[] paramValues)
--- End of inner exception stack trace ---;
I'm not sure what this means exactly. Any thoughts? it looks like a permission issue but i don't understand where. I did try to change xml data source authentication from windows to none and then add my AD account as an execution user on the reporting server. This didnt' change anything still working from browser but from Zangle browser object. One more thing, server requires authentication and all the report regardless of the environment promt for login and successfully authenticate so my credentials seems to pass to the server and only my xml data source is throwing an error when launched from with Zangle. Please share your ideas. I'm a programmer but I'm not too server stuff savy and I'm new to SSRS. Thank you.
Resolved. Turns out that foxpro app lowercases everything and the name of the sql server passed to the assembly doesn't match the name stored in the assembly. Silly :) So we'll be lowercase comparing everything from now on.