MobileServiceTable.InsertAsync ZUMO-API-VERSION Error - c#

I'm trying to migration Azure Mobile Service to Azure App Services. In C# I'm using MobileServiceClient.GetTable to get a MobileServiceTable object. With this I try to insert an object using MobileServiceTable.InsertAsync.
After upgrading I am getting the error-
An invalid API version was specified in the request, this request needs to specify a ZUMO-API-VERSION of 2.0.0
I understand the error, but I don't know how to update the request headers to add this. Is this possible?

You need to update the SDK. Remove the WindowsAzure.MobileServices SDK and add the Microsoft.Azure.Mobile.Client SDK. If you use offline-sync, then replace the equivalent SQLiteStore packages as well.
For more information, see https://learn.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-net-upgrading-from-mobile-services

Related

Unable to use swagger 3.0.1 in Azure logic apps

When I try to add a swagger endpoint from my logic app it fails even though it successfully fetches the content.
Failed to fetch swagger with error message: Invalid response: {"openapi":"3.0.1","info":{"title":"My Swagger API"
...
...
...} Ensure you have CORS enabled on the endpoint and are calling a valid HTTPS endpoint.
I tried trouble-shooting CORS in every possible way, but in the end what got it working was forcing version 2.0 of swagger:
app.UseSwagger(o => o.SerializeAsV2 = true);
Has anyone gotten swagger 3.x to work with Logic Apps?
Okay, I have replicated the issue on my end and I have observed the same issue with the my open API.
The key word to notice here is "OpenAPI" specification. This is not a swagger specification. I found the official document which clearly says Swagger(not OpenAPI). Please refer Call REST endpoints by using Azure Logic Apps
You can try work around for this by creating custom connector

Azure DocumentDB .NET SDK does not contains all HTTP Status Codes

When you look at the document of HTTP status codes that CosmosDB REST API returns, there are some status codes that does not exist in .NET SDK.
HTTP Status Codes for Azure Cosmos DB
Suppose, status code 449, does not exist in the HttpStatusCode(System.Net).
"449 Retry With"
The operation encountered a transient error.
This only occurs on write operations.
It is safe to retry the operation.
How do you handle this sort of status code using the Azure DocDb's .NET client SDK?
Or does the SDK handles these by itself?
As you said, if we check the StatusCode property (that is nullable) of DocumentClientException, we will find that status code 449 does not exist in the System.Net.HttpStatusCode.
After check the source of Azure DocumentDB .NET SDK, the SDK seems handle these by itself.

Azure Resource Manager - Get all the resources of a resource group

Yesterday, I was using this line of code with the version 1.5.0-preview of Microsoft.Azure.Management.ResourceManager :
var listResources =
ResourceManagementClient.ResourceGroups.ListResources(resourceGroup.Name);
Today, I have updated to version 1.6.0-preview but the fonction doesn't seem to be available anymore. Is there another way to get the list of the resources contained in a resource group ?
Now the SDK is still preview version. In the 1.6.0 preview version. It should use following code.
var listResources = resourceManagementClient.Resources.ListByResourceGroup("ResourceGroup Name");
But it still can't work correctly on my side because the API-Version is api-version=2017-05-10. I catch the request with fiddler.
The code you mentioned that use API-version
var listResources =
ResourceManagementClient.ResourceGroups.ListResources(resourceGroup.Name);
Note : Please still use 1.5.0-preview instead of 1.6.0-preview currently if you want get group resource, or give your feedback to azure sdk team . Or you can use REST API directly

Google Datastore authentication issue - C#

I'm trying to connect to the Google Datastore on my account with service account credentials file (which I've created according to the documentation), but I'm encountering with authentication error while trying to insert an entity:
Grpc.Core.RpcException: Status(StatusCode=Unauthenticated,
Detail="Exception occured in metadata credentials plugin.")
My code is:
var db = DatastoreDb.Create("myprojectid");
Entity entity = new Entity{
Key = db.CreateKeyFactory("mykindname").CreateIncompleteKey()
};
var keys = await db.InsertAsync(new[] { entity });
The GOOGLE_APPLICATION_CREDENTIALS variable refers to the credentials file and when calling GoogleCredential.GetApplicationDefaultAsync() to see if the credentials object is valid it indeed looks good...
I saw some earlier examples which used the GetApplicationDefaultAsync function togehether with some DatastoreService object - but I couldn't find the DatastoreService object (probably it was there in old versions...) in the latest .Net API: Google.Cloud.Datastore.V1
Notice that I don't want to use the other authenticaiton methods:
1) Using the gcloud cli.
2) Running from Google environment (app engine for example).
Any idea how to solve this?
After the great help of Jon Skeet the issue was solved.
The authentication issues can occur if you don't reference all the required Datastore dlls. Make sure that all the dlls are referenced on the project that are running the calls to the Datastore.
I've added the Google Datastore lib via the NuGet to my test project and everything worked!
Notice that in such cases it is recommended to enable gRPC logging. `(For exmaple: GrpcEnvironment.SetLogger(new ConsoleLogger()), there you'll probably see if there were issues loading several dlls...
Authentication can be broken if your system clock is significantly incorrect. Check your system time, and fix it if necessary, then try authenticating against Datastore again.

AttachUserPolicy from .NET SDK

I'm creating a new AWS user using the SDK. I'm able to create it, and retrieve the Access and Secret keys just fine. But I also want to attach an existing policy to the new user, presumably with this command
http://docs.aws.amazon.com/IAM/latest/APIReference/API_AttachUserPolicy.html
Does this method exist somewhere within the .NET SDK? I can't find it after a maddening amount of searching.
You're looking for AmazonIdentityManagementServiceClient.AttachUserPolicy.
Signature:
public virtual AttachUserPolicyResponse AttachUserPolicy(AttachUserPolicyRequest request)
Request:
Amazon.IdentityManagement.Model.AttachUserPolicyRequest
Response:
Amazon.IdentityManagement.Model.AttachUserPolicyResponse
There's also an async version, if you're interested.

Categories