1. Packages
  2. Azure Classic
  3. API Docs
  4. containerservice
  5. RegistryCacheRule

We recommend using Azure Native.

Azure v6.22.0 published on Tuesday, Apr 1, 2025 by Pulumi

azure.containerservice.RegistryCacheRule

Explore with Pulumi AI

Manages an Azure Container Registry Cache Rule.

Note: All arguments including the access key will be stored in the raw state as plain-text. Read more about sensitive data in state.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";

const example = new azure.core.ResourceGroup("example", {
    name: "example-resources",
    location: "West Europe",
});
const acr = new azure.containerservice.Registry("acr", {
    name: "containerRegistry1",
    resourceGroupName: example.name,
    location: example.location,
    sku: "Basic",
});
const cacheRule = new azure.containerservice.RegistryCacheRule("cache_rule", {
    name: "cacherule",
    containerRegistryId: acr.id,
    targetRepo: "target",
    sourceRepo: "docker.io/hello-world",
    credentialSetId: pulumi.interpolate`${acr.id}/credentialSets/example`,
});
Copy
import pulumi
import pulumi_azure as azure

example = azure.core.ResourceGroup("example",
    name="example-resources",
    location="West Europe")
acr = azure.containerservice.Registry("acr",
    name="containerRegistry1",
    resource_group_name=example.name,
    location=example.location,
    sku="Basic")
cache_rule = azure.containerservice.RegistryCacheRule("cache_rule",
    name="cacherule",
    container_registry_id=acr.id,
    target_repo="target",
    source_repo="docker.io/hello-world",
    credential_set_id=acr.id.apply(lambda id: f"{id}/credentialSets/example"))
