在使用传统的Azure Mobile服务时,您曾经获得一个密钥以及移动服务应用的URL。此密钥还用于探索后端站点上的API和&用作密码。
使用新的Azure App服务,您需要设置移动服务客户端,如下所示的URL
private static readonly MobileServiceClient MobileService = new MobileServiceClient("https://thecityapp.club");
没有密钥* Azure Mobile服务可用的第二个参数。什么现在用作密码来浏览网络上的API?
答案 0 :(得分:9)
Supreet,
使用App Services / Mobile Apps,不再使用/需要应用程序密钥,这就是门户网站上不再可用的原因。您可以使用上面的代码实例化客户端,并开始使用没有该信息的服务API。
有关身份验证,请参阅此文档:https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-windows-store-dotnet-get-started-users/
我希望这会有所帮助。
答案 1 :(得分:1)
如果需要,您可以为Azure移动应用程序实施应用程序密钥。
您可以为Azure移动服务设置Azure移动应用程序的应用程序密钥。
| zumo-api-key | 键入您的API密钥 |
| MS_SkipVersionCheck |真的|
// ----------------------------------------------------------------------------
// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
// ----------------------------------------------------------------------------
module.exports = function (req, res, next) {
// Validate zumo-api-key header against environment variable.
// The header could also be validated against config setting, etc
var apiKey = process.env['zumo-api-key'];
if (apiKey && req.get('zumo-api-key') != apiKey)
return res.status(401).send('This operation requires a valid api key');
else
return next();
}
[sampleAPI.js]
var validateApiKey = require('../validateApiKey');
module.exports = {
"get": [validateApiKey, function(request, response, next)
{
response.send(
{
message: "post"
});
}],
"post": [validateApiKey, function(request, response, next)
{
response.send(
{
message: "post"
});
}]
};
[sampleAPI.json]
{
"get": {
"access": "anonymous"
},
"post": {
"access": "anonymous"
},
"put": {
"access": "anonymous"
},
"patch": {
"access": "anonymous"
},
"delete": {
"access": "anonymous"
}
}
不要忘记将权限更改为" Anonymous"
[sampleTable.js]
var azureMobileApps = require('azure-mobile-apps'),
validateApiKey = require('../validateApiKey');
// Create a new table definition
var table = azureMobileApps.table();
// Access should be anonymous so that unauthenticated users are not rejected
// before our custom validateApiKey middleware runs.
table.access = 'anonymous';
// validate api key header prior to execution of any table operation
table.use(validateApiKey, table.execute);
// to require api key authentication for only one operation (in this case insert)
// instead of table.use(validateApiKey, table.execute) use:
// table.insert.use(validateApiKey, table.operation);
module.exports = table;
[sampleTable.json]
{
"softDelete" : true,
"autoIncrement": false,
"insert": {
"access": "anonymous"
},
"update": {
"access": "anonymous"
},
"delete": {
"access": "anonymous"
},
"read": {
"access": "anonymous"
},
"undelete": {
"access": "anonymous"
}
}
不要忘记将权限更改为" Anonymous"
不要忘记在调用Azure Mobile / Web App时添加标题。
此外,您可以在Github上的此存储库中查看更多内容。