Espace de noms : microsoft.graph.networkaccess
Importante
Les API sous la version /beta dans Microsoft Graph sont susceptibles d’être modifiées. L’utilisation de ces API dans des applications de production n’est pas prise en charge. Pour déterminer si une API est disponible dans v1.0, utilisez le sélecteur Version .
Créez un objet cloudFirewallRule dans un cloudFirewallPolicy.
Cette API est disponible dans les déploiements de cloud national suivants.
| Service global |
Gouvernement des États-Unis L4 |
Us Government L5 (DOD) |
Chine gérée par 21Vianet |
| ✅ |
❌ |
❌ |
❌ |
Autorisations
Choisissez l’autorisation ou les autorisations marquées comme moins privilégiées pour cette API. Utilisez une autorisation ou des autorisations privilégiées plus élevées uniquement si votre application en a besoin. Pour plus d’informations sur les autorisations déléguées et d’application, consultez Types d’autorisations. Pour en savoir plus sur ces autorisations, consultez les informations de référence sur les autorisations.
| Type d’autorisation |
Autorisations avec privilèges minimum |
Autorisations privilégiées plus élevées |
| Déléguée (compte professionnel ou scolaire) |
NetworkAccess.ReadWrite.All |
Non disponible. |
| Déléguée (compte Microsoft personnel) |
Non prise en charge. |
Non prise en charge. |
| Application |
NetworkAccess.ReadWrite.All |
Non disponible. |
Importante
Pour l’accès délégué à l’aide de comptes professionnels ou scolaires, l’utilisateur connecté doit se voir attribuer un rôle de Microsoft Entra pris en charge ou un rôle personnalisé qui accorde les autorisations requises pour cette opération. Cette opération prend en charge les rôles intégrés suivants, qui fournissent uniquement le moindre privilège nécessaire :
- Administrateur général de l’accès sécurisé
- Administrateur de sécurité
Requête HTTP
POST /networkAccess/cloudFirewallPolicies/{cloudFirewallPolicyId}/policyRules
Corps de la demande
Dans le corps de la demande, fournissez une représentation JSON de l’objet cloudFirewallRule .
Vous pouvez spécifier les propriétés suivantes lors de la création d’un cloudFirewallRule.
Réponse
Si elle réussit, cette méthode renvoie un 201 Created code de réponse et un objet cloudFirewallRule dans le corps de la réponse.
Exemples
Demande
L’exemple suivant montre une requête qui crée une règle pour bloquer le trafic spécifique. Les conditions correspondantes utilisent la logique AND entre les propriétés (les sources et les destinations doivent correspondre), tandis que les éléments des collections utilisent la logique OR (n’importe quelle adresse ou port peut correspondre).
POST https://graph.microsoft.com/beta/networkAccess/cloudFirewallPolicies/80b58b7d-572f-4457-8944-c804fcf3b694/policyRules
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.networkaccess.cloudFirewallRule",
"name": "Block outbound to risky destinations",
"description": "Block traffic to specific IPs on common ports",
"priority": 100,
"action": "block",
"settings": {
"status": "enabled"
},
"matchingConditions": {
"sources": {
"addresses": [
{
"@odata.type": "#microsoft.graph.networkaccess.cloudFirewallSourceIpAddress",
"values": ["192.168.1.1", "192.168.0.0/16", "172.16.0.0-172.16.255.255"]
}
],
"ports": ["80", "443", "445-447"]
},
"destinations": {
"addresses": [
{
"@odata.type": "#microsoft.graph.networkaccess.cloudFirewallDestinationIpAddress",
"values": ["10.0.0.1"]
}
],
"ports": ["80", "443", "445-447"],
"protocols": "tcp"
}
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models.Networkaccess;
var requestBody = new CloudFirewallRule
{
OdataType = "#microsoft.graph.networkaccess.cloudFirewallRule",
Name = "Block outbound to risky destinations",
Description = "Block traffic to specific IPs on common ports",
Priority = 100L,
Action = CloudFirewallAction.Block,
Settings = new CloudFirewallRuleSettings
{
Status = SecurityRuleStatus.Enabled,
},
MatchingConditions = new CloudFirewallMatchingConditions
{
Sources = new CloudFirewallSourceMatching
{
Addresses = new List<CloudFirewallSourceAddress>
{
new CloudFirewallSourceIpAddress
{
OdataType = "#microsoft.graph.networkaccess.cloudFirewallSourceIpAddress",
Values = new List<string>
{
"192.168.1.1",
"192.168.0.0/16",
"172.16.0.0-172.16.255.255",
},
},
},
Ports = new List<string>
{
"80",
"443",
"445-447",
},
},
Destinations = new CloudFirewallDestinationMatching
{
Addresses = new List<CloudFirewallDestinationAddress>
{
new CloudFirewallDestinationIpAddress
{
OdataType = "#microsoft.graph.networkaccess.cloudFirewallDestinationIpAddress",
Values = new List<string>
{
"10.0.0.1",
},
},
},
Ports = new List<string>
{
"80",
"443",
"445-447",
},
Protocols = CloudFirewallProtocol.Tcp,
},
},
};
// To initialize your graphClient, see https://dotnet.territoriali.olinfo.it/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.NetworkAccess.CloudFirewallPolicies["{cloudFirewallPolicy-id}"].PolicyRules.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodelsnetworkaccess "github.com/microsoftgraph/msgraph-beta-sdk-go/models/networkaccess"
//other-imports
)
requestBody := graphmodelsnetworkaccess.NewPolicyRule()
name := "Block outbound to risky destinations"
requestBody.SetName(&name)
description := "Block traffic to specific IPs on common ports"
requestBody.SetDescription(&description)
priority := int64(100)
requestBody.SetPriority(&priority)
action := graphmodels.BLOCK_CLOUDFIREWALLACTION
requestBody.SetAction(&action)
settings := graphmodelsnetworkaccess.NewCloudFirewallRuleSettings()
status := graphmodels.ENABLED_SECURITYRULESTATUS
settings.SetStatus(&status)
requestBody.SetSettings(settings)
matchingConditions := graphmodelsnetworkaccess.NewCloudFirewallMatchingConditions()
sources := graphmodelsnetworkaccess.NewCloudFirewallSourceMatching()
cloudFirewallSourceAddress := graphmodelsnetworkaccess.NewCloudFirewallSourceIpAddress()
values := []string {
"192.168.1.1",
"192.168.0.0/16",
"172.16.0.0-172.16.255.255",
}
cloudFirewallSourceAddress.SetValues(values)
addresses := []graphmodelsnetworkaccess.CloudFirewallSourceAddressable {
cloudFirewallSourceAddress,
}
sources.SetAddresses(addresses)
ports := []string {
"80",
"443",
"445-447",
}
sources.SetPorts(ports)
matchingConditions.SetSources(sources)
destinations := graphmodelsnetworkaccess.NewCloudFirewallDestinationMatching()
cloudFirewallDestinationAddress := graphmodelsnetworkaccess.NewCloudFirewallDestinationIpAddress()
values := []string {
"10.0.0.1",
}
cloudFirewallDestinationAddress.SetValues(values)
addresses := []graphmodelsnetworkaccess.CloudFirewallDestinationAddressable {
cloudFirewallDestinationAddress,
}
destinations.SetAddresses(addresses)
ports := []string {
"80",
"443",
"445-447",
}
destinations.SetPorts(ports)
protocols := graphmodels.TCP_CLOUDFIREWALLPROTOCOL
destinations.SetProtocols(&protocols)
matchingConditions.SetDestinations(destinations)
requestBody.SetMatchingConditions(matchingConditions)
// To initialize your graphClient, see https://dotnet.territoriali.olinfo.it/en-us/graph/sdks/create-client?from=snippets&tabs=go
policyRules, err := graphClient.NetworkAccess().CloudFirewallPolicies().ByCloudFirewallPolicyId("cloudFirewallPolicy-id").PolicyRules().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.models.networkaccess.CloudFirewallRule policyRule = new com.microsoft.graph.beta.models.networkaccess.CloudFirewallRule();
policyRule.setOdataType("#microsoft.graph.networkaccess.cloudFirewallRule");
policyRule.setName("Block outbound to risky destinations");
policyRule.setDescription("Block traffic to specific IPs on common ports");
policyRule.setPriority(100L);
policyRule.setAction(com.microsoft.graph.beta.models.networkaccess.CloudFirewallAction.Block);
com.microsoft.graph.beta.models.networkaccess.CloudFirewallRuleSettings settings = new com.microsoft.graph.beta.models.networkaccess.CloudFirewallRuleSettings();
settings.setStatus(com.microsoft.graph.beta.models.networkaccess.SecurityRuleStatus.Enabled);
policyRule.setSettings(settings);
com.microsoft.graph.beta.models.networkaccess.CloudFirewallMatchingConditions matchingConditions = new com.microsoft.graph.beta.models.networkaccess.CloudFirewallMatchingConditions();
com.microsoft.graph.beta.models.networkaccess.CloudFirewallSourceMatching sources = new com.microsoft.graph.beta.models.networkaccess.CloudFirewallSourceMatching();
LinkedList<com.microsoft.graph.beta.models.networkaccess.CloudFirewallSourceAddress> addresses = new LinkedList<com.microsoft.graph.beta.models.networkaccess.CloudFirewallSourceAddress>();
com.microsoft.graph.beta.models.networkaccess.CloudFirewallSourceIpAddress cloudFirewallSourceAddress = new com.microsoft.graph.beta.models.networkaccess.CloudFirewallSourceIpAddress();
cloudFirewallSourceAddress.setOdataType("#microsoft.graph.networkaccess.cloudFirewallSourceIpAddress");
LinkedList<String> values = new LinkedList<String>();
values.add("192.168.1.1");
values.add("192.168.0.0/16");
values.add("172.16.0.0-172.16.255.255");
cloudFirewallSourceAddress.setValues(values);
addresses.add(cloudFirewallSourceAddress);
sources.setAddresses(addresses);
LinkedList<String> ports = new LinkedList<String>();
ports.add("80");
ports.add("443");
ports.add("445-447");
sources.setPorts(ports);
matchingConditions.setSources(sources);
com.microsoft.graph.beta.models.networkaccess.CloudFirewallDestinationMatching destinations = new com.microsoft.graph.beta.models.networkaccess.CloudFirewallDestinationMatching();
LinkedList<com.microsoft.graph.beta.models.networkaccess.CloudFirewallDestinationAddress> addresses1 = new LinkedList<com.microsoft.graph.beta.models.networkaccess.CloudFirewallDestinationAddress>();
com.microsoft.graph.beta.models.networkaccess.CloudFirewallDestinationIpAddress cloudFirewallDestinationAddress = new com.microsoft.graph.beta.models.networkaccess.CloudFirewallDestinationIpAddress();
cloudFirewallDestinationAddress.setOdataType("#microsoft.graph.networkaccess.cloudFirewallDestinationIpAddress");
LinkedList<String> values1 = new LinkedList<String>();
values1.add("10.0.0.1");
cloudFirewallDestinationAddress.setValues(values1);
addresses1.add(cloudFirewallDestinationAddress);
destinations.setAddresses(addresses1);
LinkedList<String> ports1 = new LinkedList<String>();
ports1.add("80");
ports1.add("443");
ports1.add("445-447");
destinations.setPorts(ports1);
destinations.setProtocols(EnumSet.of(com.microsoft.graph.beta.models.networkaccess.CloudFirewallProtocol.Tcp));
matchingConditions.setDestinations(destinations);
policyRule.setMatchingConditions(matchingConditions);
com.microsoft.graph.models.networkaccess.PolicyRule result = graphClient.networkAccess().cloudFirewallPolicies().byCloudFirewallPolicyId("{cloudFirewallPolicy-id}").policyRules().post(policyRule);
const options = {
authProvider,
};
const client = Client.init(options);
const policyRule = {
'@odata.type': '#microsoft.graph.networkaccess.cloudFirewallRule',
name: 'Block outbound to risky destinations',
description: 'Block traffic to specific IPs on common ports',
priority: 100,
action: 'block',
settings: {
status: 'enabled'
},
matchingConditions: {
sources: {
addresses: [
{
'@odata.type': '#microsoft.graph.networkaccess.cloudFirewallSourceIpAddress',
values: ['192.168.1.1', '192.168.0.0/16', '172.16.0.0-172.16.255.255']
}
],
ports: ['80', '443', '445-447']
},
destinations: {
addresses: [
{
'@odata.type': '#microsoft.graph.networkaccess.cloudFirewallDestinationIpAddress',
values: ['10.0.0.1']
}
],
ports: ['80', '443', '445-447'],
protocols: 'tcp'
}
}
};
await client.api('/networkAccess/cloudFirewallPolicies/80b58b7d-572f-4457-8944-c804fcf3b694/policyRules')
.version('beta')
.post(policyRule);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Networkaccess\CloudFirewallRule;
use Microsoft\Graph\Beta\Generated\Models\Networkaccess\CloudFirewallAction;
use Microsoft\Graph\Beta\Generated\Models\Networkaccess\CloudFirewallRuleSettings;
use Microsoft\Graph\Beta\Generated\Models\Networkaccess\SecurityRuleStatus;
use Microsoft\Graph\Beta\Generated\Models\Networkaccess\CloudFirewallMatchingConditions;
use Microsoft\Graph\Beta\Generated\Models\Networkaccess\CloudFirewallSourceMatching;
use Microsoft\Graph\Beta\Generated\Models\Networkaccess\CloudFirewallSourceAddress;
use Microsoft\Graph\Beta\Generated\Models\Networkaccess\CloudFirewallSourceIpAddress;
use Microsoft\Graph\Beta\Generated\Models\Networkaccess\CloudFirewallDestinationMatching;
use Microsoft\Graph\Beta\Generated\Models\Networkaccess\CloudFirewallDestinationAddress;
use Microsoft\Graph\Beta\Generated\Models\Networkaccess\CloudFirewallDestinationIpAddress;
use Microsoft\Graph\Beta\Generated\Models\Networkaccess\CloudFirewallProtocol;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new CloudFirewallRule();
$requestBody->setOdataType('#microsoft.graph.networkaccess.cloudFirewallRule');
$requestBody->setName('Block outbound to risky destinations');
$requestBody->setDescription('Block traffic to specific IPs on common ports');
$requestBody->setPriority(100);
$requestBody->setAction(new CloudFirewallAction('block'));
$settings = new CloudFirewallRuleSettings();
$settings->setStatus(new SecurityRuleStatus('enabled'));
$requestBody->setSettings($settings);
$matchingConditions = new CloudFirewallMatchingConditions();
$matchingConditionsSources = new CloudFirewallSourceMatching();
$addressesCloudFirewallSourceAddress1 = new CloudFirewallSourceIpAddress();
$addressesCloudFirewallSourceAddress1->setOdataType('#microsoft.graph.networkaccess.cloudFirewallSourceIpAddress');
$addressesCloudFirewallSourceAddress1->setValues(['192.168.1.1', '192.168.0.0/16', '172.16.0.0-172.16.255.255', ]);
$addressesArray []= $addressesCloudFirewallSourceAddress1;
$matchingConditionsSources->setAddresses($addressesArray);
$matchingConditionsSources->setPorts(['80', '443', '445-447', ]);
$matchingConditions->setSources($matchingConditionsSources);
$matchingConditionsDestinations = new CloudFirewallDestinationMatching();
$addressesCloudFirewallDestinationAddress1 = new CloudFirewallDestinationIpAddress();
$addressesCloudFirewallDestinationAddress1->setOdataType('#microsoft.graph.networkaccess.cloudFirewallDestinationIpAddress');
$addressesCloudFirewallDestinationAddress1->setValues(['10.0.0.1', ]);
$addressesArray []= $addressesCloudFirewallDestinationAddress1;
$matchingConditionsDestinations->setAddresses($addressesArray);
$matchingConditionsDestinations->setPorts(['80', '443', '445-447', ]);
$matchingConditionsDestinations->setProtocols(new CloudFirewallProtocol('tcp'));
$matchingConditions->setDestinations($matchingConditionsDestinations);
$requestBody->setMatchingConditions($matchingConditions);
$result = $graphServiceClient->networkAccess()->cloudFirewallPolicies()->byCloudFirewallPolicyId('cloudFirewallPolicy-id')->policyRules()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.NetworkAccess
$params = @{
"@odata.type" = "#microsoft.graph.networkaccess.cloudFirewallRule"
name = "Block outbound to risky destinations"
description = "Block traffic to specific IPs on common ports"
priority =
action = "block"
settings = @{
status = "enabled"
}
matchingConditions = @{
sources = @{
addresses = @(
@{
"@odata.type" = "#microsoft.graph.networkaccess.cloudFirewallSourceIpAddress"
values = @(
"192.168.1.1"
"192.168.0.0/16"
"172.16.0.0-172.16.255.255"
)
}
)
ports = @(
"80"
"443"
"445-447"
)
}
destinations = @{
addresses = @(
@{
"@odata.type" = "#microsoft.graph.networkaccess.cloudFirewallDestinationIpAddress"
values = @(
"10.0.0.1"
)
}
)
ports = @(
"80"
"443"
"445-447"
)
protocols = "tcp"
}
}
}
New-MgBetaNetworkAccessCloudFirewallPolicyRule -CloudFirewallPolicyId $cloudFirewallPolicyId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.networkaccess.cloud_firewall_rule import CloudFirewallRule
from msgraph_beta.generated.models.cloud_firewall_action import CloudFirewallAction
from msgraph_beta.generated.models.networkaccess.cloud_firewall_rule_settings import CloudFirewallRuleSettings
from msgraph_beta.generated.models.security_rule_status import SecurityRuleStatus
from msgraph_beta.generated.models.networkaccess.cloud_firewall_matching_conditions import CloudFirewallMatchingConditions
from msgraph_beta.generated.models.networkaccess.cloud_firewall_source_matching import CloudFirewallSourceMatching
from msgraph_beta.generated.models.networkaccess.cloud_firewall_source_address import CloudFirewallSourceAddress
from msgraph_beta.generated.models.networkaccess.cloud_firewall_source_ip_address import CloudFirewallSourceIpAddress
from msgraph_beta.generated.models.networkaccess.cloud_firewall_destination_matching import CloudFirewallDestinationMatching
from msgraph_beta.generated.models.networkaccess.cloud_firewall_destination_address import CloudFirewallDestinationAddress
from msgraph_beta.generated.models.networkaccess.cloud_firewall_destination_ip_address import CloudFirewallDestinationIpAddress
from msgraph_beta.generated.models.cloud_firewall_protocol import CloudFirewallProtocol
# To initialize your graph_client, see https://dotnet.territoriali.olinfo.it/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = CloudFirewallRule(
odata_type = "#microsoft.graph.networkaccess.cloudFirewallRule",
name = "Block outbound to risky destinations",
description = "Block traffic to specific IPs on common ports",
priority = 100,
action = CloudFirewallAction.Block,
settings = CloudFirewallRuleSettings(
status = SecurityRuleStatus.Enabled,
),
matching_conditions = CloudFirewallMatchingConditions(
sources = CloudFirewallSourceMatching(
addresses = [
CloudFirewallSourceIpAddress(
odata_type = "#microsoft.graph.networkaccess.cloudFirewallSourceIpAddress",
values = [
"192.168.1.1",
"192.168.0.0/16",
"172.16.0.0-172.16.255.255",
],
),
],
ports = [
"80",
"443",
"445-447",
],
),
destinations = CloudFirewallDestinationMatching(
addresses = [
CloudFirewallDestinationIpAddress(
odata_type = "#microsoft.graph.networkaccess.cloudFirewallDestinationIpAddress",
values = [
"10.0.0.1",
],
),
],
ports = [
"80",
"443",
"445-447",
],
protocols = CloudFirewallProtocol.Tcp,
),
),
)
result = await graph_client.network_access.cloud_firewall_policies.by_cloud_firewall_policy_id('cloudFirewallPolicy-id').policy_rules.post(request_body)
Réponse
L’exemple suivant illustre la réponse.
Remarque : l’objet de réponse affiché ci-après peut être raccourci pour plus de lisibilité.
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.networkaccess.cloudFirewallRule",
"id": "406ebb24-e229-4011-8240-e11bbaa4f49d",
"name": "Block outbound to risky destinations",
"description": "Block traffic to specific IPs on common ports",
"priority": 100,
"action": "block",
"settings": {
"status": "enabled"
},
"matchingConditions": {
"sources": {
"addresses": [
{
"@odata.type": "#microsoft.graph.networkaccess.cloudFirewallSourceIpAddress",
"values": ["192.168.1.1", "192.168.0.0/16", "172.16.0.0-172.16.255.255"]
}
],
"ports": ["80", "443", "445-447"]
},
"destinations": {
"addresses": [
{
"@odata.type": "#microsoft.graph.networkaccess.cloudFirewallDestinationIpAddress",
"values": ["10.0.0.1"]
}
],
"ports": ["80", "443", "445-447"],
"protocols": "tcp"
}
}
}