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();
Related
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.
I am trying to find the relevant C# API for Powershell's Get-ADDomain. I don't want to invoke the Powershell commands in C#. Instead I am looking for one or multiple C# API with which I can retrieve all the values.
Get-ADDomain -Identity user.com
I tried searching through DOT net API's but couldn't find a relevant one. I found Domain class. But I am not sure how to get all the info using GetDomain
System.DirectoryServices.ActiveDirectory.Domain.GetDomain(DirectoryContext)
Can someone help in finding the relevant C# API that I can use to retrieve all the values of Get-ADDomain?
If you want to get the domain info for the domain that the computer is a member of or the domain that the user running the script is a member of (if they are the same, flip a coin), you can use a different method on the same class you're already trying to use:
For computer's domain:
[System.DirectoryServices.ActiveDirectory.Domain]::GetComputerDomain()
For user's domain:
[System.DirectoryServices.ActiveDirectory.Domain]::GetUserDomain()
...yes it's in PowerShell but just invoke the either of the two methods above and they internally pass in the DirectoryContext relative to what you're looking for.
You might also get more information you're looking for by going up to the forest and retrieving that info as well:
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
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."
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.
I am trying to connect to Magento API using C#. I am using Magento Go service and from what I've read I am able to use their API - I hope I am not wrong here. So here is what I did:
I added a Service Reference to http://mydomain.gostorego.com/api/v2_soap?wsdl=1, and just adding a service worked fine. Now I created a test class with GetStuff() method, which looks like this:
using ww.Feeds.MagnetoGoService;
public static string GetStuff()
{
MagnetoGoService.Mage_Api_Model_Server_V2_HandlerPortTypeClient s = new MagnetoGoService.Mage_Api_Model_Server_V2_HandlerPortTypeClient();
var login = s.login("username here", "key here");
return login.ToString();
}
When I run the program I get an error in first line saying:
Could not find default endpoint element that references contract 'MagnetoGoService.Mage_Api_Model_Server_V2_HandlerPortType' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
Any ideas what this may be? Do I have to set something up in my Magento Go settings? Or maybe using Magento Go is not allowing API access?
Thanks a lot.
Forget SOAP with c# you will pull your hair out. Download Charls Cook's xml-rpc api libary for c# and use the xml-rpc method. You won't get all the snazzy intellisense but at least it will work. There's also c# solution from ez.newsletter they released with Cook's library demonstrating how to use 80% of the magento api calls.
Cook's library xml-rpc.net
http://www.xml-rpc.net/
ez.newsletter solution
http://code.google.com/p/csharlibformagexmlrpcapi/
If anyone ever has problems with this, my solution was this:
I used the reference in one project, but I actually called the class and had main program in another project. You need your Service reference to be in each project wherever you're using it. That fixed it! Alternatively you can create a new BasicHttpBinding() and putt all the options from app.config/web.config into that binder, then you don't need to reference to Service everywhere. I hope that helps!