I get this error when I run dacpac from VS Community 2017 MVC 5 project.
"Internal Error. The database platform service with type Microsoft.Data.Tools.Schema.Sql.Sql140DatabaseSchemaProvider is not valid. You must make sure the service is loaded, or you must provide the full type name of a valid database platform service."
The code
var dacpacName = "setup.dacpac";
var dacpacPath = Path.Combine(Server.MapPath("~/assets/dacpac"), dacpacName);
var dp = DacPackage.Load(dacpacPath);
var dbDeployOptions = new DacDeployOptions
{
BlockOnPossibleDataLoss = false,
ScriptDatabaseOptions = false,
GenerateSmartDefaults = true,
CreateNewDatabase = true
};
var dbServices = new DacServices(setupDbConn.ConnectionString);
dbServices.Deploy(dp, newDatabaseName, true, dbDeployOptions);
The error happens after this code:
var dbServices = new DacServices(setupDbConn.ConnectionString);
My SqlExpress is 2017. I've regenerated the dacpac from SqlExpress 2017 as well. The dacpac works without error when I use it in SqlExpress.
I've been googling for hours but can't seem to find the right answer to this. I'm thinking this is some kind of compatibility issues but can't figure out how to fix the error.
Hope someone have experienced this and can help me fix this issue.
I've tried everything I can think of. I've installed different versions of dacfx. Also tried generating dacpac from 2008. All with no luck.
I then resorted to other ways instead of using dacpac. I've generated a script for recreating all the tables and run that instead.
Server myServer = new Server(serverName);
//Using windows authentication
bool integratedSecurity = Convert.ToBoolean(ConfigurationManager.AppSettings["integratedSecurity"]);
myServer.ConnectionContext.LoginSecure = integratedSecurity;
myServer.ConnectionContext.Connect();
// check that database doesn't already exists
if (myServer.Databases.Contains(newDatabaseName))
{
return new HttpStatusCodeResult(400, "Database has already been created");
}
//Define a Database object variable by supplying the server and the database name arguments in the constructor.
Database db;
db = new Database(myServer, newDatabaseName);
//Create the database on the instance of SQL Server.
db.Create();
string dbscript = System.IO.File.ReadAllText(Server.MapPath("~/assets/dbscript/createAllTables.sql"));
myServer.Databases[newDatabaseName].ExecuteNonQuery(dbscript);
myServer.ConnectionContext.Disconnect();
Related
I use CosmosClient from SDK Microsoft.Azure.Cosmos 3.28.0 in ASP.NET Core 3.1 in Azure Durable Function. This client is getting and sending data from/to my cosmos instance (Core (SQL)) and it works fine but I see that it constantly throws exception in following http request for metadata
GET 169.254.169.254/metadata/instance
System.Net.Http.HttpRequestException: An attempt was made to access a socket in a way forbidden by its access permissions.
I use following configuration:
private static void RegisterCosmosDbClient(ContainerBuilder builder)
{
builder.Register(c => new SocketsHttpHandler()
{
PooledConnectionLifetime = TimeSpan.FromMinutes(10), // Customize this value based on desired DNS refresh timer
MaxConnectionsPerServer = 20, // Customize the maximum number of allowed connections
}).As<SocketsHttpHandler>().SingleInstance();
builder.Register(
x =>
{
var cosmosDbOptions = x.Resolve<CosmosDbOptions>();
var socketsHttpHandler = x.Resolve<SocketsHttpHandler>();
return new CosmosClient(cosmosDbOptions.ConnectionString, new CosmosClientOptions()
{
ConnectionMode = ConnectionMode.Direct,
PortReuseMode = PortReuseMode.PrivatePortPool,
IdleTcpConnectionTimeout = new TimeSpan(0, 23, 59, 59),
SerializerOptions = new CosmosSerializationOptions()
{
PropertyNamingPolicy = CosmosPropertyNamingPolicy.CamelCase
},
HttpClientFactory = () => new HttpClient(socketsHttpHandler, disposeHandler: false)
});
})
.AsSelf()
.SingleInstance();
}
I also tried approach with passing IHttpClientFactory from this blog but it didn't help.
It looks like there are no new sockets available in your environment therefore you are getting the socket forbidden error. Please review how to manage connection for Azure Cosmos DB clients and you should use a singleton Azure Cosmos DB client for the lifetime of your application to resolve the issue. In case if you still facing the issue leveraging the singleton object then please let me know so we can further review it.
That particular IP and path is for https://learn.microsoft.com/azure/virtual-machines/windows/instance-metadata-service?tabs=windows
The SDK is attempting to detect the Azure information. It could mean for Durable Functions, this information and endpoint is not available.
This does not affect SDK operations and should not block you from performing other actions on the CosmosClient instance.
MY application exports CSV's fine when I test it from Visual Studio, but when I deploy it to an Azure as a Web app, instead of exporting a CSV I get a Error code: ERR_INVALID_RESPONSE.
Below is the method I use :
public void ExportEmpReport(int? er_id)
{
var er_hdr = db.expense_report_hdr.Include(w => w.employeeExpUser).Where(x => x.ID == er_id).FirstOrDefault();
StringWriter sw = new StringWriter();
sw.WriteLine("Employee Name: " + er_hdr.employeeExpUser.fullname + ", Period: " + er_hdr.period + ", Expense Report ID: " + er_id);
sw.WriteLine("Date of Expense , Expense Class , Detail , Cust/Conv , Notes , Amount , GL Code , Project Code");
Response.ClearContent();
Response.AddHeader("content-disposition", "attachment;filename=ExpenseReport_" + er_id + ".csv");
Response.ContentType = "text/csv";
var lines = db.expense_report_line.Where(y => y.er_id == er_id);
foreach (var line in lines)
{
string exp_class = line.expenseType.expense.ToString().Replace(",", "");
string detail = (line.expense_detail != null) ? line.expense_detail.Replace(",", "") : "";
string cust_conv = (line.cust_conv != null) ? line.cust_conv.Replace(",", "") : "";
string notes = (line.notes != null) ? line.notes.Replace(",", "") : "";
sw.WriteLine(string.Format("{0},{1},{2},{3},{4},{5},{6},{7}", line.expense_date, exp_class, detail, cust_conv, notes, line.amount, line.gl_code.GL_code, line.project_code));
}
Response.Write(sw.ToString());
Response.End();
}
Here are some suggestions you may use to try and troubleshoot it:
A. Debug the web app locally, while connected to the DB on Azure. Are the tables being read correctly?
If the code fails to read the data from the database, make sure that the database is updated to the latest schema.
B. If it reads the data correctly, debug it step by step, and watch exactly where it fails.
If it fails at a particular line, remove/replace some lines of code until the local web app is running correctly against the DB on Azure. You may be able to identify the offending line(s) of code, and then report back here to allow others to help you troubleshoot further.
C. Once you get it working with the local app against the DB on Azure, deploy the updated project code to the Web App on Azure to see if it still runs correctly.
If it still doesn't work, maybe there's a setting on your Web App that is preventing it from running the code successfully.
D. Check the version of the .NET Framework on the Web App in Azure. The choices should be v3.5 or v4.6 (for non-Core 1.0 applications).
If it has the wrong version selected, make sure you select the correct version.
E. Enable Remote Debugging of the Web App running on Azure.
There's a Remote Debugging feature that you can toggle on/off in the Application Settings blade, where you can also select the VS version (2012, 2013, 2015). Turn it on to pinpoint which line of code it's failing at.
Whatever I tried I cannot set an extension property on a User object, here is a reproducible piece of code:
public async Task CleanTest(string extName)
{
ExtensionProperty ep = new ExtensionProperty
{
Name = extName,
DataType = "String",
TargetObjects = { "User" }
};
App app = (App)(await _client.Applications.Where(a => a.AppId == _managementAppClientId).ExecuteSingleAsync());
app.ExtensionProperties.Add(ep);
await app.UpdateAsync();
GraphUser user = (GraphUser)(await _client.Users.Where(u => u.UserPrincipalName.Equals("email")).ExecuteSingleAsync());
string propName = FormatExtensionPropertyName(extName); //formats properly as extesion_xxx_name
user.SetExtendedProperty(propName, "testvalue");
//user.SetExtendedProperty(extName, "testvalue");
await user.UpdateAsync(); // fails here
}
user.UpdateAsync() according to Fiddler doesn't even go out and application fails with an exception:
"The property 'extension_e206e28ff36244b19bc56c01160b9cf0_UserEEEqdbtgd3ixx2' does not exist on type 'Microsoft.Azure.ActiveDirectory.GraphClient.Internal.User'. Make sure to only use property names that are defined by the type."
This issue is also being tracked here:
https://github.com/Azure-Samples/active-directory-dotnet-graphapi-console/issues/28
I've got an alternative workaround for this bug, for those that want to use the version 5.7 OData libraries rather than redirecting to the v5.6.4 versions.
Add a request pipeline configuration handler.
// initialize in the usual way
ActiveDirectoryClient activeDirectoryClient =
AuthenticationHelper.GetActiveDirectoryClientAsApplication();
// after initialization add a handler to the request pipline configuration.
activeDirectoryClient.Context
.Configurations.RequestPipeline
.OnMessageWriterSettingsCreated(UndeclaredPropertyHandler);
In the handler, change the ODataUndeclaredPropertyBehaviorKinds value on the writer settings to SupportUndeclaredValueProperty.
private static void UndeclaredPropertyHandler(MessageWriterSettingsArgs args)
{
var field = args.Settings.GetType().GetField("settings",
BindingFlags.NonPublic | BindingFlags.Instance);
var settingsObject = field?.GetValue(args.Settings);
var settings = settingsObject as ODataMessageWriterSettings;
if (settings != null)
{
settings.UndeclaredPropertyBehaviorKinds =
ODataUndeclaredPropertyBehaviorKinds.SupportUndeclaredValueProperty;
}
}
Just in case you still looking for solution to this problem or someone else is facing the same issue:
I got similar issue and it looks like, at least for me, the problem was in latest version of "Microsoft.Data.Services.Client" package - 5.7.0 (or in one of it dependencies). When I downgraded to previous version - 5.6.4 it worked as a charm.
I had same symptoms - updating of extended property was failing even w/o any request is made (also used Fiddler)
Hope it helps!
Artem Liman
I am using socket.io in node.js to implement chat functionality in my azure cloud project. In it i have been adding the user chat history to tables using node.js. It works fine when i run it on my local emulator, but strangely when i deploy to my azure cloud it doesnt work and it doesnt throw up any error either so its really mind boggling. Below is my code.
var app = require('express')()
, server = require('http').createServer(app)
, sio = require('socket.io')
, redis = require('redis');
var client = redis.createClient();
var io = sio.listen(server,{origins: '*:*'});
io.set("store", new sio.RedisStore);
process.env.AZURE_STORAGE_ACCOUNT = "account";
process.env.AZURE_STORAGE_ACCESS_KEY = "key";
var azure = require('azure');
var chatTableService = azure.createTableService();
createTable("ChatUser");
server.listen(4002);
socket.on('privateChat', function (data) {
var receiver = data.Receiver;
console.log(data.Username);
var chatGUID1 = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
var chatRecord1 = {
PartitionKey: data.Receiver,
RowKey: data.Username,
ChatID: chatGUID2,
Username: data.Receiver,
ChattedWithUsername: data.Username,
Timestamp: new Date(new Date().getTime())
};
console.log(chatRecord1.Timestamp);
queryEntity(chatRecord1);
}
function queryEntity(record1) {
chatTableService.queryEntity('ChatUser'
, record1.PartitionKey
, record1.RowKey
, function (error, entity) {
if (!error) {
console.log("Entity already exists")
}
else {
insertEntity(record1);
}
})
}
function insertEntity(record) {
chatTableService.insertEntity('ChatUser', record, function (error) {
if (!error) {
console.log("Entity inserted");
}
});
}
Its working on my local emulator but not on cloud and I came across a reading that DateTime variable of an entity should not be null when creating a record on cloud table. But am pretty sure the way am passing timestamp is fine, it is right? any other ideas why it might be working on local but not on cloud?
EDIT:
I hav also been getting this error when am running the socket.io server, but in spite of this error the socket.io functionality is working fine so i didnt bother to care about it. I have no idea what the error means in the first place.
{ [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect' }
Couple things:
You shouldn't need to set Timestamp, the service should be populating that automatically when you insert a record.
When running it locally you can set the environment variables to the Windows Azure storage account settings and see if it will successfully write to the table when running on your developer box. Instead of running in the emulator, just set the environment variables and run the app directly with node.exe.
Are you running in a web role or worker role? I'm assuming it's a cloud service since you mentioned the emulator. If it's a worker role, maybe add some instrumentation to log to file to assist in debugging. If it's a web role you can add an iisnode.yml file in the root of the application, with the following line in the file to enable logging of stdout/stderr:
loggingEnabled: true
This will capture stdout/stderr to an iislog folder under the approot folder on e: or f: of the web role instance. You can remote desktop to the instance and look at the logs to see if the logs you have for successful insertion are occurring.
Otherwise, it's not obvious from the code above what's going on. Similar code worked fine for me. Relevant bits for my test code can be found at https://gist.github.com/Blackmist/5326756.
Hope this helps.
I have developed a windows services which work to send email for neglected lead after 7 days.
When I run code in my machine it work and continue. But when I install in a Windows services then some error occurs:
using (OrganizationServiceProxy serviceProxy =
new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, null))
{
IOrganizationService service = (IOrganizationService)serviceProxy;
ColumnSet Indexcol = new ColumnSet(new string[] { columnname });
QueryByAttribute indexattribute = new QueryByAttribute();
indexattribute.EntityName = EntityName;
indexattribute.Attributes.AddRange(RangeAttribute);
indexattribute.Values.AddRange(RangeValues);
indexattribute.ColumnSet = Indexcol;
RetrieveMultipleRequest req_index = new RetrieveMultipleRequest();
req_index.Query = indexattribute;
try {
// Error occurs when this line executes
RetrieveMultipleResponse resp_index =
(RetrieveMultipleResponse)service.Execute(req_index);
EntityCollection mcs_index = resp_index.EntityCollection;
}
}
and error is
The server was unable to process the request due to an internal error.
For more information about the error, either turn on
IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute
or from the configuration behavior) on the server in
order to send the exception information back to the client, or turn on
tracing as per the Microsoft .NET Framework 3.0 SDK documentation and
inspect the server trace logs.
kindly guide me I am stuck here. :(