I have an azure mobile service that will go live at some point. So I need to create UAT and dev versions which would point to the UAT and dev databases. What I am struggling with is how to create these.
The namespace in my live, UAT and Dev databases need to be the same but if I create a new mobile service called myAppName_UAT, it's going to want to use MyAppName_UAT as the namespace and so will not find any of the tables.
Has anyone overcome this problem? Once the product goes live I'll need to be able to test the mobile apps against the Dev db without affecting live which surely must be a common scenario?
Any advice would be very gratefully received.
Edit: What I'm specifically after is how to manage the multiple environments within the Azure Portal. I can deploy all the other components of my UAT environment but I'm stuck on the mobile service.
I am not asking for a way for my applications to switch config files or to migrate data between databases. Does anyone have any experience of running azure applications with multiple components where they ran multiple mobile services?
Do you use a Version Control? For me, you just need to create branches to separate the 'UAT' and 'dev' versions.
About the databases:
You can use web.config transformations to switch the connection string between your databases.
http://msdn.microsoft.com/en-us/library/dd465326.aspx
How do I use Web.Config transform on my connection strings?
=================================================================================
Update:
Ok, now I understood what you want.
Create your two versions of mobile services:
1-Log in Windows Azure Management Portal (http://manage.windowsazure.com)
2-Create your test mobile services (if you already have then, skip this step):
2.1- New -> Compute -> Mobile Services
2.2- Url - MyMobileServicesTest
2.3- Database -> Create a new (test db).
3-Create your production mobile services (if you already have then, skip this step):
2.1- New -> Compute -> Mobile Services
2.2- Url - MyMobileServicesProduction
2.3- Database -> Create a new (production db).
Right now, you have two different versions.
Using Windows Azure SDK:
//public static MobileServiceClient MobileService = new MobileServiceClient(
// "AppUrl",
// "AppKey"
//);
Pay attention: AppUrl will be "MyMobileServicesTest.azure-mobile.net/" or "MyMobileServicesProduction.azure-mobile.net/". The app key, each environment will have it's own. You can store this settings in a config file and switch according to what you are doing.
More information:
http://www.windowsazure.com/en-us/develop/mobile/tutorials/get-started-with-data-dotnet/
Multiple mobile services can share the same database. You only need to specify the same schema name in web.config in each mobile service:
<appSettings>
<add key="MS_MobileServiceName" value="MyAppName" />
</appSettings>
Updated:
The setting above only works in localhost, but not after publishing to live.
Need to do the following trick in order to make it work. Just hard code the schema name into function OnModelCreating. This way the database schema name will not depend on the mobile service name any more:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
string schema = "MyAppName"; // ServiceSettingsDictionary.GetSchemaName();
if (!string.IsNullOrEmpty(schema))
{
modelBuilder.HasDefaultSchema(schema);
}
modelBuilder.Conventions.Add(
new AttributeToColumnAnnotationConvention<TableColumnAttribute, string>(
"ServiceTableColumn", (property, attributes) => attributes.Single().ColumnType.ToString()));
}
Related
I have to use SQL Server with Flutter and I don't have another database option because my client has it. I was looking for packages but I only found a package that doesn't run on mobile. Is there any option to do that without web services or api?
The first thing that you need to consider is that there is no immediate and extremely effective solution and you have to decide what frameworks and tools to be used. And as mentioned in the comment that the market for this scenario is very small. But there are some ways that you can handle this.
Remote storage sample solution:
Here is a basic example of how you should implement this. It was also cited in this SO post:
Client application
The client application can be any application the user typically uses.
Some examples:
Mobile app (written in native, Dart, Xamarin, ...)
Desktop app (Electron, WPF, ...)
Website app (Angular, React, Vue, ...)
API
The API is there to retrieve data, and change data. But It will also
handle authentication, authorization, logging, doing business logic
Database
Your API will then execute queries, inserts, updates, deletes, execute
stored procedures on the Database of your choice. In your example SQL
Server.
There are many possibilities on how to set this up, depending on your
skills, knowledge of frameworks, how you want to deploy things.
How you want to deploy this will limit your choices as well. For your
API:
Serverless API (Via Azure Functions, AWS Lambda)
Cloud Website (Azure Web Apps)
Website hosted on premise
Docker container
In real life scenarios this often gets more complex with Firewalls,
Application Gateways, Virtual networks, clusters.
You can install a SQLServerSocket on your server:
https://github.com/nippur72/SqlServerSocket
Install and execute SqlServerSocket.exe in the background on the server machine where SQL Server is installed.
Also, you need a client:
https://github.com/nippur72/SqlServerSocket/tree/master/DartClient
And you can try some connections and queries directly to your DDBB:
// creates a connection
var conn = new
SqlConnection("SERVER=localhost;Database=mydb;Trusted_connection=yes");
// open connection
await conn.open();
// runs a query returning a single value
var howmany = await conn.queryValue("SELECT COUNT(*) FROM Customers");
// runs a query returning a single row
var myFirstCustomer = await conn.querySingle("SELECT name,age FROM Custormers");
print(myFirstCustomer["name"]);
// runs a query returning all rows
var customers = await conn.query("SELECT TOP 10 name,age FROM Custormers");
for(var customer in customers)
{
print(customer["name"]);
}
// execute a command, returning the number of rows affected
var n = await conn.execute("UPDATE Customers SET age=0");
print("zeroed $n customers");
// disconnect
await conn.close();
so I got my Identity Server project up and running, and am setting up my project to publish. Now, when I define my client in the config for IS4, I suppose I will have to set my redirect urls to my publish domain, something like this:
new Client{
...
RedirectUris = { "localhost:5002/signin-oidc", "myclient.com/signin-oidc" }
...
}
Is including the localhost and domain the right way to do this?
I am thinking it would be ok since an attacker would have to have my client secret in order to login. Or is it better to set up two separate clients (eg. 'client' and 'client_local'), and request the appropriate client at startup?
There are two ways:
1) Use Configuration File: You can store the clients in a JSON file and load them during startup. Use different JSON files for different environments.
Example. clients.Development.json for Development and clients.Production.json in Production environment; However, The clients will be In Memory Clients and any changes in clients configuration will require a reboot of your application.
2) Use Persistent Storage: Use a database server to store configuration and operational data. A local database for development and a database for production use.
See this docs, The example uses Entity Framework for persistent storage but you're bound to Entity Framework or any ORM. You can opt to write your own Data Access Layer for IdentityServer. This will allow you to change client configurations without restarting your application as the data will be retrieved from a database.
I am migrating my existing deployed App from Parse to another server. There are about 1k users already logged onto the existing app. How can I smoothly get them on the new app (with new UI anddifferent backend) without making them login again with a new/same password? What's the best way to do this?
I'm not sure to understand, but if you want to migrate your parse database to another server without downtime it's simple :
Prepare your server (a lot of solutions exist : Mlab, AWS)
When your mongoDB is ready, get your mongodb url :
mongodb://MONGO_USER:PASSWORD#52.51.73.48:27017/parse
and go to parse dashboard -> Your App -> App settings -> general -> Migrate Database (somethink like that) and specify your mongoDB url
Parse copy the database and start to use your database instead the Parse database. No downtime, no data changed, no client config changes.
After this operation, you have all your time for migrate the parse api to your own server.
I have an ADF application module and I have it configured to use a JNDI datasource (e.g., JNDI name = jdbc/ORCL).
That all works fine, but when I try to test my Application Module through the integrated tester in JDeveloper (i.e., run the application module directly instead of running a page), it cannot find the JNDI data source, even if my integrated Weblogic Server is started.
Is this just a drawback of using JNDI: that you cannot use the integrated application module tester anymore? Or is there a way to configure JDeveloper to make this all work together (JNDI + integrated AM tester)?
You should make use of the default JDBC url, i.e. java:comp/env/jdbc/ORCL instead of using the short form jdbc/ORCL. Many features of JDeveloper rely on the full url to work. For example, even if you don't manually create the datasource on your Integrated WebLogic Server, you still can right-click and run a page to test because behind the scene, JDeveloper automatically create a temporary datasource with that name to run the application.
When you deploy your application to an actual standalone server, the application will automatically trim the java:comp/env/ portion of the full url and look for the datasource with the name jdbc/ORCL. You don't need to shorten it yourself :).
I would like to accesss the sitecore DB and items from console application like
Sitecore.Data.Database db = Sitecore.Context.Database
or
Sitecore.Data.Database db = Sitecore.Data.Database.GetDatabase("master")
how do I configure and setup my console application to access the DB as above?
Thanks Everyone for the suggestion, I am really interested in config changes, I used webservice, but it has very limited methods. For example, if I would like create an Item with the template and insert the item with prepopulated value, there is no such option. The reason I am looking for the console apporach is I would like to import the contents from XML or excel sheet and push those to the sitecore tree, eventually use the scheduled task to run the console app periodically. I do not want to copy the entire web.config and app_config. If anyone has already done this, could you please post your steps and necessary config changes?
You have two options I think:
1) Import the Sitecore bits of a website's web.config into your console application's app.config, so that the Sitecore API "just works"
I'm sure I read a blog post about this, but I can't find the reference right now. (I will have another look) But I think the simple but long winded approach is to copy all of the <sitecore/> element and all the separate files it references. I'm fairly sure you can whittle this down to a subset of the config required for data access with a bit of thinking.
2) Don't use the Sitecore API directly, connect to a web service that exposes access to it remotely.
There are a few of these that already exist. Sitecore itself exposes one, Sitecore Rocks has one, and Hedgehog TDS has one too. And you can always write your own (since any web service running inside the Sitecore ASP.Net app can make database calls and report values back and forth - just remember to consider security if this web service might end up exposed externally for any reason)
John West links to some relevant stuff here:
http://www.sitecore.net/Learn/Blogs/Technical-Blogs/John-West-Sitecore-Blog/Posts/2013/09/Getting-Data-Out-of-the-Sitecore-ASPNET-CMS.aspx
-- Edited to add --
I've not found the blog post I remember. But I came across this SO thread:
Accessing Sitecore API from a CLI tool
which refers to this blog post:
http://www.experimentsincode.com/?p=232
which I think gives the info you'll need for option 1.
(And it reminds me that, of course, when you copy the config stuff you have to copy the Sitecore binaries into your app's folder as well)
I would just like to expand on #JermDavis' post and note that Sitecore isn't a big fan of being accessed when not in a web application. However, if you still want to do this, you will need to make sure that you have all of the necessary configuration settings from the web.config and App_Config of your site in your console application's app.config file.
Moreover, you will never be able to call Sitecore.Context in a console application, as the Sitecore Context sits on top of the HttpContext which means that it must be an application and have a valid request for you to use it. What you are looking for is something more along the lines of Sitecore.Configuration.Factory.GetDatabase("master").
Good luck and happy coding :)
This sounds like a job for the Sitecore Item Web API. I use the Sitecore Item Web API whenever I need to access Sitecore data from the master database outside the context of the Content Management server or outside of the context of the Sitecore application. The Web API definitely does not allow you to do everything that the standard Sitecore API does but it can act as a good base and I now extend upon the Web API instead of writing my own custom web services whenever possible.
Thanks to JemDavis's advise.
After I copied the configuration and made changes to config section to get rid of conflicts. I copied almost all of Sitrecore, analytics and lucene dlls, it worked great.
Only thing you have to remember is, copy the app_config folder to the same location where your dlls are.
Thanks again JemDavis....