Access aws IAM Policy JSON file programmatically .Net SDK - c#

I want to access the JSON File programmatically.
In the Management Console, you can find that right here
To be specific, not only do I want to access the managed, but also the custom policies.
Sorry, for not being familiar with the proper terms.

I suggest familiarizing yourself with the AWS SDK for .NET.
You would get a policy object by calling the AmazonIdentityManagementServiceClient.GetPolicy() method. This method requires the policy ARN. Next You would get the policy's versions by calling AmazonIdentityManagementServiceClient.ListPolicyVersions(). Once you have both the policy ARN and the ID of the version you want (you probably just want to pull the ID of the latest version out of the versions list), then you would call AmazonIdentityManagementServiceClient.GetPolicyVersion() to get the actual policy JSON document.
If you don't know the ARN for the policy, or you just want to loop through all policies, you would call the AmazonIdentityManagementServiceClient.ListPolicies() method to get a list of all policies. You mentioned in your question that you want to retrieve both the customer managed and AWS managed policies, which this method does:
"Lists all the managed policies that are available in your AWS
account, including your own customer-defined managed policies and all
AWS managed policies."

Related

Azure Search set disableOrderByHighWaterMarkColumn with .NET C# API

I have a service that manages all of the indexes/indxers I use for Azure Cognitive Search, and within that I am attempting to set disableOrderByHighWaterMarkColumn to true when creating/updating an indexer.
While I do see examples in the official docs for an HTTP request to set that field, I'm not seeing any parameter anywhere (including the Parameters option under the SearchIndexer object) that can be set to update that value.
Does nadisableOrderByHighWaterMarkColumn` through the C# API? I have the latest Azure.Search.Documents package installed.
You would need to add it as a custom key under the SearchIndexer.Parameters.IndexingParametersConfiguration property.
If for some reason that doesn't work as expected, then it is a bug with the .NET SDK that I would suggest you submit as an issue against the official Github repository.

How to call Microsoft Graph Beta API from C#

I tried to get the content of the user's profile picture and I found out that I had to call the Beta version because the current version gives the following error message:
"code": "GetUserPhoto",
"message": "The operation is not supported."
So, I tried to switch to Beta, and here is the code that I wrote in C# to do it, but it doesn't work:
Microsoft.Graph 1.6.2
List<QueryOption> options = new List<QueryOption>
{
new QueryOption("$api-version", "beta")
};
var pictureStream = await graphClient.Me.Photo.Content.Request(options).GetAsync();
I got the same error message.
I tried the same request in the Graph Explorer. The 1.0 doesn't work, but Beta works.
The api-version query parameter is used by the Azure AD Graph API. This is a different API than Microsoft Graph. There is a lot of functional overlap (Azure AD Graph is slowly being migrated over to Microsoft Graph) but they use entirely different entities and calling conventions.
In order to call the /beta endpoint using the Microsoft Graph .NET Client Library, you need to change the BaseUrl of the client:
graphClient.BaseUrl = "https://graph.microsoft.com/beta";
var pictureStream = await graphClient.Me.Photo.Content.Request().GetAsync();
Some important notes about the /beta endpoint:
It isn't supported and isn't suitable for production. So don't do that. Or at least don't tell anyone and don't call Support if it stops working. ;-)
The .NET Client uses objects constructed off the production metadata. This means that any entities, actions or properties that were added in /beta don't exist in the models shipped with the SDK.
The .NET Client will ignore any values returned by Microsoft Graph that it doesn't expect to see. So if an endpoint returns a property that wasn't included in the production metadata (see #2), it will simply be ignored.
So long as you're only using a /beta to gain functionality but still expecting /v1.0 results, it should work okay. Photos for example only look at Exchange in v1.0 but look in both Exchange and Active Directory but still return the same result. In theory this means you should be able to swap /beta for /v1.0 without a problem.
I think you are still calling V1 endpoint. In fact, the Beta endpoint is not currently supported in the Microsoft Graph .NET Client Library. More info here.
There is an official beta client for Graph API now:
https://github.com/microsoftgraph/msgraph-beta-sdk-dotnet

Using Twilio RestClient 5.x on a website's backend

In the previous version (4.x), we were able to initilize a TwilioRestClient instance per request. In that way, we could generate clients to use for accounts and subaccounts.
Is it possible to do the same with the newest version (5.x)?
Twilio Dev Evangelist here.
With the new version of the SDK for C#, there is no need to instantiate the RestClient more than once. You would initialize it by making a call to a static TwilioClient.Init method, passing in your account SID and auth token.
You can alternatively create your own REST client that derives from ITwilioRestClient, but that would totally depend on your use case.
Check out our migration docs here. It provides details on this and other changes for migration scenarios.

EWS - Get Throttling Policy

I need to get the parameter values of Get-ThrottlingPolicy for Exchange 2013. I am looking at getting the values.
Is it possible to get this through EWS API?
I have tried extracting this through powershell from C#. I am not able to find the cmdlet Get-ThrottlingPolicy. What is the solution, what could be wrong. I am new to powershell.
Also can we retrieve the current status - ex current concurrency.
Sadly doesn't look like is possible. The github repo does not appear to contain any reference to throttling.
https://github.com/OfficeDev/ews-managed-api/search?q=throttling

Easiest way to get EC2 instance attributes within the instance itself

Can you guys show me how to retrieve instanceId, dns public name and type of current EC2 instance from where I'm running the code...
I'm playing with DescribeInstanceAttribute(), but it needs to supply the instanceId to the request, and I can't find how to get the id of currently running instance.
There's a much easier method than making a web API call, the .NET SDK.
See the SDK documentation for EC2InstanceMetadata here
For example, if you need InstanceId you can use:
Amazon.Util.EC2InstanceMetadata.InstanceId.ToString();
All the other properties are available in a similar manner.
Note that the SDK used to have Amazon.EC2.Utils - this was deprecated in 2015 and moved to Amazon.Util namespace
There's a webservice that returns machine information. Access
http://169.254.169.254/latest/meta-data/instance-id
To retrieve the instance id
The Instance Metadata Documentation can be handy.
You can also use AWS's Dot Net SDK for example Amazon.EC2.Util.EC2Metadata.InstanceId.ToString();

Categories

Resources