创建或更新蓝图项目。
PUT https://management.azure.com/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/artifacts/{artifactName}?api-version=2018-11-01-preview
URI 参数
名称 |
在 |
必需 |
类型 |
说明 |
artifactName
|
path |
True
|
string
|
蓝图项目的名称。
|
blueprintName
|
path |
True
|
string
|
蓝图定义的名称。
|
resourceScope
|
path |
True
|
string
|
资源的范围。 有效范围包括:管理组(格式:'/providers/Microsoft.Management/managementGroups/{managementGroup}')、订阅(格式:'/subscriptions/{subscriptionId}')。
|
api-version
|
query |
True
|
string
|
客户端 API 版本。
|
请求正文
请求正文可以为下列任一内容:
PolicyAssignmentArtifact
应用策略分配的蓝图项目。
名称 |
必需 |
类型 |
说明 |
kind
|
True
|
string:
policyAssignment
|
指定蓝图项目的类型。
|
properties.parameters
|
True
|
<string,
ParameterValue>
|
策略定义的参数值。
|
properties.policyDefinitionId
|
True
|
string
|
策略定义的 Azure 资源 ID。
|
properties.dependsOn
|
|
string[]
|
需要在指定项目之前部署的项目。
|
properties.description
|
|
string
maxLength: 500
|
多行说明此资源。
|
properties.displayName
|
|
string
maxLength: 256
|
单行字符串解释此资源。
|
properties.resourceGroup
|
|
string
|
将向其分配策略的资源组占位符的名称。
|
RoleAssignmentArtifact
应用角色分配的蓝图项目。
名称 |
必需 |
类型 |
说明 |
kind
|
True
|
string:
roleAssignment
|
指定蓝图项目的类型。
|
properties.principalIds
|
True
|
|
Azure Active Directory 中的用户或组标识数组。 roleDefinition 将应用于每个标识。
|
properties.roleDefinitionId
|
True
|
string
|
RoleDefinition 的 Azure 资源 ID。
|
properties.dependsOn
|
|
string[]
|
需要在指定项目之前部署的项目。
|
properties.description
|
|
string
maxLength: 500
|
多行说明此资源。
|
properties.displayName
|
|
string
maxLength: 256
|
单行字符串解释此资源。
|
properties.resourceGroup
|
|
string
|
RoleAssignment 的范围将限定为此 resourceGroup。 如果为空,则范围限定为订阅。
|
TemplateArtifact
部署资源管理器模板的蓝图项目。
名称 |
必需 |
类型 |
说明 |
kind
|
True
|
string:
template
|
指定蓝图项目的类型。
|
properties.parameters
|
True
|
<string,
ParameterValue>
|
资源管理器模板蓝图项目参数值。
|
properties.template
|
True
|
object
|
资源管理器模板蓝图项目正文。
|
properties.dependsOn
|
|
string[]
|
需要在指定项目之前部署的项目。
|
properties.description
|
|
string
maxLength: 500
|
多行说明此资源。
|
properties.displayName
|
|
string
maxLength: 256
|
单行字符串解释此资源。
|
properties.resourceGroup
|
|
string
|
如果适用,则会将资源管理器模板蓝图项目部署到的资源组占位符的名称。
|
响应
名称 |
类型 |
说明 |
201 Created
|
Artifact:
|
已创建 -- 蓝图项目已创建/更新。
|
Other Status Codes
|
CloudError
|
蓝图错误响应。
|
安全性
azure_auth
Azure Active Directory OAuth2 Flow
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
名称 |
说明 |
user_impersonation
|
模拟用户帐户
|
示例
MG-ARMTemplateArtifact
示例请求
PUT https://management.azure.com/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint/artifacts/storageTemplate?api-version=2018-11-01-preview
{
"kind": "template",
"properties": {
"template": {
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountType": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS",
"Standard_ZRS",
"Premium_LRS"
],
"metadata": {
"description": "Storage Account type"
}
}
},
"variables": {
"storageAccountName": "[concat(uniquestring(resourceGroup().id), 'standardsa')]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"apiVersion": "2016-01-01",
"location": "[resourceGroup().location]",
"sku": {
"name": "[parameters('storageAccountType')]"
},
"kind": "Storage",
"properties": {}
}
],
"outputs": {
"storageAccountName": {
"type": "string",
"value": "[variables('storageAccountName')]"
}
}
},
"resourceGroup": "storageRG",
"parameters": {
"storageAccountType": {
"value": "[parameters('storageAccountType')]"
}
}
}
}
package armblueprint_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blueprint/armblueprint"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/ARMTemplateArtifact_Create.json
func ExampleArtifactsClient_CreateOrUpdate_mgArmTemplateArtifact() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armblueprint.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
_, err = clientFactory.NewArtifactsClient().CreateOrUpdate(ctx, "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup", "simpleBlueprint", "storageTemplate", &armblueprint.TemplateArtifact{
Kind: to.Ptr(armblueprint.ArtifactKindTemplate),
Properties: &armblueprint.TemplateArtifactProperties{
Parameters: map[string]*armblueprint.ParameterValue{
"storageAccountType": {
Value: "[parameters('storageAccountType')]",
},
},
ResourceGroup: to.Ptr("storageRG"),
Template: map[string]any{
"contentVersion": "1.0.0.0",
"outputs": map[string]any{
"storageAccountName": map[string]any{
"type": "string",
"value": "[variables('storageAccountName')]",
},
},
"parameters": map[string]any{
"storageAccountType": map[string]any{
"type": "string",
"allowedValues": []any{
"Standard_LRS",
"Standard_GRS",
"Standard_ZRS",
"Premium_LRS",
},
"defaultValue": "Standard_LRS",
"metadata": map[string]any{
"description": "Storage Account type",
},
},
},
"resources": []any{
map[string]any{
"name": "[variables('storageAccountName')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2016-01-01",
"kind": "Storage",
"location": "[resourceGroup().location]",
"properties": map[string]any{},
"sku": map[string]any{
"name": "[parameters('storageAccountType')]",
},
},
},
"variables": map[string]any{
"storageAccountName": "[concat(uniquestring(resourceGroup().id), 'standardsa')]",
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Blueprint.Models;
using Azure.ResourceManager.Blueprint;
// Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/ARMTemplateArtifact_Create.json
// this example is just showing the usage of "Artifacts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// 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
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BlueprintResource created on azure
// for more information of creating BlueprintResource, please refer to the document of BlueprintResource
string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup";
string blueprintName = "simpleBlueprint";
ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName);
BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId);
// get the collection of this BlueprintArtifactResource
BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts();
// invoke the operation
string artifactName = "storageTemplate";
ArtifactData data = new TemplateArtifact(BinaryData.FromObjectAsJson(new
{
contentVersion = "1.0.0.0",
outputs = new
{
storageAccountName = new
{
type = "string",
value = "[variables('storageAccountName')]",
},
},
parameters = new
{
storageAccountType = new
{
type = "string",
allowedValues = new object[]
{
"Standard_LRS",
"Standard_GRS",
"Standard_ZRS",
"Premium_LRS"
},
defaultValue = "Standard_LRS",
metadata = new
{
description = "Storage Account type",
},
},
},
resources = new object[]
{
new
{
name = "[variables('storageAccountName')]",
type = "Microsoft.Storage/storageAccounts",
apiVersion = "2016-01-01",
kind = "Storage",
location = "[resourceGroup().location]",
properties = new object(),
sku = new
{
name = "[parameters('storageAccountType')]",
},
}
},
variables = new
{
storageAccountName = "[concat(uniquestring(resourceGroup().id), 'standardsa')]",
},
}), new Dictionary<string, ParameterValue>
{
["storageAccountType"] = new ParameterValue
{
Value = BinaryData.FromObjectAsJson("[parameters('storageAccountType')]"),
}
})
{
ResourceGroup = "storageRG",
};
ArmOperation<BlueprintArtifactResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, artifactName, data);
BlueprintArtifactResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ArtifactData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"properties": {
"template": {
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountType": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS",
"Standard_ZRS",
"Premium_LRS"
],
"metadata": {
"description": "Storage Account type"
}
}
},
"variables": {
"storageAccountName": "[concat(uniquestring(resourceGroup().id), 'standardsa')]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"apiVersion": "2016-01-01",
"location": "[resourceGroup().location]",
"sku": {
"name": "[parameters('storageAccountType')]"
},
"kind": "Storage",
"properties": {}
}
],
"outputs": {
"storageAccountName": {
"type": "string",
"value": "[variables('storageAccountName')]"
}
}
},
"resourceGroup": "storageRG",
"parameters": {
"storageAccountType": {
"value": "[parameters('storageAccountType')]"
}
}
},
"kind": "template",
"id": "/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint/artifacts/storageTemplate",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "storageTemplate"
}
MG-PolicyAssignmentArtifact
示例请求
PUT https://management.azure.com/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint/artifacts/costCenterPolicy?api-version=2018-11-01-preview
{
"properties": {
"displayName": "force costCenter tag on all resources",
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62",
"parameters": {
"tagName": {
"value": "costCenter"
},
"tagValue": {
"value": "[parameter('costCenter')]"
}
}
},
"kind": "policyAssignment"
}
package armblueprint_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blueprint/armblueprint"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/PolicyAssignmentArtifact_Create.json
func ExampleArtifactsClient_CreateOrUpdate_mgPolicyAssignmentArtifact() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armblueprint.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
_, err = clientFactory.NewArtifactsClient().CreateOrUpdate(ctx, "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup", "simpleBlueprint", "costCenterPolicy", &armblueprint.PolicyAssignmentArtifact{
Kind: to.Ptr(armblueprint.ArtifactKindPolicyAssignment),
Properties: &armblueprint.PolicyAssignmentArtifactProperties{
DisplayName: to.Ptr("force costCenter tag on all resources"),
Parameters: map[string]*armblueprint.ParameterValue{
"tagName": {
Value: "costCenter",
},
"tagValue": {
Value: "[parameter('costCenter')]",
},
},
PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Blueprint.Models;
using Azure.ResourceManager.Blueprint;
// Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/PolicyAssignmentArtifact_Create.json
// this example is just showing the usage of "Artifacts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// 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
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BlueprintResource created on azure
// for more information of creating BlueprintResource, please refer to the document of BlueprintResource
string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup";
string blueprintName = "simpleBlueprint";
ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName);
BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId);
// get the collection of this BlueprintArtifactResource
BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts();
// invoke the operation
string artifactName = "costCenterPolicy";
ArtifactData data = new PolicyAssignmentArtifact("/providers/Microsoft.Authorization/policyDefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62", new Dictionary<string, ParameterValue>
{
["tagName"] = new ParameterValue
{
Value = BinaryData.FromObjectAsJson("costCenter"),
},
["tagValue"] = new ParameterValue
{
Value = BinaryData.FromObjectAsJson("[parameter('costCenter')]"),
}
})
{
DisplayName = "force costCenter tag on all resources",
};
ArmOperation<BlueprintArtifactResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, artifactName, data);
BlueprintArtifactResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ArtifactData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"properties": {
"displayName": "force costCenter tag on all resources",
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62",
"parameters": {
"tagName": {
"value": "costCenter"
},
"tagValue": {
"value": "[parameter('costCenter')]"
}
}
},
"kind": "policyAssignment",
"id": "/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint/artifacts/costCenterPolicy",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "costCenterPolicy"
}
MG-RoleAssignmentArtifact
示例请求
PUT https://management.azure.com/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint/artifacts/ownerAssignment?api-version=2018-11-01-preview
{
"properties": {
"displayName": "enforce owners of given subscription",
"roleDefinitionId": "/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7",
"principalIds": "[parameters('owners')]"
},
"kind": "roleAssignment"
}
package armblueprint_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blueprint/armblueprint"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/RoleAssignmentArtifact_Create.json
func ExampleArtifactsClient_CreateOrUpdate_mgRoleAssignmentArtifact() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armblueprint.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
_, err = clientFactory.NewArtifactsClient().CreateOrUpdate(ctx, "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup", "simpleBlueprint", "ownerAssignment", &armblueprint.RoleAssignmentArtifact{
Kind: to.Ptr(armblueprint.ArtifactKindRoleAssignment),
Properties: &armblueprint.RoleAssignmentArtifactProperties{
DisplayName: to.Ptr("enforce owners of given subscription"),
PrincipalIDs: "[parameters('owners')]",
RoleDefinitionID: to.Ptr("/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Blueprint.Models;
using Azure.ResourceManager.Blueprint;
// Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/RoleAssignmentArtifact_Create.json
// this example is just showing the usage of "Artifacts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// 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
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BlueprintResource created on azure
// for more information of creating BlueprintResource, please refer to the document of BlueprintResource
string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup";
string blueprintName = "simpleBlueprint";
ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName);
BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId);
// get the collection of this BlueprintArtifactResource
BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts();
// invoke the operation
string artifactName = "ownerAssignment";
ArtifactData data = new RoleAssignmentArtifact("/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7", BinaryData.FromObjectAsJson("[parameters('owners')]"))
{
DisplayName = "enforce owners of given subscription",
};
ArmOperation<BlueprintArtifactResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, artifactName, data);
BlueprintArtifactResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ArtifactData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"properties": {
"displayName": "enforce owners of given subscription",
"roleDefinitionId": "/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7",
"principalIds": "[parameters('owners')]"
},
"kind": "roleAssignment",
"id": "/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint/artifacts/ownerAssignment",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "ownerAssignment"
}
Sub-ARMTemplateArtifact
示例请求
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Blueprint/blueprints/simpleBlueprint/artifacts/storageTemplate?api-version=2018-11-01-preview
{
"kind": "template",
"properties": {
"template": {
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountType": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS",
"Standard_ZRS",
"Premium_LRS"
],
"metadata": {
"description": "Storage Account type"
}
}
},
"variables": {
"storageAccountName": "[concat(uniquestring(resourceGroup().id), 'standardsa')]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"apiVersion": "2016-01-01",
"location": "[resourceGroup().location]",
"sku": {
"name": "[parameters('storageAccountType')]"
},
"kind": "Storage",
"properties": {}
}
],
"outputs": {
"storageAccountName": {
"type": "string",
"value": "[variables('storageAccountName')]"
}
}
},
"resourceGroup": "storageRG",
"parameters": {
"storageAccountType": {
"value": "[parameters('storageAccountType')]"
}
}
}
}
package armblueprint_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blueprint/armblueprint"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/ARMTemplateArtifact_Create.json
func ExampleArtifactsClient_CreateOrUpdate_subArmTemplateArtifact() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armblueprint.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
_, err = clientFactory.NewArtifactsClient().CreateOrUpdate(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "simpleBlueprint", "storageTemplate", &armblueprint.TemplateArtifact{
Kind: to.Ptr(armblueprint.ArtifactKindTemplate),
Properties: &armblueprint.TemplateArtifactProperties{
Parameters: map[string]*armblueprint.ParameterValue{
"storageAccountType": {
Value: "[parameters('storageAccountType')]",
},
},
ResourceGroup: to.Ptr("storageRG"),
Template: map[string]any{
"contentVersion": "1.0.0.0",
"outputs": map[string]any{
"storageAccountName": map[string]any{
"type": "string",
"value": "[variables('storageAccountName')]",
},
},
"parameters": map[string]any{
"storageAccountType": map[string]any{
"type": "string",
"allowedValues": []any{
"Standard_LRS",
"Standard_GRS",
"Standard_ZRS",
"Premium_LRS",
},
"defaultValue": "Standard_LRS",
"metadata": map[string]any{
"description": "Storage Account type",
},
},
},
"resources": []any{
map[string]any{
"name": "[variables('storageAccountName')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2016-01-01",
"kind": "Storage",
"location": "[resourceGroup().location]",
"properties": map[string]any{},
"sku": map[string]any{
"name": "[parameters('storageAccountType')]",
},
},
},
"variables": map[string]any{
"storageAccountName": "[concat(uniquestring(resourceGroup().id), 'standardsa')]",
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Blueprint.Models;
using Azure.ResourceManager.Blueprint;
// Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/ARMTemplateArtifact_Create.json
// this example is just showing the usage of "Artifacts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// 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
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BlueprintResource created on azure
// for more information of creating BlueprintResource, please refer to the document of BlueprintResource
string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000";
string blueprintName = "simpleBlueprint";
ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName);
BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId);
// get the collection of this BlueprintArtifactResource
BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts();
// invoke the operation
string artifactName = "storageTemplate";
ArtifactData data = new TemplateArtifact(BinaryData.FromObjectAsJson(new
{
contentVersion = "1.0.0.0",
outputs = new
{
storageAccountName = new
{
type = "string",
value = "[variables('storageAccountName')]",
},
},
parameters = new
{
storageAccountType = new
{
type = "string",
allowedValues = new object[]
{
"Standard_LRS",
"Standard_GRS",
"Standard_ZRS",
"Premium_LRS"
},
defaultValue = "Standard_LRS",
metadata = new
{
description = "Storage Account type",
},
},
},
resources = new object[]
{
new
{
name = "[variables('storageAccountName')]",
type = "Microsoft.Storage/storageAccounts",
apiVersion = "2016-01-01",
kind = "Storage",
location = "[resourceGroup().location]",
properties = new object(),
sku = new
{
name = "[parameters('storageAccountType')]",
},
}
},
variables = new
{
storageAccountName = "[concat(uniquestring(resourceGroup().id), 'standardsa')]",
},
}), new Dictionary<string, ParameterValue>
{
["storageAccountType"] = new ParameterValue
{
Value = BinaryData.FromObjectAsJson("[parameters('storageAccountType')]"),
}
})
{
ResourceGroup = "storageRG",
};
ArmOperation<BlueprintArtifactResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, artifactName, data);
BlueprintArtifactResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ArtifactData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"properties": {
"template": {
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountType": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS",
"Standard_ZRS",
"Premium_LRS"
],
"metadata": {
"description": "Storage Account type"
}
}
},
"variables": {
"storageAccountName": "[concat(uniquestring(resourceGroup().id), 'standardsa')]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"apiVersion": "2016-01-01",
"location": "[resourceGroup().location]",
"sku": {
"name": "[parameters('storageAccountType')]"
},
"kind": "Storage",
"properties": {}
}
],
"outputs": {
"storageAccountName": {
"type": "string",
"value": "[variables('storageAccountName')]"
}
}
},
"resourceGroup": "storageRG",
"parameters": {
"storageAccountType": {
"value": "[parameters('storageAccountType')]"
}
}
},
"kind": "template",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Blueprint/blueprints/simpleBlueprint/artifacts/storageTemplate",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "storageTemplate"
}
Sub-PolicyAssignmentArtifact
示例请求
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Blueprint/blueprints/simpleBlueprint/artifacts/costCenterPolicy?api-version=2018-11-01-preview
{
"properties": {
"displayName": "force costCenter tag on all resources",
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62",
"parameters": {
"tagName": {
"value": "costCenter"
},
"tagValue": {
"value": "[parameter('costCenter')]"
}
}
},
"kind": "policyAssignment"
}
package armblueprint_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blueprint/armblueprint"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/PolicyAssignmentArtifact_Create.json
func ExampleArtifactsClient_CreateOrUpdate_subPolicyAssignmentArtifact() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armblueprint.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
_, err = clientFactory.NewArtifactsClient().CreateOrUpdate(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "simpleBlueprint", "costCenterPolicy", &armblueprint.PolicyAssignmentArtifact{
Kind: to.Ptr(armblueprint.ArtifactKindPolicyAssignment),
Properties: &armblueprint.PolicyAssignmentArtifactProperties{
DisplayName: to.Ptr("force costCenter tag on all resources"),
Parameters: map[string]*armblueprint.ParameterValue{
"tagName": {
Value: "costCenter",
},
"tagValue": {
Value: "[parameter('costCenter')]",
},
},
PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Blueprint.Models;
using Azure.ResourceManager.Blueprint;
// Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/PolicyAssignmentArtifact_Create.json
// this example is just showing the usage of "Artifacts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// 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
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BlueprintResource created on azure
// for more information of creating BlueprintResource, please refer to the document of BlueprintResource
string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000";
string blueprintName = "simpleBlueprint";
ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName);
BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId);
// get the collection of this BlueprintArtifactResource
BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts();
// invoke the operation
string artifactName = "costCenterPolicy";
ArtifactData data = new PolicyAssignmentArtifact("/providers/Microsoft.Authorization/policyDefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62", new Dictionary<string, ParameterValue>
{
["tagName"] = new ParameterValue
{
Value = BinaryData.FromObjectAsJson("costCenter"),
},
["tagValue"] = new ParameterValue
{
Value = BinaryData.FromObjectAsJson("[parameter('costCenter')]"),
}
})
{
DisplayName = "force costCenter tag on all resources",
};
ArmOperation<BlueprintArtifactResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, artifactName, data);
BlueprintArtifactResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ArtifactData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"properties": {
"displayName": "force costCenter tag on all resources",
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62",
"parameters": {
"tagName": {
"value": "costCenter"
},
"tagValue": {
"value": "[parameter('costCenter')]"
}
}
},
"kind": "policyAssignment",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Blueprint/blueprints/simpleBlueprint/artifacts/costCenterPolicy",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "costCenterPolicy"
}
Sub-RoleAssignmentArtifact
示例请求
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Blueprint/blueprints/simpleBlueprint/artifacts/ownerAssignment?api-version=2018-11-01-preview
{
"properties": {
"displayName": "enforce owners of given subscription",
"roleDefinitionId": "/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7",
"principalIds": "[parameters('owners')]"
},
"kind": "roleAssignment"
}
package armblueprint_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/blueprint/armblueprint"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/RoleAssignmentArtifact_Create.json
func ExampleArtifactsClient_CreateOrUpdate_subRoleAssignmentArtifact() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armblueprint.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
_, err = clientFactory.NewArtifactsClient().CreateOrUpdate(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "simpleBlueprint", "ownerAssignment", &armblueprint.RoleAssignmentArtifact{
Kind: to.Ptr(armblueprint.ArtifactKindRoleAssignment),
Properties: &armblueprint.RoleAssignmentArtifactProperties{
DisplayName: to.Ptr("enforce owners of given subscription"),
PrincipalIDs: "[parameters('owners')]",
RoleDefinitionID: to.Ptr("/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Blueprint.Models;
using Azure.ResourceManager.Blueprint;
// Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/RoleAssignmentArtifact_Create.json
// this example is just showing the usage of "Artifacts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// 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
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this BlueprintResource created on azure
// for more information of creating BlueprintResource, please refer to the document of BlueprintResource
string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000";
string blueprintName = "simpleBlueprint";
ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName);
BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId);
// get the collection of this BlueprintArtifactResource
BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts();
// invoke the operation
string artifactName = "ownerAssignment";
ArtifactData data = new RoleAssignmentArtifact("/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7", BinaryData.FromObjectAsJson("[parameters('owners')]"))
{
DisplayName = "enforce owners of given subscription",
};
ArmOperation<BlueprintArtifactResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, artifactName, data);
BlueprintArtifactResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ArtifactData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"properties": {
"displayName": "enforce owners of given subscription",
"roleDefinitionId": "/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7",
"principalIds": "[parameters('owners')]"
},
"kind": "roleAssignment",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Blueprint/blueprints/simpleBlueprint/artifacts/ownerAssignment",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "ownerAssignment"
}
定义
CloudError
Object
名称 |
类型 |
说明 |
error
|
ErrorResponse
|
错误响应
所有 Azure 资源管理器 API 的常见错误响应,以返回失败作的错误详细信息。 (这也遵循 OData 错误响应格式。)
|
ErrorAdditionalInfo
Object
资源管理错误附加信息。
名称 |
类型 |
说明 |
info
|
object
|
其他信息。
|
type
|
string
|
其他信息类型。
|
ErrorResponse
Object
错误响应
keyVaultReference
Object
指定 Key Vault 的链接。
名称 |
类型 |
说明 |
id
|
string
|
Key Vault 的 Azure 资源 ID。
|
ParameterValue
Object
指定参数的值。 可以是“value”或“reference”,但不能同时为两者。
名称 |
类型 |
说明 |
reference
|
SecretValueReference
|
参数值作为引用类型。
|
value
|
object
|
参数值。 允许任何有效的 JSON 值,包括对象、数组、字符串、数字和布尔值。
|
PolicyAssignmentArtifact
Object
应用策略分配的蓝图项目。
名称 |
类型 |
说明 |
id
|
string
|
用于在 Azure 上查找任何资源的字符串 ID。
|
kind
|
string:
policyAssignment
|
指定蓝图项目的类型。
|
name
|
string
|
此资源的名称。
|
properties.dependsOn
|
string[]
|
需要在指定项目之前部署的项目。
|
properties.description
|
string
maxLength: 500
|
多行说明此资源。
|
properties.displayName
|
string
maxLength: 256
|
单行字符串解释此资源。
|
properties.parameters
|
<string,
ParameterValue>
|
策略定义的参数值。
|
properties.policyDefinitionId
|
string
|
策略定义的 Azure 资源 ID。
|
properties.resourceGroup
|
string
|
将向其分配策略的资源组占位符的名称。
|
type
|
string
|
此资源的类型。
|
RoleAssignmentArtifact
Object
应用角色分配的蓝图项目。
名称 |
类型 |
说明 |
id
|
string
|
用于在 Azure 上查找任何资源的字符串 ID。
|
kind
|
string:
roleAssignment
|
指定蓝图项目的类型。
|
name
|
string
|
此资源的名称。
|
properties.dependsOn
|
string[]
|
需要在指定项目之前部署的项目。
|
properties.description
|
string
maxLength: 500
|
多行说明此资源。
|
properties.displayName
|
string
maxLength: 256
|
单行字符串解释此资源。
|
properties.principalIds
|
|
Azure Active Directory 中的用户或组标识数组。 roleDefinition 将应用于每个标识。
|
properties.resourceGroup
|
string
|
RoleAssignment 的范围将限定为此 resourceGroup。 如果为空,则范围限定为订阅。
|
properties.roleDefinitionId
|
string
|
RoleDefinition 的 Azure 资源 ID。
|
type
|
string
|
此资源的类型。
|
SecretValueReference
Object
对 Key Vault 机密的引用。
名称 |
类型 |
说明 |
keyVault
|
keyVaultReference
|
指定对给定 Azure Key Vault 的引用。
|
secretName
|
string
|
机密的名称。
|
secretVersion
|
string
|
要使用的机密版本。 如果留空,则使用最新版本的机密。
|
TemplateArtifact
Object
部署资源管理器模板的蓝图项目。
名称 |
类型 |
说明 |
id
|
string
|
用于在 Azure 上查找任何资源的字符串 ID。
|
kind
|
string:
template
|
指定蓝图项目的类型。
|
name
|
string
|
此资源的名称。
|
properties.dependsOn
|
string[]
|
需要在指定项目之前部署的项目。
|
properties.description
|
string
maxLength: 500
|
多行说明此资源。
|
properties.displayName
|
string
maxLength: 256
|
单行字符串解释此资源。
|
properties.parameters
|
<string,
ParameterValue>
|
资源管理器模板蓝图项目参数值。
|
properties.resourceGroup
|
string
|
如果适用,则会将资源管理器模板蓝图项目部署到的资源组占位符的名称。
|
properties.template
|
object
|
资源管理器模板蓝图项目正文。
|
type
|
string
|
此资源的类型。
|