Where is the key in the new Azure App service?

When using the classic Azure Mobile services, you used the key along with the URL of your Mobile Service application. This key was also used to learn the APIs on your base site and was used as a password.

When using the new Azure App services that you need to set up the mobile service client, this is the URL as shown below.

private static readonly MobileServiceClient MobileService = new MobileServiceClient("https://thecityapp.club"); 

There is no key * for the second parameter available for Azure Mobile Services. What is now used as a password to learn the API on the Internet?

+7
azure azure-mobile-services azure-app-service-envrmnt
source share
2 answers

Supreet

In App / Mobile Apps, the application key is no longer used / required, so it is no longer available on the portal. You can create a client instance with the above code and start using the service APIs without this information.

For authentication, refer to this documentation: https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-windows-store-dotnet-get-started-users/

Hope this helps.

+9
source share

You can implement the Application Key for the Azure Mobile App if you want.

You can set the application key for your Azure Mobile App, such as Azure Mobile Services.

1. Open the application settings on Azure Mobile Application

2. Scroll down to the application settings. Add these two lines.

| zumo-api-key | TYPE YOUR API KEY |

| MS_SkipVersionCheck | True |

3. Then click "Save"

4. Open Utility Editor

5. Create a file in the wwwroot main folder

6. Name your file as validateApiKey.js

 // ---------------------------------------------------------------------------- // 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(); } 

6. Update the API script as,

[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" } } 

Remember to change permissions to "Anonymous"

6. Update the script as table,

[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" } } 

Remember to change permissions to "Anonymous"

7. Done!

Remember to add a title when calling Azure Mobile / Web App.

You can also see more from this repository on Github.

https://github.com/thisisfatih/applicationKeyAzure/

+1
source share

All Articles