Update the example in README.md
This commit is contained in:
Родитель
072ac1a151
Коммит
0235d292b6
|
@ -15,15 +15,15 @@ namespace ARMClient.Library.Runner
|
|||
|
||||
private static async Task Run()
|
||||
{
|
||||
var csmClient = ARMClient.GetDynamicClient(apiVersion: "2014-04-01", authHelper: new AuthHelper(AzureEnvironments.Prod));
|
||||
var armClient = ARMClient.GetDynamicClient(apiVersion: "2014-04-01", authHelper: new AuthHelper(AzureEnvironments.Prod));
|
||||
|
||||
var resrouceGroups = await csmClient.Subscriptions["{subscriptionId}"]
|
||||
var resrouceGroups = await armClient.Subscriptions["{subscriptionId}"]
|
||||
.ResourceGroups
|
||||
.GetAsync<JObject>();
|
||||
|
||||
foreach (var resrouceGroup in resrouceGroups.value)
|
||||
{
|
||||
var sites = (Site[])await csmClient.Subscriptions["{subscriptionId}"]
|
||||
var sites = (Site[])await armClient.Subscriptions["{subscriptionId}"]
|
||||
.ResourceGroups[resrouceGroup.name]
|
||||
.Providers["Microsoft.Web"]
|
||||
.Sites
|
||||
|
|
34
README.md
34
README.md
|
@ -8,7 +8,7 @@ Check out [wiki](https://github.com/projectkudu/ARMClient/wiki) for more details
|
|||
Login and get tokens
|
||||
ARMClient.exe login ([Prod|Current|Dogfood|Next])
|
||||
|
||||
Call CSM api
|
||||
Call ARM api
|
||||
ARMClient.exe [get|post|put|delete] [url] ([user])
|
||||
|
||||
Copy token to clipboard
|
||||
|
@ -31,35 +31,47 @@ Example
|
|||
=========
|
||||
|
||||
```C#
|
||||
//This example prints the names of all resrouceGroups that don't have sites under a certain subscription
|
||||
// This example prints the names of all resrouceGroups that don't
|
||||
// have sites under a certain subscription
|
||||
|
||||
private static async Task Run()
|
||||
{
|
||||
var csmClient = ARMClient.GetDynamicClient(apiVersion: "2014-04-01", authHelper: new AuthHelper(AzureEnvironments.Prod));
|
||||
var armClient = ARMClient.GetDynamicClient(apiVersion: "2014-04-01",
|
||||
authHelper: new AuthHelper(AzureEnvironments.Prod));
|
||||
|
||||
var resrouceGroups = await csmClient.Subscriptions["{subscriptionId}"]
|
||||
var resrouceGroups = await armClient.Subscriptions["{subscriptionId}"]
|
||||
.ResourceGroups
|
||||
.GetAsync<JObject>();
|
||||
|
||||
foreach (var resrouceGroup in resrouceGroups.value)
|
||||
{
|
||||
var sites = (Site[])await csmClient.Subscriptions["{subscriptionId}"]
|
||||
.ResourceGroups[resrouceGroup.name]
|
||||
.Providers["Microsoft.Web"]
|
||||
.Sites
|
||||
.GetAsync<Site[]>();
|
||||
var sites = (Site[]) await armClient.Subscriptions["{subscriptionId}"]
|
||||
.ResourceGroups[resrouceGroup.name]
|
||||
.Providers["Microsoft.Web"]
|
||||
.Sites
|
||||
.GetAsync<Site[]>();
|
||||
|
||||
if (sites.Length == 0)
|
||||
{
|
||||
Console.WriteLine("ResrouceGroup: {0} Doesn't contain any websites!", resrouceGroup.name);
|
||||
Console.WriteLine("ResrouceGroup: {0} Doesn't contain any websites!",
|
||||
resrouceGroup.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class Site
|
||||
{
|
||||
public string location { get; set; }
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
The make up of the call is similar to the way CSM Urls are constructed. For example if the Url looks like this
|
||||
`https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{webSiteName}/slots/{slotName}/config/web`
|
||||
|
||||
then the `DynamicARMClient` will be `.Subscriptions["{subscriptionId}"].ResourceGroups["{resourceGroupName}"].Providers["Microsoft.Web"].Sites["{webSiteName}"].Slots["{slotName}"].Config["web"]`
|
||||
then the `ARMClient` call will be `.Subscriptions["{subscriptionId}"].ResourceGroups["{resourceGroupName}"].Providers["Microsoft.Web"].Sites["{webSiteName}"].Slots["{slotName}"].Config["web"]`
|
||||
|
||||
Note: Capitalization is optional `.Subscriptions[""]` == `.subscription[""]` also the distinction between `[]` and `.` is also optional `.Config["web"]` == `.Config.Web`.
|
||||
However, some names like subscription Ids which are usually GUIDs are not valid C# identifiers so you will have to use the indexer notation.
|
||||
|
|
Загрузка…
Ссылка в новой задаче