简体   繁体   English

将Azure移动服务连接到UWP

[英]Connecting Azure Mobile Services to UWP

I have created a Mobile service in Azure, and connected an SQL database in it. 我已经在Azure中创建了移动服务,并在其中连接了SQL数据库。 I installed the required Nuget Package Microsoft.Azure.Mobile.Client , and i tried Microsoft.WindowsAzure.MobileServices , and inserted this code in my App.xaml.cs: 我安装了必需的Nuget软件包Microsoft.Azure.Mobile.Client ,并尝试了Microsoft.WindowsAzure.MobileServices ,并将此代码插入到App.xaml.cs中:

public static MobileServiceClient MobileService = new MobileServiceClient("https://sqlbackend.azurewebsites.net");

The Problem is: When i come to connect an azure mobile service to the project, they say it is not supported. 问题是:当我将azure移动服务连接到该项目时,他们说它不受支持。

Is there any way to connect my project to an azure mobile service? 有什么方法可以将我的项目连接到Azure移动服务?

连接服务面板

What kind of project the client is? 客户是什么样的项目?

If it's Azure Mobile Service or Azure Mobile App itself, no need to add a connected service, just right-click the project,select Publish ,import the web app publish settings file and publish to Azure. 如果是Azure移动服务Azure移动应用程序本身,则无需添加连接的服务,只需右键单击该项目,选择“ 发布” ,导入Web应用程序的发布设置文件,然后发布到Azure。

If it's Windows Phone WebView App or others supported by tooling gesture, the configure button will be enabled and the code in App.xaml.cs should be: 如果是Windows Phone WebView App或其他受工具手势支持的应用程序 ,则将启用配置按钮,并且App.xaml.cs的代码应为:

public static MobileServiceClient MobileService = new MobileServiceClient ("https://sqlbackend.azurewebsites.net", "XXXX-APPLICATION-KEY-XXXXX"); public static MobileServiceClient MobileService = new MobileServiceClient ("https://sqlbackend.azurewebsites.net", "XXXX-APPLICATION-KEY-XXXXX");

The second parameter is application key which is generated here: 第二个参数是在此处生成的应用程序密钥:

在此处输入图片说明

PS: The code above and adding connected service(Azure Mobile Service) reach the same result and no need to use both at the same time. PS:上面的代码和添加连接的服务(Azure移动服务)达到相同的结果,无需同时使用两者。

You are using the old Azure Mobile Services client. 您正在使用旧的Azure移动服务客户端。

Links for you: 您的链接:

When you convert to using Microsoft.WindowsAzure.MobileServices, it will inject the right header and you will not get the Unsupported message. 当您转换为使用Microsoft.WindowsAzure.MobileServices时,它将注入正确的标题,并且不会收到不支持的消息。

After reviewing your question again, you need to match up the type in the server with the type in the client. 再次查看问题后,您需要将服务器中的类型与客户端中的类型进行匹配。 If you have created an Azure Mobile Service, then your client should be Microsoft.Azure.Mobile.Client. 如果创建了Azure移动服务,则客户端应为Microsoft.Azure.Mobile.Client。 If you have created an Azure App Service Mobile App, then your client should be Microsoft.WindowsAzure.Mobile.Client - the links I provided were for Azure Mobile Apps (not Services in the client). 如果您已经创建了Azure App Service移动应用程序,则您的客户端应该是Microsoft.WindowsAzure.Mobile.Client-我提供的链接是针对Azure Mobile Apps(而不是客户端中的服务)的。 I recommend Azure Mobile Apps (which can be considered the latest generation of such). 我建议使用Azure移动应用程序(可以将其视为此类的最新一代)。 Tutorials are available on azure.com 教程可在azure.com上找到

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM