创建或更新蓝图分配。
PUT https://management.azure.com/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}?api-version=2018-11-01-preview
URI 参数
名称 |
在 |
必需 |
类型 |
说明 |
assignmentName
|
path |
True
|
string
|
蓝图分配的名称。
|
resourceScope
|
path |
True
|
string
|
资源的范围。 有效范围包括:管理组(格式:'/providers/Microsoft.Management/managementGroups/{managementGroup}')、订阅(格式:'/subscriptions/{subscriptionId}')。
|
api-version
|
query |
True
|
string
|
客户端 API 版本。
|
请求正文
名称 |
必需 |
类型 |
说明 |
identity
|
True
|
ManagedServiceIdentity
|
此蓝图分配的托管标识。
|
location
|
True
|
string
|
此蓝图分配的位置。
|
properties.parameters
|
True
|
<string,
ParameterValue>
|
蓝图分配参数值。
|
properties.resourceGroups
|
True
|
<string,
ResourceGroupValue>
|
资源组占位符的名称和位置。
|
properties.blueprintId
|
|
string
|
蓝图定义的已发布版本的 ID。
|
properties.description
|
|
string
maxLength: 500
|
多行说明此资源。
|
properties.displayName
|
|
string
maxLength: 256
|
单行字符串解释此资源。
|
properties.locks
|
|
AssignmentLockSettings
|
定义蓝图分配部署的资源被锁定的方式。
|
properties.scope
|
|
string
|
蓝图分配的目标订阅范围(格式:“/subscriptions/{subscriptionId}”。 对于管理组级别分配,属性是必需的。
|
响应
安全性
azure_auth
Azure Active Directory OAuth2 Flow
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
名称 |
说明 |
user_impersonation
|
模拟用户帐户
|
示例
Assignment with system-assigned managed identity at management group scope
示例请求
PUT https://management.azure.com/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprintAssignments/assignSimpleBlueprint?api-version=2018-11-01-preview
{
"identity": {
"type": "SystemAssigned"
},
"location": "eastus",
"properties": {
"description": "enforce pre-defined simpleBlueprint to this XXXXXXXX subscription.",
"blueprintId": "/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint",
"scope": "subscriptions/00000000-0000-0000-0000-000000000000",
"parameters": {
"storageAccountType": {
"value": "Standard_LRS"
},
"costCenter": {
"value": "Contoso/Online/Shopping/Production"
},
"owners": {
"value": [
"johnDoe@contoso.com",
"johnsteam@contoso.com"
]
}
},
"resourceGroups": {
"storageRG": {
"name": "defaultRG",
"location": "eastus"
}
}
}
}
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/managementGroupBPAssignment/BlueprintAssignment_Create_SystemAssignedMSI.json
func ExampleAssignmentsClient_CreateOrUpdate_assignmentWithSystemAssignedManagedIdentityAtManagementGroupScope() {
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.NewAssignmentsClient().CreateOrUpdate(ctx, "managementGroups/ContosoOnlineGroup", "assignSimpleBlueprint", armblueprint.Assignment{
Location: to.Ptr("eastus"),
Identity: &armblueprint.ManagedServiceIdentity{
Type: to.Ptr(armblueprint.ManagedServiceIdentityTypeSystemAssigned),
},
Properties: &armblueprint.AssignmentProperties{
Description: to.Ptr("enforce pre-defined simpleBlueprint to this XXXXXXXX subscription."),
BlueprintID: to.Ptr("/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint"),
Parameters: map[string]*armblueprint.ParameterValue{
"costCenter": {
Value: "Contoso/Online/Shopping/Production",
},
"owners": {
Value: []any{
"johnDoe@contoso.com",
"johnsteam@contoso.com",
},
},
"storageAccountType": {
Value: "Standard_LRS",
},
},
ResourceGroups: map[string]*armblueprint.ResourceGroupValue{
"storageRG": {
Name: to.Ptr("defaultRG"),
Location: to.Ptr("eastus"),
},
},
Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"),
},
}, 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 System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Blueprint;
using Azure.ResourceManager.Blueprint.Models;
using Azure.ResourceManager.Models;
// Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPAssignment/BlueprintAssignment_Create_SystemAssignedMSI.json
// this example is just showing the usage of "Assignments_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 AssignmentResource created on azure
// for more information of creating AssignmentResource, please refer to the document of AssignmentResource
string resourceScope = "managementGroups/ContosoOnlineGroup";
string assignmentName = "assignSimpleBlueprint";
ResourceIdentifier assignmentResourceId = AssignmentResource.CreateResourceIdentifier(resourceScope, assignmentName);
AssignmentResource assignment = client.GetAssignmentResource(assignmentResourceId);
// invoke the operation
AssignmentData data = new AssignmentData(new Models.ManagedServiceIdentity(ManagedServiceIdentityType.SystemAssigned), new Dictionary<string, ParameterValue>()
{
["costCenter"] = new ParameterValue()
{
Value = BinaryData.FromString("Contoso/Online/Shopping/Production"),
},
["owners"] = new ParameterValue()
{
Value = BinaryData.FromObjectAsJson(new object[] { "johnDoe@contoso.com", "johnsteam@contoso.com" }),
},
["storageAccountType"] = new ParameterValue()
{
Value = BinaryData.FromString("Standard_LRS"),
},
}, new Dictionary<string, ResourceGroupValue>()
{
["storageRG"] = new ResourceGroupValue()
{
Name = "defaultRG",
Location = new AzureLocation("eastus"),
},
}, new AzureLocation("eastus"))
{
Description = "enforce pre-defined simpleBlueprint to this XXXXXXXX subscription.",
BlueprintId = "/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint",
Scope = "subscriptions/00000000-0000-0000-0000-000000000000",
};
ArmOperation<AssignmentResource> lro = await assignment.UpdateAsync(WaitUntil.Completed, data);
AssignmentResource 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
AssignmentData 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
示例响应
{
"identity": {
"type": "SystemAssigned",
"tenantId": "00000000-0000-0000-0000-000000000000",
"principalId": "00000000-0000-0000-0000-000000000000"
},
"location": "eastus",
"properties": {
"description": "enforce pre-defined simpleBlueprint to this XXXXXXXX subscription.",
"provisioningState": "creating",
"blueprintId": "/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint",
"scope": "subscriptions/00000000-0000-0000-0000-000000000000",
"parameters": {
"storageAccountType": {
"value": "Standard_LRS"
},
"costCenter": {
"value": "Contoso/Online/Shopping/Production"
},
"owners": {
"value": [
"johnDoe@contoso.com",
"johnsteam@contoso.com"
]
}
},
"resourceGroups": {
"storageRG": {
"name": "defaultRG",
"location": "eastus"
}
}
},
"id": "/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprintAssignments/assignSimpleBlueprint",
"type": "Microsoft.Blueprint/Assignment",
"name": "assignSimpleBlueprint"
}
Assignment with system-assigned managed identity at subscription scope
示例请求
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Blueprint/blueprintAssignments/assignSimpleBlueprint?api-version=2018-11-01-preview
{
"identity": {
"type": "SystemAssigned"
},
"location": "eastus",
"properties": {
"description": "enforce pre-defined simpleBlueprint to this XXXXXXXX subscription.",
"blueprintId": "/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint",
"parameters": {
"storageAccountType": {
"value": "Standard_LRS"
},
"costCenter": {
"value": "Contoso/Online/Shopping/Production"
},
"owners": {
"value": [
"johnDoe@contoso.com",
"johnsteam@contoso.com"
]
}
},
"resourceGroups": {
"storageRG": {
"name": "defaultRG",
"location": "eastus"
}
}
}
}
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/subscriptionBPAssignment/BlueprintAssignment_Create_SystemAssignedMSI.json
func ExampleAssignmentsClient_CreateOrUpdate_assignmentWithSystemAssignedManagedIdentityAtSubscriptionScope() {
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.NewAssignmentsClient().CreateOrUpdate(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "assignSimpleBlueprint", armblueprint.Assignment{
Location: to.Ptr("eastus"),
Identity: &armblueprint.ManagedServiceIdentity{
Type: to.Ptr(armblueprint.ManagedServiceIdentityTypeSystemAssigned),
},
Properties: &armblueprint.AssignmentProperties{
Description: to.Ptr("enforce pre-defined simpleBlueprint to this XXXXXXXX subscription."),
BlueprintID: to.Ptr("/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint"),
Parameters: map[string]*armblueprint.ParameterValue{
"costCenter": {
Value: "Contoso/Online/Shopping/Production",
},
"owners": {
Value: []any{
"johnDoe@contoso.com",
"johnsteam@contoso.com",
},
},
"storageAccountType": {
Value: "Standard_LRS",
},
},
ResourceGroups: map[string]*armblueprint.ResourceGroupValue{
"storageRG": {
Name: to.Ptr("defaultRG"),
Location: to.Ptr("eastus"),
},
},
},
}, 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 System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Blueprint;
using Azure.ResourceManager.Blueprint.Models;
using Azure.ResourceManager.Models;
// Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPAssignment/BlueprintAssignment_Create_SystemAssignedMSI.json
// this example is just showing the usage of "Assignments_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 AssignmentResource created on azure
// for more information of creating AssignmentResource, please refer to the document of AssignmentResource
string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000";
string assignmentName = "assignSimpleBlueprint";
ResourceIdentifier assignmentResourceId = AssignmentResource.CreateResourceIdentifier(resourceScope, assignmentName);
AssignmentResource assignment = client.GetAssignmentResource(assignmentResourceId);
// invoke the operation
AssignmentData data = new AssignmentData(new Models.ManagedServiceIdentity(ManagedServiceIdentityType.SystemAssigned), new Dictionary<string, ParameterValue>()
{
["costCenter"] = new ParameterValue()
{
Value = BinaryData.FromString("Contoso/Online/Shopping/Production"),
},
["owners"] = new ParameterValue()
{
Value = BinaryData.FromObjectAsJson(new object[] { "johnDoe@contoso.com", "johnsteam@contoso.com" }),
},
["storageAccountType"] = new ParameterValue()
{
Value = BinaryData.FromString("Standard_LRS"),
},
}, new Dictionary<string, ResourceGroupValue>()
{
["storageRG"] = new ResourceGroupValue()
{
Name = "defaultRG",
Location = new AzureLocation("eastus"),
},
}, new AzureLocation("eastus"))
{
Description = "enforce pre-defined simpleBlueprint to this XXXXXXXX subscription.",
BlueprintId = "/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint",
};
ArmOperation<AssignmentResource> lro = await assignment.UpdateAsync(WaitUntil.Completed, data);
AssignmentResource 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
AssignmentData 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
示例响应
{
"identity": {
"type": "SystemAssigned",
"tenantId": "00000000-0000-0000-0000-000000000000",
"principalId": "00000000-0000-0000-0000-000000000000"
},
"location": "eastus",
"properties": {
"description": "enforce pre-defined simpleBlueprint to this XXXXXXXX subscription.",
"provisioningState": "creating",
"blueprintId": "/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint",
"parameters": {
"storageAccountType": {
"value": "Standard_LRS"
},
"costCenter": {
"value": "Contoso/Online/Shopping/Production"
},
"owners": {
"value": [
"johnDoe@contoso.com",
"johnsteam@contoso.com"
]
}
},
"resourceGroups": {
"storageRG": {
"name": "defaultRG",
"location": "eastus"
}
}
},
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Blueprint/blueprintAssignments/assignSimpleBlueprint",
"type": "Microsoft.Blueprint/Assignment",
"name": "assignSimpleBlueprint"
}
Assignment with user-assigned managed identity at management group scope
示例请求
PUT https://management.azure.com/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprintAssignments/assignSimpleBlueprint?api-version=2018-11-01-preview
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity": {}
}
},
"location": "eastus",
"properties": {
"description": "enforce pre-defined simpleBlueprint to this XXXXXXXX subscription.",
"blueprintId": "/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint",
"scope": "subscriptions/00000000-0000-0000-0000-000000000000",
"parameters": {
"storageAccountType": {
"value": "Standard_LRS"
},
"costCenter": {
"value": "Contoso/Online/Shopping/Production"
},
"owners": {
"value": [
"johnDoe@contoso.com",
"johnsteam@contoso.com"
]
}
},
"resourceGroups": {
"storageRG": {
"name": "defaultRG",
"location": "eastus"
}
}
}
}
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/managementGroupBPAssignment/BlueprintAssignment_Create_UserAssignedMSI.json
func ExampleAssignmentsClient_CreateOrUpdate_assignmentWithUserAssignedManagedIdentityAtManagementGroupScope() {
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.NewAssignmentsClient().CreateOrUpdate(ctx, "managementGroups/ContosoOnlineGroup", "assignSimpleBlueprint", armblueprint.Assignment{
Location: to.Ptr("eastus"),
Identity: &armblueprint.ManagedServiceIdentity{
Type: to.Ptr(armblueprint.ManagedServiceIdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armblueprint.UserAssignedIdentity{
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity": {},
},
},
Properties: &armblueprint.AssignmentProperties{
Description: to.Ptr("enforce pre-defined simpleBlueprint to this XXXXXXXX subscription."),
BlueprintID: to.Ptr("/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint"),
Parameters: map[string]*armblueprint.ParameterValue{
"costCenter": {
Value: "Contoso/Online/Shopping/Production",
},
"owners": {
Value: []any{
"johnDoe@contoso.com",
"johnsteam@contoso.com",
},
},
"storageAccountType": {
Value: "Standard_LRS",
},
},
ResourceGroups: map[string]*armblueprint.ResourceGroupValue{
"storageRG": {
Name: to.Ptr("defaultRG"),
Location: to.Ptr("eastus"),
},
},
Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"),
},
}, 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 System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Blueprint;
using Azure.ResourceManager.Blueprint.Models;
using Azure.ResourceManager.Models;
// Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPAssignment/BlueprintAssignment_Create_UserAssignedMSI.json
// this example is just showing the usage of "Assignments_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 AssignmentResource created on azure
// for more information of creating AssignmentResource, please refer to the document of AssignmentResource
string resourceScope = "managementGroups/ContosoOnlineGroup";
string assignmentName = "assignSimpleBlueprint";
ResourceIdentifier assignmentResourceId = AssignmentResource.CreateResourceIdentifier(resourceScope, assignmentName);
AssignmentResource assignment = client.GetAssignmentResource(assignmentResourceId);
// invoke the operation
AssignmentData data = new AssignmentData(new Models.ManagedServiceIdentity(ManagedServiceIdentityType.UserAssigned)
{
UserAssignedIdentities =
{
["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity"] = new UserAssignedIdentity(),
},
}, new Dictionary<string, ParameterValue>()
{
["costCenter"] = new ParameterValue()
{
Value = BinaryData.FromString("Contoso/Online/Shopping/Production"),
},
["owners"] = new ParameterValue()
{
Value = BinaryData.FromObjectAsJson(new object[] { "johnDoe@contoso.com", "johnsteam@contoso.com" }),
},
["storageAccountType"] = new ParameterValue()
{
Value = BinaryData.FromString("Standard_LRS"),
},
}, new Dictionary<string, ResourceGroupValue>()
{
["storageRG"] = new ResourceGroupValue()
{
Name = "defaultRG",
Location = new AzureLocation("eastus"),
},
}, new AzureLocation("eastus"))
{
Description = "enforce pre-defined simpleBlueprint to this XXXXXXXX subscription.",
BlueprintId = "/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint",
Scope = "subscriptions/00000000-0000-0000-0000-000000000000",
};
ArmOperation<AssignmentResource> lro = await assignment.UpdateAsync(WaitUntil.Completed, data);
AssignmentResource 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
AssignmentData 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
示例响应
{
"identity": {
"type": "UserAssigned",
"tenantId": "00000000-0000-0000-0000-000000000000",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity": {
"principalId": "00000000-0000-0000-0000-000000000000",
"clientId": "00000000-0000-0000-0000-000000000000"
}
}
},
"location": "eastus",
"properties": {
"description": "enforce pre-defined simpleBlueprint to this XXXXXXXX subscription.",
"provisioningState": "creating",
"blueprintId": "/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint",
"scope": "subscriptions/00000000-0000-0000-0000-000000000000",
"parameters": {
"storageAccountType": {
"value": "Standard_LRS"
},
"costCenter": {
"value": "Contoso/Online/Shopping/Production"
},
"owners": {
"value": [
"johnDoe@contoso.com",
"johnsteam@contoso.com"
]
}
},
"resourceGroups": {
"storageRG": {
"name": "defaultRG",
"location": "eastus"
}
}
},
"id": "/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprintAssignments/assignSimpleBlueprint",
"type": "Microsoft.Blueprint/Assignment",
"name": "assignSimpleBlueprint"
}
Assignment with user-assigned managed identity at subscription scope
示例请求
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Blueprint/blueprintAssignments/assignSimpleBlueprint?api-version=2018-11-01-preview
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity": {}
}
},
"location": "eastus",
"properties": {
"description": "enforce pre-defined simpleBlueprint to this XXXXXXXX subscription.",
"blueprintId": "/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint",
"parameters": {
"storageAccountType": {
"value": "Standard_LRS"
},
"costCenter": {
"value": "Contoso/Online/Shopping/Production"
},
"owners": {
"value": [
"johnDoe@contoso.com",
"johnsteam@contoso.com"
]
}
},
"resourceGroups": {
"storageRG": {
"name": "defaultRG",
"location": "eastus"
}
}
}
}
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/subscriptionBPAssignment/BlueprintAssignment_Create_UserAssignedMSI.json
func ExampleAssignmentsClient_CreateOrUpdate_assignmentWithUserAssignedManagedIdentityAtSubscriptionScope() {
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.NewAssignmentsClient().CreateOrUpdate(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "assignSimpleBlueprint", armblueprint.Assignment{
Location: to.Ptr("eastus"),
Identity: &armblueprint.ManagedServiceIdentity{
Type: to.Ptr(armblueprint.ManagedServiceIdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armblueprint.UserAssignedIdentity{
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity": {},
},
},
Properties: &armblueprint.AssignmentProperties{
Description: to.Ptr("enforce pre-defined simpleBlueprint to this XXXXXXXX subscription."),
BlueprintID: to.Ptr("/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint"),
Parameters: map[string]*armblueprint.ParameterValue{
"costCenter": {
Value: "Contoso/Online/Shopping/Production",
},
"owners": {
Value: []any{
"johnDoe@contoso.com",
"johnsteam@contoso.com",
},
},
"storageAccountType": {
Value: "Standard_LRS",
},
},
ResourceGroups: map[string]*armblueprint.ResourceGroupValue{
"storageRG": {
Name: to.Ptr("defaultRG"),
Location: to.Ptr("eastus"),
},
},
},
}, 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 System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Blueprint;
using Azure.ResourceManager.Blueprint.Models;
using Azure.ResourceManager.Models;
// Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPAssignment/BlueprintAssignment_Create_UserAssignedMSI.json
// this example is just showing the usage of "Assignments_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 AssignmentResource created on azure
// for more information of creating AssignmentResource, please refer to the document of AssignmentResource
string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000";
string assignmentName = "assignSimpleBlueprint";
ResourceIdentifier assignmentResourceId = AssignmentResource.CreateResourceIdentifier(resourceScope, assignmentName);
AssignmentResource assignment = client.GetAssignmentResource(assignmentResourceId);
// invoke the operation
AssignmentData data = new AssignmentData(new Models.ManagedServiceIdentity(ManagedServiceIdentityType.UserAssigned)
{
UserAssignedIdentities =
{
["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity"] = new UserAssignedIdentity(),
},
}, new Dictionary<string, ParameterValue>()
{
["costCenter"] = new ParameterValue()
{
Value = BinaryData.FromString("Contoso/Online/Shopping/Production"),
},
["owners"] = new ParameterValue()
{
Value = BinaryData.FromObjectAsJson(new object[] { "johnDoe@contoso.com", "johnsteam@contoso.com" }),
},
["storageAccountType"] = new ParameterValue()
{
Value = BinaryData.FromString("Standard_LRS"),
},
}, new Dictionary<string, ResourceGroupValue>()
{
["storageRG"] = new ResourceGroupValue()
{
Name = "defaultRG",
Location = new AzureLocation("eastus"),
},
}, new AzureLocation("eastus"))
{
Description = "enforce pre-defined simpleBlueprint to this XXXXXXXX subscription.",
BlueprintId = "/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint",
};
ArmOperation<AssignmentResource> lro = await assignment.UpdateAsync(WaitUntil.Completed, data);
AssignmentResource 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
AssignmentData 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
示例响应
{
"identity": {
"type": "UserAssigned",
"tenantId": "00000000-0000-0000-0000-000000000000",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity": {
"principalId": "00000000-0000-0000-0000-000000000000",
"clientId": "00000000-0000-0000-0000-000000000000"
}
}
},
"location": "eastus",
"properties": {
"description": "enforce pre-defined simpleBlueprint to this XXXXXXXX subscription.",
"provisioningState": "creating",
"blueprintId": "/providers/Microsoft.Management/managementGroups/ContosoOnlineGroup/providers/Microsoft.Blueprint/blueprints/simpleBlueprint",
"parameters": {
"storageAccountType": {
"value": "Standard_LRS"
},
"costCenter": {
"value": "Contoso/Online/Shopping/Production"
},
"owners": {
"value": [
"johnDoe@contoso.com",
"johnsteam@contoso.com"
]
}
},
"resourceGroups": {
"storageRG": {
"name": "defaultRG",
"location": "eastus"
}
}
},
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Blueprint/blueprintAssignments/assignSimpleBlueprint",
"type": "Microsoft.Blueprint/Assignment",
"name": "assignSimpleBlueprint"
}
定义
Assignment
Object
表示蓝图分配。
名称 |
类型 |
说明 |
id
|
string
|
用于在 Azure 上查找任何资源的字符串 ID。
|
identity
|
ManagedServiceIdentity
|
此蓝图分配的托管标识。
|
location
|
string
|
此蓝图分配的位置。
|
name
|
string
|
此资源的名称。
|
properties.blueprintId
|
string
|
蓝图定义的已发布版本的 ID。
|
properties.description
|
string
maxLength: 500
|
多行说明此资源。
|
properties.displayName
|
string
maxLength: 256
|
单行字符串解释此资源。
|
properties.locks
|
AssignmentLockSettings
|
定义蓝图分配部署的资源被锁定的方式。
|
properties.parameters
|
<string,
ParameterValue>
|
蓝图分配参数值。
|
properties.provisioningState
|
AssignmentProvisioningState
|
蓝图分配的状态。
|
properties.resourceGroups
|
<string,
ResourceGroupValue>
|
资源组占位符的名称和位置。
|
properties.scope
|
string
|
蓝图分配的目标订阅范围(格式:“/subscriptions/{subscriptionId}”。 对于管理组级别分配,属性是必需的。
|
properties.status
|
AssignmentStatus
|
蓝图分配的状态。 此字段是只读的。
|
type
|
string
|
此资源的类型。
|
AssignmentLockMode
枚举
锁定模式。
值 |
说明 |
AllResourcesDoNotDelete
|
|
AllResourcesReadOnly
|
|
None
|
|
AssignmentLockSettings
Object
定义蓝图分配部署的资源被锁定的方式。
名称 |
类型 |
说明 |
excludedActions
|
string[]
|
从蓝图锁中排除的管理操作列表。 最多允许 200 个作。 如果锁定模式设置为“AllResourcesReadOnly”,则以下操作会自动追加到“excludedActions”、“Microsoft.Network/virtualNetworks/subnets/join/action”和“Microsoft.Authorization/locks/delete”。 如果锁定模式设置为“AllResourcesDoNotDelete”,则以下操作会自动追加到“excludedActions”:“Microsoft.Authorization/locks/delete”。 将删除重复的操作。
|
excludedPrincipals
|
string[]
|
从蓝图锁中排除的 AAD 主体列表。 最多允许 5 个主体。
|
mode
|
AssignmentLockMode
|
锁定模式。
|
AssignmentProvisioningState
枚举
蓝图分配的状态。
值 |
说明 |
canceled
|
|
cancelling
|
|
creating
|
|
deleting
|
|
deploying
|
|
failed
|
|
locking
|
|
succeeded
|
|
validating
|
|
waiting
|
|
AssignmentStatus
Object
蓝图分配的状态。 此字段是只读的。
名称 |
类型 |
说明 |
lastModified
|
string
(date-time)
|
此蓝图定义的上次修改时间。
|
managedResources
|
string[]
|
蓝图分配创建的资源列表。
|
timeCreated
|
string
(date-time)
|
此蓝图定义的创建时间。
|
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。
|
ManagedServiceIdentity
Object
托管标识泛型对象。
名称 |
类型 |
说明 |
principalId
|
string
|
与此标识关联的 Azure Active Directory 主体 ID。
|
tenantId
|
string
|
Azure Active Directory 的 ID。
|
type
|
ManagedServiceIdentityType
|
托管标识的类型。
|
userAssignedIdentities
|
<string,
UserAssignedIdentity>
|
与资源关联的用户分配托管标识的列表。 密钥是托管标识的 Azure 资源 ID。
|
ManagedServiceIdentityType
枚举
托管标识的类型。
值 |
说明 |
None
|
|
SystemAssigned
|
|
UserAssigned
|
|
ParameterValue
Object
指定参数的值。 可以是“value”或“reference”,但不能同时为两者。
名称 |
类型 |
说明 |
reference
|
SecretValueReference
|
参数值作为引用类型。
|
value
|
object
|
参数值。 允许任何有效的 JSON 值,包括对象、数组、字符串、数字和布尔值。
|
ResourceGroupValue
Object
表示 Azure 资源组。
名称 |
类型 |
说明 |
location
|
string
|
资源组的位置。
|
name
|
string
minLength: 1 maxLength: 90
|
资源组的名称。
|
SecretValueReference
Object
对 Key Vault 机密的引用。
名称 |
类型 |
说明 |
keyVault
|
keyVaultReference
|
指定对给定 Azure Key Vault 的引用。
|
secretName
|
string
|
机密的名称。
|
secretVersion
|
string
|
要使用的机密版本。 如果留空,则使用最新版本的机密。
|
UserAssignedIdentity
Object
用户分配的托管标识。
名称 |
类型 |
说明 |
clientId
|
string
|
与此标识关联的客户端应用 ID。
|
principalId
|
string
|
与此标识关联的 Azure Active Directory 主体 ID。
|