Copy
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/containerservice"
	"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
			Name:     pulumi.String("example-resources"),
			Location: pulumi.String("West Europe"),
		})
		if err != nil {
			return err
		}
		acr, err := containerservice.NewRegistry(ctx, "acr", &containerservice.RegistryArgs{
			Name:              pulumi.String("containerRegistry1"),
			ResourceGroupName: example.Name,
			Location:          example.Location,
			Sku:               pulumi.String("Basic"),
		})
		if err != nil {
			return err
		}
		_, err = containerservice.NewRegistryCacheRule(ctx, "cache_rule", &containerservice.RegistryCacheRuleArgs{
			Name:                pulumi.String("cacherule"),
			ContainerRegistryId: acr.ID(),
			TargetRepo:          pulumi.String("target"),
			SourceRepo:          pulumi.String("docker.io/hello-world"),
			CredentialSetId: acr.ID().ApplyT(func(id string) (string, error) {
				return fmt.Sprintf("%v/credentialSets/example", id), nil
			}).(pulumi.StringOutput),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;

return await Deployment.RunAsync(() => 
{
    var example = new Azure.Core.ResourceGroup("example", new()
    {
        Name = "example-resources",
        Location = "West Europe",
    });

    var acr = new Azure.ContainerService.Registry("acr", new()
    {
        Name = "containerRegistry1",
        ResourceGroupName = example.Name,
        Location = example.Location,
        Sku = "Basic",
    });

    var cacheRule = new Azure.ContainerService.RegistryCacheRule("cache_rule", new()
    {
        Name = "cacherule",
        ContainerRegistryId = acr.Id,
        TargetRepo = "target",
        SourceRepo = "docker.io/hello-world",
        CredentialSetId = acr.Id.Apply(id => $"{id}/credentialSets/example"),
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.containerservice.Registry;
import com.pulumi.azure.containerservice.RegistryArgs;
import com.pulumi.azure.containerservice.RegistryCacheRule;
import com.pulumi.azure.containerservice.RegistryCacheRuleArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new ResourceGroup("example", ResourceGroupArgs.builder()
            .name("example-resources")
            .location("West Europe")
            .build());

        var acr = new Registry("acr", RegistryArgs.builder()
            .name("containerRegistry1")
            .resourceGroupName(example.name())
            .location(example.location())
            .sku("Basic")
            .build());

        var cacheRule = new RegistryCacheRule("cacheRule", RegistryCacheRuleArgs.builder()
            .name("cacherule")
            .containerRegistryId(acr.id())
            .targetRepo("target")
            .sourceRepo("docker.io/hello-world")
            .credentialSetId(acr.id().applyValue(id -> String.format("%s/credentialSets/example", id)))
            .build());

    }
}
Copy
resources:
  example:
    type: azure:core:ResourceGroup
    properties:
      name: example-resources
      location: West Europe
  acr:
    type: azure:containerservice:Registry
    properties:
      name: containerRegistry1
      resourceGroupName: ${example.name}
      location: ${example.location}
      sku: Basic
  cacheRule:
    type: azure:containerservice:RegistryCacheRule
    name: cache_rule
    properties:
      name: cacherule
      containerRegistryId: ${acr.id}
      targetRepo: target
      sourceRepo: docker.io/hello-world
      credentialSetId: ${acr.id}/credentialSets/example
Copy

Create RegistryCacheRule Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new RegistryCacheRule(name: string, args: RegistryCacheRuleArgs, opts?: CustomResourceOptions);
@overload
def RegistryCacheRule(resource_name: str,
                      args: RegistryCacheRuleArgs,
                      opts: Optional[ResourceOptions] = None)

@overload
def RegistryCacheRule(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      container_registry_id: Optional[str] = None,
                      source_repo: Optional[str] = None,
                      target_repo: Optional[str] = None,
                      credential_set_id: Optional[str] = None,
                      name: Optional[str] = None)
func NewRegistryCacheRule(ctx *Context, name string, args RegistryCacheRuleArgs, opts ...ResourceOption) (*RegistryCacheRule, error)
public RegistryCacheRule(string name, RegistryCacheRuleArgs args, CustomResourceOptions? opts = null)
public RegistryCacheRule(String name, RegistryCacheRuleArgs args)
public RegistryCacheRule(String name, RegistryCacheRuleArgs args, CustomResourceOptions options)
type: azure:containerservice:RegistryCacheRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. RegistryCacheRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. RegistryCacheRuleArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. RegistryCacheRuleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. RegistryCacheRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. RegistryCacheRuleArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var registryCacheRuleResource = new Azure.ContainerService.RegistryCacheRule("registryCacheRuleResource", new()
{
    ContainerRegistryId = "string",
    SourceRepo = "string",
    TargetRepo = "string",
    CredentialSetId = "string",
    Name = "string",
});
Copy
example, err := containerservice.NewRegistryCacheRule(ctx, "registryCacheRuleResource", &containerservice.RegistryCacheRuleArgs{
	ContainerRegistryId: pulumi.String("string"),
	SourceRepo:          pulumi.String("string"),
	TargetRepo:          pulumi.String("string"),
	CredentialSetId:     pulumi.String("string"),
	Name:                pulumi.String("string"),
})
Copy
var registryCacheRuleResource = new RegistryCacheRule("registryCacheRuleResource", RegistryCacheRuleArgs.builder()
    .containerRegistryId("string")
    .sourceRepo("string")
    .targetRepo("string")
    .credentialSetId("string")
    .name("string")
    .build());
Copy
registry_cache_rule_resource = azure.containerservice.RegistryCacheRule("registryCacheRuleResource",
    container_registry_id="string",
    source_repo="string",
    target_repo="string",
    credential_set_id="string",
    name="string")
Copy
const registryCacheRuleResource = new azure.containerservice.RegistryCacheRule("registryCacheRuleResource", {
    containerRegistryId: "string",
    sourceRepo: "string",
    targetRepo: "string",
    credentialSetId: "string",
    name: "string",
});
Copy
type: azure:containerservice:RegistryCacheRule
properties:
    containerRegistryId: string
    credentialSetId: string
    name: string
    sourceRepo: string
    targetRepo: string
Copy

RegistryCacheRule Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The RegistryCacheRule resource accepts the following input properties:

ContainerRegistryId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the Container Registry where the Cache Rule should apply. Changing this forces a new resource to be created.
SourceRepo
This property is required.
Changes to this property will trigger replacement.
string
The name of the source repository path. Changing this forces a new resource to be created.
TargetRepo
This property is required.
Changes to this property will trigger replacement.
string
The name of the new repository path to store artifacts. Changing this forces a new resource to be created.
CredentialSetId string
The ARM resource ID of the Credential Store which is associated with the Cache Rule.
Name Changes to this property will trigger replacement. string
Specifies the name of the Container Registry Cache Rule. Only Alphanumeric characters allowed. Changing this forces a new resource to be created.
ContainerRegistryId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the Container Registry where the Cache Rule should apply. Changing this forces a new resource to be created.
SourceRepo
This property is required.
Changes to this property will trigger replacement.
string
The name of the source repository path. Changing this forces a new resource to be created.
TargetRepo
This property is required.
Changes to this property will trigger replacement.
string
The name of the new repository path to store artifacts. Changing this forces a new resource to be created.
CredentialSetId string
The ARM resource ID of the Credential Store which is associated with the Cache Rule.
Name Changes to this property will trigger replacement. string
Specifies the name of the Container Registry Cache Rule. Only Alphanumeric characters allowed. Changing this forces a new resource to be created.
containerRegistryId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the Container Registry where the Cache Rule should apply. Changing this forces a new resource to be created.
sourceRepo
This property is required.
Changes to this property will trigger replacement.
String
The name of the source repository path. Changing this forces a new resource to be created.
targetRepo
This property is required.
Changes to this property will trigger replacement.
String
The name of the new repository path to store artifacts. Changing this forces a new resource to be created.
credentialSetId String
The ARM resource ID of the Credential Store which is associated with the Cache Rule.
name Changes to this property will trigger replacement. String
Specifies the name of the Container Registry Cache Rule. Only Alphanumeric characters allowed. Changing this forces a new resource to be created.
containerRegistryId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the Container Registry where the Cache Rule should apply. Changing this forces a new resource to be created.
sourceRepo
This property is required.
Changes to this property will trigger replacement.
string
The name of the source repository path. Changing this forces a new resource to be created.
targetRepo
This property is required.
Changes to this property will trigger replacement.
string
The name of the new repository path to store artifacts. Changing this forces a new resource to be created.
credentialSetId string
The ARM resource ID of the Credential Store which is associated with the Cache Rule.
name Changes to this property will trigger replacement. string
Specifies the name of the Container Registry Cache Rule. Only Alphanumeric characters allowed. Changing this forces a new resource to be created.
container_registry_id
This property is required.
Changes to this property will trigger replacement.
str
The ID of the Container Registry where the Cache Rule should apply. Changing this forces a new resource to be created.
source_repo
This property is required.
Changes to this property will trigger replacement.
str
The name of the source repository path. Changing this forces a new resource to be created.
target_repo
This property is required.
Changes to this property will trigger replacement.
str
The name of the new repository path to store artifacts. Changing this forces a new resource to be created.
credential_set_id str
The ARM resource ID of the Credential Store which is associated with the Cache Rule.
name Changes to this property will trigger replacement. str
Specifies the name of the Container Registry Cache Rule. Only Alphanumeric characters allowed. Changing this forces a new resource to be created.
containerRegistryId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the Container Registry where the Cache Rule should apply. Changing this forces a new resource to be created.
sourceRepo
This property is required.
Changes to this property will trigger replacement.
String
The name of the source repository path. Changing this forces a new resource to be created.
targetRepo
This property is required.
Changes to this property will trigger replacement.
String
The name of the new repository path to store artifacts. Changing this forces a new resource to be created.
credentialSetId String
The ARM resource ID of the Credential Store which is associated with the Cache Rule.
name Changes to this property will trigger replacement. String
Specifies the name of the Container Registry Cache Rule. Only Alphanumeric characters allowed. Changing this forces a new resource to be created.

Outputs

All input properties are implicitly available as output properties. Additionally, the RegistryCacheRule resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing RegistryCacheRule Resource

Get an existing RegistryCacheRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: RegistryCacheRuleState, opts?: CustomResourceOptions): RegistryCacheRule
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        container_registry_id: Optional[str] = None,
        credential_set_id: Optional[str] = None,
        name: Optional[str] = None,
        source_repo: Optional[str] = None,
        target_repo: Optional[str] = None) -> RegistryCacheRule
func GetRegistryCacheRule(ctx *Context, name string, id IDInput, state *RegistryCacheRuleState, opts ...ResourceOption) (*RegistryCacheRule, error)
public static RegistryCacheRule Get(string name, Input<string> id, RegistryCacheRuleState? state, CustomResourceOptions? opts = null)
public static RegistryCacheRule get(String name, Output<String> id, RegistryCacheRuleState state, CustomResourceOptions options)
resources:  _:    type: azure:containerservice:RegistryCacheRule    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
ContainerRegistryId Changes to this property will trigger replacement. string
The ID of the Container Registry where the Cache Rule should apply. Changing this forces a new resource to be created.
CredentialSetId string
The ARM resource ID of the Credential Store which is associated with the Cache Rule.
Name Changes to this property will trigger replacement. string
Specifies the name of the Container Registry Cache Rule. Only Alphanumeric characters allowed. Changing this forces a new resource to be created.
SourceRepo Changes to this property will trigger replacement. string
The name of the source repository path. Changing this forces a new resource to be created.
TargetRepo Changes to this property will trigger replacement. string
The name of the new repository path to store artifacts. Changing this forces a new resource to be created.
ContainerRegistryId Changes to this property will trigger replacement. string
The ID of the Container Registry where the Cache Rule should apply. Changing this forces a new resource to be created.
CredentialSetId string
The ARM resource ID of the Credential Store which is associated with the Cache Rule.
Name Changes to this property will trigger replacement. string
Specifies the name of the Container Registry Cache Rule. Only Alphanumeric characters allowed. Changing this forces a new resource to be created.
SourceRepo Changes to this property will trigger replacement. string
The name of the source repository path. Changing this forces a new resource to be created.
TargetRepo Changes to this property will trigger replacement. string
The name of the new repository path to store artifacts. Changing this forces a new resource to be created.
containerRegistryId Changes to this property will trigger replacement. String
The ID of the Container Registry where the Cache Rule should apply. Changing this forces a new resource to be created.
credentialSetId String
The ARM resource ID of the Credential Store which is associated with the Cache Rule.
name Changes to this property will trigger replacement. String
Specifies the name of the Container Registry Cache Rule. Only Alphanumeric characters allowed. Changing this forces a new resource to be created.
sourceRepo Changes to this property will trigger replacement. String
The name of the source repository path. Changing this forces a new resource to be created.
targetRepo Changes to this property will trigger replacement. String
The name of the new repository path to store artifacts. Changing this forces a new resource to be created.
containerRegistryId Changes to this property will trigger replacement. string
The ID of the Container Registry where the Cache Rule should apply. Changing this forces a new resource to be created.
credentialSetId string
The ARM resource ID of the Credential Store which is associated with the Cache Rule.
name Changes to this property will trigger replacement. string
Specifies the name of the Container Registry Cache Rule. Only Alphanumeric characters allowed. Changing this forces a new resource to be created.
sourceRepo Changes to this property will trigger replacement. string
The name of the source repository path. Changing this forces a new resource to be created.
targetRepo Changes to this property will trigger replacement. string
The name of the new repository path to store artifacts. Changing this forces a new resource to be created.
container_registry_id Changes to this property will trigger replacement. str
The ID of the Container Registry where the Cache Rule should apply. Changing this forces a new resource to be created.
credential_set_id str
The ARM resource ID of the Credential Store which is associated with the Cache Rule.
name Changes to this property will trigger replacement. str
Specifies the name of the Container Registry Cache Rule. Only Alphanumeric characters allowed. Changing this forces a new resource to be created.
source_repo Changes to this property will trigger replacement. str
The name of the source repository path. Changing this forces a new resource to be created.
target_repo Changes to this property will trigger replacement. str
The name of the new repository path to store artifacts. Changing this forces a new resource to be created.
containerRegistryId Changes to this property will trigger replacement. String
The ID of the Container Registry where the Cache Rule should apply. Changing this forces a new resource to be created.
credentialSetId String
The ARM resource ID of the Credential Store which is associated with the Cache Rule.
name Changes to this property will trigger replacement. String
Specifies the name of the Container Registry Cache Rule. Only Alphanumeric characters allowed. Changing this forces a new resource to be created.
sourceRepo Changes to this property will trigger replacement. String
The name of the source repository path. Changing this forces a new resource to be created.
targetRepo Changes to this property will trigger replacement. String
The name of the new repository path to store artifacts. Changing this forces a new resource to be created.

Import

Container Registry Cache Rules can be imported using the resource id, e.g.

$ pulumi import azure:containerservice/registryCacheRule:RegistryCacheRule example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/cacheRules/myCacheRule
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Azure Classic pulumi/pulumi-azure
License
Apache-2.0
Notes
This Pulumi package is based on the azurerm Terraform Provider.