使用Node.js API将Izure应用程序连接到Azure数据库 [英] Connecting ionic azure app to Azure databases using Node.js API

查看:143
本文介绍了使用Node.js API将Izure应用程序连接到Azure数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试将Ionic应用程序连接到Azure SQL数据库时遇到麻烦.这是我的配置:

I'm having troubles trying to connect an Ionic app to an Azure SQL database. Here is my configuration :

-带有" azure-mobile-apps-client "的Ionic应用程序;通过npm安装了软件包.

- An Ionic app,with the "azure-mobile-apps-client" package installed though npm.

-SQL服务器

-数据库,托管在SQL Server上

- A database, hosted on the SQL Server

-一个应用程序服务计划:NodeJS API +数据连接(以数据库为目标)

- An app service plan : NodeJS API + Data Connection (target the database)

在我的Ionic应用程序内部,我正在连接到 https://myapp.azurewebsites.net/ 托管于我的Azure帐户.

Inside my Ionic App, i'm connecting to https://myapp.azurewebsites.net/, hosted with my Azure account.

  constructor(public navCtrl: NavController) {
    this.client = new WindowsAzure.MobileServiceClient("https://myapp.azurewebsites.net/");
    var syncContext = this.client.getSyncContext();
    this.table = this.client.getTable("Contact");
    this.table.read().then((result) => {
      console.log('Result :', result);
    });

当然,它可以与简易表"功能配合使用,但是我想使用我的帐户数据库

Of course, it works fine with the 'Easy Tables' functionnality, but i would like to use a database of my account

问题是我无法将我的应用程序连接到目标数据库:我尝试使用数据连接",并在NodeJS API上进行了所需的配置(在其中定义1个表我的Azure移动应用程序).我还允许所有人(*)

The problem is that i can't connect my app to the targeted database : i tried with a "Data connection", and made the required configuration on the NodeJS API (define 1 table in my Azure Mobile App). I also allowed CORS to all (*)


我不了解如何手动选择数据库,以及是否有可能仅使用一个API就可以选择多个数据库.我的目标是在具有这些数据库的设备上使用实时同步(以及离线同步),而我太长了,无法仅使用 我自己使用http请求编码的Web服务.

I don't understand how i could choose manually my database, and if it could be possible to have multiples, using only one API. My goal is to use real time sync on devices with theses databases (and also offline-sync), and i would be too long to only use a webservice coded by myself using http requests.

我不知道我是否错过了文档中的某些内容,或者我是否不使用创建时所用的azure-mobile-sync.你能帮我吗?非常感谢

I don't know if i missed something on the documentation, or if i'm not using azure-mobile-sync as it is created for. Could you help me with this ? Thanks a lot

推荐答案

https://blogs.msdn.microsoft.com/jpsanders/2016/09/21/execute-transactions-from-azure-mobile-app-api-node-js/.

Try to write all of the logic in a stored procedure and make the Azure SQL Database do the work for you. For more details, you may refer to this document: https://blogs.msdn.microsoft.com/jpsanders/2016/09/21/execute-transactions-from-azure-mobile-app-api-node-js/.

您可以参考以下文档: https://docs.microsoft.com/zh-cn/azure/app-service-mobile/app-service-mobile-offline-data-sync 用于Azure Mobile App中的脱机数据同步.

You may refer to this document: https://docs.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-offline-data-sync for offline data sync in Azure Mobile App.


这篇关于使用Node.js API将Izure应用程序连接到Azure数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