简体   繁体   中英

Connecting Azure Mobile Services to UWP

I have created a Mobile service in Azure, and connected an SQL database in it. 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:

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.

Is there any way to connect my project to an azure mobile service?

连接服务面板

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.

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:

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.

You are using the old Azure Mobile Services client.

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.

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. 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). I recommend Azure Mobile Apps (which can be considered the latest generation of such). Tutorials are available on azure.com

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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