Skip to content

Commit 8c1d946

Browse files
authored
[Automation] Collect examples from azure-sdk-for-net#Azure.ResourceManager.ContainerRegistry_1.4.0
1 parent 59de7c2 commit 8c1d946

File tree

204 files changed

+4570
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

204 files changed

+4570
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using Azure;
2+
using Azure.ResourceManager;
3+
using System;
4+
using System.Threading.Tasks;
5+
using Azure.Core;
6+
using Azure.Identity;
7+
using Azure.ResourceManager.ContainerRegistry;
8+
9+
// Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/Registry/stable/2025-11-01/examples/CacheRuleCreate.json
10+
// this example is just showing the usage of "CacheRules_Create" operation, for the dependent resources, they will have to be created separately.
11+
12+
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
13+
TokenCredential cred = new DefaultAzureCredential();
14+
// authenticate your client
15+
ArmClient client = new ArmClient(cred);
16+
17+
// this example assumes you already have this ContainerRegistryResource created on azure
18+
// for more information of creating ContainerRegistryResource, please refer to the document of ContainerRegistryResource
19+
string subscriptionId = "00000000-0000-0000-0000-000000000000";
20+
string resourceGroupName = "myResourceGroup";
21+
string registryName = "myRegistry";
22+
ResourceIdentifier containerRegistryResourceId = ContainerRegistryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName);
23+
ContainerRegistryResource containerRegistry = client.GetContainerRegistryResource(containerRegistryResourceId);
24+
25+
// get the collection of this ContainerRegistryCacheRuleResource
26+
ContainerRegistryCacheRuleCollection collection = containerRegistry.GetContainerRegistryCacheRules();
27+
28+
// invoke the operation
29+
string cacheRuleName = "myCacheRule";
30+
ContainerRegistryCacheRuleData data = new ContainerRegistryCacheRuleData
31+
{
32+
CredentialSetResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/credentialSets/myCredentialSet"),
33+
SourceRepository = "docker.io/library/hello-world",
34+
TargetRepository = "cached-docker-hub/hello-world",
35+
};
36+
ArmOperation<ContainerRegistryCacheRuleResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cacheRuleName, data);
37+
ContainerRegistryCacheRuleResource result = lro.Value;
38+
39+
// the variable result is a resource, you could call other operations on this instance as well
40+
// but just for demo, we get its data from this resource instance
41+
ContainerRegistryCacheRuleData resourceData = result.Data;
42+
// for demo we just print out the id
43+
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"sdkUrl": "https://github.com/Azure/azure-sdk-for-net/blob/Azure.ResourceManager.ContainerRegistry_1.4.0/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/README.md"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Azure;
2+
using Azure.ResourceManager;
3+
using System;
4+
using System.Threading.Tasks;
5+
using Azure.Core;
6+
using Azure.Identity;
7+
using Azure.ResourceManager.ContainerRegistry.Models;
8+
using Azure.ResourceManager.ContainerRegistry;
9+
10+
// Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/Registry/stable/2025-11-01/examples/CacheRuleDelete.json
11+
// this example is just showing the usage of "CacheRules_Delete" operation, for the dependent resources, they will have to be created separately.
12+
13+
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
14+
TokenCredential cred = new DefaultAzureCredential();
15+
// authenticate your client
16+
ArmClient client = new ArmClient(cred);
17+
18+
// this example assumes you already have this ContainerRegistryCacheRuleResource created on azure
19+
// for more information of creating ContainerRegistryCacheRuleResource, please refer to the document of ContainerRegistryCacheRuleResource
20+
string subscriptionId = "00000000-0000-0000-0000-000000000000";
21+
string resourceGroupName = "myResourceGroup";
22+
string registryName = "myRegistry";
23+
string cacheRuleName = "myCacheRule";
24+
ResourceIdentifier containerRegistryCacheRuleResourceId = ContainerRegistryCacheRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName, cacheRuleName);
25+
ContainerRegistryCacheRuleResource containerRegistryCacheRule = client.GetContainerRegistryCacheRuleResource(containerRegistryCacheRuleResourceId);
26+
27+
// invoke the operation
28+
await containerRegistryCacheRule.DeleteAsync(WaitUntil.Completed);
29+
30+
Console.WriteLine("Succeeded");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"sdkUrl": "https://github.com/Azure/azure-sdk-for-net/blob/Azure.ResourceManager.ContainerRegistry_1.4.0/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/README.md"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Azure;
2+
using Azure.ResourceManager;
3+
using System;
4+
using System.Threading.Tasks;
5+
using Azure.Core;
6+
using Azure.Identity;
7+
using Azure.ResourceManager.ContainerRegistry.Models;
8+
using Azure.ResourceManager.ContainerRegistry;
9+
10+
// Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/Registry/stable/2025-11-01/examples/CacheRuleGet.json
11+
// this example is just showing the usage of "CacheRules_Get" operation, for the dependent resources, they will have to be created separately.
12+
13+
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
14+
TokenCredential cred = new DefaultAzureCredential();
15+
// authenticate your client
16+
ArmClient client = new ArmClient(cred);
17+
18+
// this example assumes you already have this ContainerRegistryCacheRuleResource created on azure
19+
// for more information of creating ContainerRegistryCacheRuleResource, please refer to the document of ContainerRegistryCacheRuleResource
20+
string subscriptionId = "00000000-0000-0000-0000-000000000000";
21+
string resourceGroupName = "myResourceGroup";
22+
string registryName = "myRegistry";
23+
string cacheRuleName = "myCacheRule";
24+
ResourceIdentifier containerRegistryCacheRuleResourceId = ContainerRegistryCacheRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName, cacheRuleName);
25+
ContainerRegistryCacheRuleResource containerRegistryCacheRule = client.GetContainerRegistryCacheRuleResource(containerRegistryCacheRuleResourceId);
26+
27+
// invoke the operation
28+
ContainerRegistryCacheRuleResource result = await containerRegistryCacheRule.GetAsync();
29+
30+
// the variable result is a resource, you could call other operations on this instance as well
31+
// but just for demo, we get its data from this resource instance
32+
ContainerRegistryCacheRuleData resourceData = result.Data;
33+
// for demo we just print out the id
34+
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"sdkUrl": "https://github.com/Azure/azure-sdk-for-net/blob/Azure.ResourceManager.ContainerRegistry_1.4.0/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/README.md"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Azure;
2+
using Azure.ResourceManager;
3+
using System;
4+
using System.Threading.Tasks;
5+
using Azure.Core;
6+
using Azure.Identity;
7+
using Azure.ResourceManager.ContainerRegistry;
8+
9+
// Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/Registry/stable/2025-11-01/examples/CacheRuleList.json
10+
// this example is just showing the usage of "CacheRules_List" operation, for the dependent resources, they will have to be created separately.
11+
12+
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
13+
TokenCredential cred = new DefaultAzureCredential();
14+
// authenticate your client
15+
ArmClient client = new ArmClient(cred);
16+
17+
// this example assumes you already have this ContainerRegistryResource created on azure
18+
// for more information of creating ContainerRegistryResource, please refer to the document of ContainerRegistryResource
19+
string subscriptionId = "00000000-0000-0000-0000-000000000000";
20+
string resourceGroupName = "myResourceGroup";
21+
string registryName = "myRegistry";
22+
ResourceIdentifier containerRegistryResourceId = ContainerRegistryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName);
23+
ContainerRegistryResource containerRegistry = client.GetContainerRegistryResource(containerRegistryResourceId);
24+
25+
// get the collection of this ContainerRegistryCacheRuleResource
26+
ContainerRegistryCacheRuleCollection collection = containerRegistry.GetContainerRegistryCacheRules();
27+
28+
// invoke the operation and iterate over the result
29+
await foreach (ContainerRegistryCacheRuleResource item in collection.GetAllAsync())
30+
{
31+
// the variable item is a resource, you could call other operations on this instance as well
32+
// but just for demo, we get its data from this resource instance
33+
ContainerRegistryCacheRuleData resourceData = item.Data;
34+
// for demo we just print out the id
35+
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
36+
}
37+
38+
Console.WriteLine("Succeeded");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"sdkUrl": "https://github.com/Azure/azure-sdk-for-net/blob/Azure.ResourceManager.ContainerRegistry_1.4.0/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/README.md"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Azure;
2+
using Azure.ResourceManager;
3+
using System;
4+
using System.Threading.Tasks;
5+
using Azure.Core;
6+
using Azure.Identity;
7+
using Azure.ResourceManager.ContainerRegistry.Models;
8+
using Azure.ResourceManager.ContainerRegistry;
9+
10+
// Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/Registry/stable/2025-11-01/examples/CacheRuleUpdate.json
11+
// this example is just showing the usage of "CacheRules_Update" operation, for the dependent resources, they will have to be created separately.
12+
13+
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
14+
TokenCredential cred = new DefaultAzureCredential();
15+
// authenticate your client
16+
ArmClient client = new ArmClient(cred);
17+
18+
// this example assumes you already have this ContainerRegistryCacheRuleResource created on azure
19+
// for more information of creating ContainerRegistryCacheRuleResource, please refer to the document of ContainerRegistryCacheRuleResource
20+
string subscriptionId = "00000000-0000-0000-0000-000000000000";
21+
string resourceGroupName = "myResourceGroup";
22+
string registryName = "myRegistry";
23+
string cacheRuleName = "myCacheRule";
24+
ResourceIdentifier containerRegistryCacheRuleResourceId = ContainerRegistryCacheRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName, cacheRuleName);
25+
ContainerRegistryCacheRuleResource containerRegistryCacheRule = client.GetContainerRegistryCacheRuleResource(containerRegistryCacheRuleResourceId);
26+
27+
// invoke the operation
28+
ContainerRegistryCacheRulePatch patch = new ContainerRegistryCacheRulePatch
29+
{
30+
CredentialSetResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/credentialSets/myCredentialSet2"),
31+
};
32+
ArmOperation<ContainerRegistryCacheRuleResource> lro = await containerRegistryCacheRule.UpdateAsync(WaitUntil.Completed, patch);
33+
ContainerRegistryCacheRuleResource result = lro.Value;
34+
35+
// the variable result is a resource, you could call other operations on this instance as well
36+
// but just for demo, we get its data from this resource instance
37+
ContainerRegistryCacheRuleData resourceData = result.Data;
38+
// for demo we just print out the id
39+
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"sdkUrl": "https://github.com/Azure/azure-sdk-for-net/blob/Azure.ResourceManager.ContainerRegistry_1.4.0/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/README.md"}

0 commit comments

Comments
 (0)