为订阅创建安全联系人配置
PUT https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}?api-version=2020-01-01-preview
URI 参数
名称 |
在 |
必需 |
类型 |
说明 |
securityContactName
|
path |
True
|
string
|
安全联系人对象的名称
|
subscriptionId
|
path |
True
|
string
|
Azure 订阅 ID
Regex pattern: ^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$
|
api-version
|
query |
True
|
string
|
操作的 API 版本
|
请求正文
名称 |
类型 |
说明 |
properties.alertNotifications
|
AlertNotifications
|
定义是否发送有关新安全警报电子邮件通知
|
properties.emails
|
string
|
此安全联系人中定义的配置将从 Microsoft Defender for Cloud 接收通知的电子邮件地址列表。
|
properties.notificationsByRole
|
NotificationsByRole
|
定义是否将 Microsoft Defender for Cloud 中的电子邮件通知发送给订阅中具有特定 RBAC 角色的人员。
|
properties.phone
|
string
|
安全联系人的电话号码
|
响应
安全性
azure_auth
Azure Active Directory OAuth2 流
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
名称 |
说明 |
user_impersonation
|
模拟用户帐户
|
示例
Sample Request
PUT https://management.azure.com/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/providers/Microsoft.Security/securityContacts/default?api-version=2020-01-01-preview
{
"properties": {
"notificationsByRole": {
"state": "On",
"roles": [
"Owner"
]
},
"emails": "john@contoso.com;jane@contoso.com",
"phone": "(214)275-4038",
"alertNotifications": {
"state": "On",
"minimalSeverity": "Low"
}
}
}
import com.azure.resourcemanager.security.models.MinimalSeverity;
import com.azure.resourcemanager.security.models.Roles;
import com.azure.resourcemanager.security.models.SecurityContactPropertiesAlertNotifications;
import com.azure.resourcemanager.security.models.SecurityContactPropertiesNotificationsByRole;
import com.azure.resourcemanager.security.models.State;
import java.util.Arrays;
/** Samples for SecurityContacts Create. */
public final class Main {
/*
* x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/SecurityContacts/CreateSecurityContact_example.json
*/
/**
* Sample code: Create security contact data.
*
* @param manager Entry point to SecurityManager.
*/
public static void createSecurityContactData(com.azure.resourcemanager.security.SecurityManager manager) {
manager
.securityContacts()
.define("default")
.withEmails("john@contoso.com;jane@contoso.com")
.withPhone("(214)275-4038")
.withAlertNotifications(
new SecurityContactPropertiesAlertNotifications()
.withState(State.fromString("On"))
.withMinimalSeverity(MinimalSeverity.LOW))
.withNotificationsByRole(
new SecurityContactPropertiesNotificationsByRole()
.withState(State.fromString("On"))
.withRoles(Arrays.asList(Roles.OWNER)))
.create();
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armsecurity_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/security/armsecurity"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e716082ac474f182e2220e4f38f1d6191e7636cf/specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/SecurityContacts/CreateSecurityContact_example.json
func ExampleContactsClient_Create() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armsecurity.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewContactsClient().Create(ctx, "default", armsecurity.Contact{
Properties: &armsecurity.ContactProperties{
AlertNotifications: &armsecurity.ContactPropertiesAlertNotifications{
MinimalSeverity: to.Ptr(armsecurity.MinimalSeverityLow),
State: to.Ptr(armsecurity.State("On")),
},
Emails: to.Ptr("john@contoso.com;jane@contoso.com"),
NotificationsByRole: &armsecurity.ContactPropertiesNotificationsByRole{
Roles: []*armsecurity.Roles{
to.Ptr(armsecurity.RolesOwner)},
State: to.Ptr(armsecurity.State("On")),
},
Phone: to.Ptr("(214)275-4038"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Contact = armsecurity.Contact{
// Name: to.Ptr("default"),
// Type: to.Ptr("Microsoft.Security/securityContact"),
// ID: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/providers/Microsoft.Security/securityContacts/default"),
// Properties: &armsecurity.ContactProperties{
// AlertNotifications: &armsecurity.ContactPropertiesAlertNotifications{
// MinimalSeverity: to.Ptr(armsecurity.MinimalSeverityLow),
// State: to.Ptr(armsecurity.State("On")),
// },
// Emails: to.Ptr("john@microsoft.com;jane@microsoft.com"),
// NotificationsByRole: &armsecurity.ContactPropertiesNotificationsByRole{
// Roles: []*armsecurity.Roles{
// to.Ptr(armsecurity.RolesOwner)},
// State: to.Ptr(armsecurity.State("On")),
// },
// Phone: to.Ptr("(214)275-4038"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { SecurityCenter } = require("@azure/arm-security");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create security contact configurations for the subscription
*
* @summary Create security contact configurations for the subscription
* x-ms-original-file: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/SecurityContacts/CreateSecurityContact_example.json
*/
async function createSecurityContactData() {
const subscriptionId =
process.env["SECURITY_SUBSCRIPTION_ID"] || "20ff7fc3-e762-44dd-bd96-b71116dcdc23";
const securityContactName = "default";
const securityContact = {
alertNotifications: { minimalSeverity: "Low", state: "On" },
emails: "john@contoso.com;jane@contoso.com",
notificationsByRole: { roles: ["Owner"], state: "On" },
phone: "(214)275-4038",
};
const credential = new DefaultAzureCredential();
const client = new SecurityCenter(credential, subscriptionId);
const result = await client.securityContacts.create(securityContactName, securityContact);
console.log(result);
}
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.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.SecurityCenter;
using Azure.ResourceManager.SecurityCenter.Models;
// Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/SecurityContacts/CreateSecurityContact_example.json
// this example is just showing the usage of "SecurityContacts_Create" 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 SubscriptionResource created on azure
// for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource
string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23";
ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId);
SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId);
// get the collection of this SecurityContactResource
SecurityContactCollection collection = subscriptionResource.GetSecurityContacts();
// invoke the operation
string securityContactName = "default";
SecurityContactData data = new SecurityContactData()
{
Emails = "john@contoso.com;jane@contoso.com",
Phone = "(214)275-4038",
AlertNotifications = new SecurityContactPropertiesAlertNotifications()
{
State = SecurityAlertNotificationState.On,
MinimalSeverity = SecurityAlertMinimalSeverity.Low,
},
NotificationsByRole = new SecurityContactPropertiesNotificationsByRole()
{
State = SecurityAlertNotificationByRoleState.On,
Roles =
{
SecurityAlertReceivingRole.Owner
},
},
};
ArmOperation<SecurityContactResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityContactName, data);
SecurityContactResource 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
SecurityContactData 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
Sample Response
{
"id": "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/providers/Microsoft.Security/securityContacts/default",
"name": "default",
"type": "Microsoft.Security/securityContact",
"properties": {
"notificationsByRole": {
"state": "On",
"roles": [
"Owner"
]
},
"emails": "john@microsoft.com;jane@microsoft.com",
"phone": "(214)275-4038",
"alertNotifications": {
"state": "On",
"minimalSeverity": "Low"
}
}
}
{
"id": "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/providers/Microsoft.Security/securityContacts/default",
"name": "default",
"type": "Microsoft.Security/securityContact",
"properties": {
"notificationsByRole": {
"state": "On",
"roles": [
"Owner"
]
},
"emails": "john@microsoft.com;jane@microsoft.com",
"phone": "(214)275-4038",
"alertNotifications": {
"state": "On",
"minimalSeverity": "Low"
}
}
}
定义
AlertNotifications
定义是否发送有关新安全警报电子邮件通知
CloudError
对所有 Azure 资源管理器 API 的常见错误响应,可返回失败操作的错误详细信息。 (这也遵循 OData 错误响应格式.) 。
名称 |
类型 |
说明 |
error.additionalInfo
|
ErrorAdditionalInfo[]
|
错误附加信息。
|
error.code
|
string
|
错误代码。
|
error.details
|
CloudErrorBody[]
|
错误详细信息。
|
error.message
|
string
|
错误消息。
|
error.target
|
string
|
错误目标。
|
CloudErrorBody
错误详细信息。
ErrorAdditionalInfo
资源管理错误附加信息。
名称 |
类型 |
说明 |
info
|
object
|
其他信息。
|
type
|
string
|
其他信息类型。
|
minimalSeverity
定义将作为电子邮件通知发送的最低警报严重性
名称 |
类型 |
说明 |
High
|
string
|
获取有关高严重性的新警报的通知
|
Low
|
string
|
不要收到有关低、中或高严重性的新警报的通知
|
Medium
|
string
|
获取有关具有中等或高严重性的新警报的通知
|
NotificationsByRole
定义是否将 Microsoft Defender for Cloud 中的电子邮件通知发送给订阅中具有特定 RBAC 角色的人员。
名称 |
类型 |
说明 |
roles
|
roles[]
|
定义将从 Microsoft Defender for Cloud 获取哪些 RBAC 角色电子邮件通知。 允许的 RBAC 角色列表:
|
state
|
state
|
定义是否将 AMicrosoft Defender for Cloud 中的电子邮件通知发送给订阅中具有特定 RBAC 角色的人员。
|
roles
定义将从 Microsoft Defender for Cloud 获取哪些 RBAC 角色电子邮件通知。 允许的 RBAC 角色列表:
名称 |
类型 |
说明 |
AccountAdmin
|
string
|
如果启用,请向帐户管理员发送有关新警报的通知
|
Contributor
|
string
|
如果启用,请向订阅参与者发送有关新警报的通知
|
Owner
|
string
|
如果启用,请向订阅所有者发送有关新警报的通知
|
ServiceAdmin
|
string
|
如果启用,请向服务管理员发送有关新警报的通知
|
来自 Microsoft Defender for Cloud 的通知的联系人详细信息和配置。
名称 |
类型 |
说明 |
id
|
string
|
资源 ID
|
name
|
string
|
资源名称
|
properties.alertNotifications
|
AlertNotifications
|
定义是否发送有关新安全警报电子邮件通知
|
properties.emails
|
string
|
此安全联系人中定义的配置将从 Microsoft Defender for Cloud 接收通知的电子邮件地址列表。
|
properties.notificationsByRole
|
NotificationsByRole
|
定义是否将 Microsoft Defender for Cloud 中的电子邮件通知发送给订阅中具有特定 RBAC 角色的人员。
|
properties.phone
|
string
|
安全联系人的电话号码
|
type
|
string
|
资源类型
|
state
定义是否发送有关新安全警报的电子邮件通知
名称 |
类型 |
说明 |
Off
|
string
|
不要收到有关新警报的通知
|
On
|
string
|
获取有关新警报的通知
|