Code 302 when trying to post to Azure SQL database - c#

I am working on an Android app which uses Microsoft Azure Mobile App Service.
My app is based on the example code at: https://learn.microsoft.com/en-us/previous-versions/azure/app-service-mobile/app-service-mobile-android-get-started
After adding authentication (https://learn.microsoft.com/en-us/previous-versions/azure/app-service-mobile/app-service-mobile-android-get-started-users), I am getting a strange issue with post or update requests to my SQL database.
When I try to post to my MobileServiceTable object in Android, the process completes immediately with no error message but the table does not contain the object I've added.
Digging into the issue on Azure Portal, I found that post requests complete "successfully" with code 302 and do not ever access my SQL database. That is, the request is seen by the server and terminates with code 302 without ever accessing the database.

Refer the below post
How to fix Server Status Code: 302 Found by SQL Inject Me Firefox Addon
Seems like your connection attempt is not secure enough.
You may want to Use azure AD to register and channel through that and see if that works for you.
Also check sql paas firewall settings to make sure connection is allowed

Related

Getting error 500 in my Azure apim while trying to connect to RavenDB

Locally, my api is working fine but in the Azure apim when i add these lines in the controller (to access my RavenDB) i get an internal server error 500.
Here is the startup configuration:
i'm also using AzureKeyVault to get the certificate to access my RavenDB.
I added the apim's IP in the allowed IPs of RavenDB Cloud, without success.
The question is, how can i fix that ?
Feel free to ask in case you need more informations.
EDIT
I recently had more information about the error 500
Problem solved
Waiting for #TinyWang to write his anwser instead of a comment.
You can find the things that worked for me in the comments.
To sum up here and end this case:
According to the error message, we can see it comes from the error route in the server but not something wrong with azure apim. We can use kudu for azure web app to check the folder structure of server.
And as op said in the comment above, he chose to uploaded the certificate to the server.
I uploaded the certificate in the App Service of Azure using kudu in
the C:\home\site\wwwroot> - Finally, i changed the x509KeyStorageFlags
from DefaultKeySet to MachineKeySet

Calling another API within an API gets timeout

I have quite a stupid question, but the environment I am working in forced me to use this solution.
We have a WebAPI providing data to an angular frontend.
For authentication we use an Azure AD B2C Tenant.
User sign into frontend and start to receive Data from the API as normal as it should be.
But: The users have to get different data regarding Groups in the Azure AD. So e.g. UserA is in GroupB and has to get other data than UserX who is in GroupY.
So within the api I need to verify that the Users are in the groups for the data they are requesting.
Normaly I would use Microsoft.Graph to communicate with Azure from the API. But as this is a special network I need to go through a proxiy using different User-Agents. This is all working fine when I call my Code from an executable.
But when I call the same Methods within the API I get a timeout and no Data from Azure. I tested the same routines with other APIs and there is no timeout.
I already checked the request Headers to verify that there is no mixed up information or anything, but everything looks like as it should be.
Has anyone had similar Problems, or has a solution regarding the User-Agent when creating the Request Token for API?
Thank you!
Cheers!
Case closed. The proxy denied the request and caused the timeout when called by the api. Don't ask my why. The same code and build is running on the deployed environement with no issues. Who would have thought that there would be the day when I say "But it wasn't working on my machine..."
Cheers!

Programmatically authenticate with Azure AD for Application Proxy

I have an on-premise hosted WCF service with REST endpoint which is configured for Anonymous authentication only in IIS. I installed and configured Azure App proxy connector on the server. I am able to contact the service fine with Pass-through authentication, but struggling to authenticate from a console app when Azure AD is chosen as security mechanism. I know I could have pass-through in Azure and turn on for example windows authentication in IIS, but this is unfortunately not an option in this case.
Using a browser, I am able to access the application fine, don't even need to enter credentials, our on-premise AD is connected and synchronized with Azure AD.
I followed this walk-through despite it is not regarding application proxy, and reusing parts of code I am able to get the Access Token for my application, but when I run the http request with Authorization header I don't get the result of service operation.
Using Fiddler I can note the following:
I get http 302 (Found). I can see my Authorization header in request, and in response I get a cookie AzureAppProxyAnalyticCookie
That is followed with http 200 to login.microsoftonline.com
Example I provided link for above works fine so it is clear that I am doing something wrong. Why is Authorization header not accepted and why am I being redirected to logon page?
Thanks in advance
This is working for another service, have no idea what was wrong with the first one, but suspecting something with DNS on local server. Won't be spending more time on this, point is that I shouldn't have experienced the redirect at all, although browser handled it and managed to get me authenticated.

Microsoft Bot Framework Unauthorized error

I am getting started with the Microsoft Bot Framework, and tried running the very basic app from the getting started tutorial using the emulator.
When I send the message, I get the error : 401 Unauthorized
Things I have done
I have corrected the URL in the emulator to match the correct URL of the app.
Have deleted the APP ID and APP password from the emulator fields.
I assume I don't need to worry about https yet, since I am running locally (localhost).
Microsoft Bot Framework Document says that when you're running in the localhost add your localhost with the correct port and ask you to keep empty in the app id and the app pass.
But if you have added you your app id and and pass to web.config file, make sure to add them to your emulator as well. Otherwise you will get 401 - Unauthorized error.

ASP.Net Synchronization with Quickbooks Onine using Intuit Services

I have a quick books sandbox account and a trial database, i want to connect my asp.net application with its database using web services.
Requirement is whenever we insert anything into our database, it should also be inserted into Quickbooks database.
I have studied Intuit SDK and as per their flow, we have to authorize our request using oAuth process, whenever we need to do any action.
My requirement is very simple, i have a service createItem() in my application deployed on an online server, if this services is called, it should also create that item on quickbooks online database. I want this process to be generic, services will work automatically as per actions. Is there any way? I just want that there should be no oAuth/Redirection.
Please suggest some solution
You are misunderstanding how OAuth works.
The OAuth redirections only occurs once. Once you have gone through the OAuth flow once, you never have to go through it again. Ever.
The purpose of the OAuth redirection is to securely supply your website with a set of tokens that it can use to connect in the future. So once you have those tokens, you never have to redirect someone ever again, and the process can be fully automated beyond that.
What you're trying to do is perfectly possible.

Categories

Resources