GET https://management.azure.com/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/providers/Microsoft.Security/settings?api-version=2022-05-01
/**
* Samples for Settings List.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/security/resource-manager/Microsoft.Security/stable/2022-05-01/examples/Settings/
* GetSettings_example.json
*/
/**
* Sample code: Get settings of subscription.
*
* @param manager Entry point to SecurityManager.
*/
public static void getSettingsOfSubscription(com.azure.resourcemanager.security.SecurityManager manager) {
manager.settings().list(com.azure.core.util.Context.NONE);
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.security import SecurityCenter
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-security
# USAGE
python get_settings_example.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SecurityCenter(
credential=DefaultAzureCredential(),
subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23",
)
response = client.settings.list()
for item in response:
print(item)
# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-05-01/examples/Settings/GetSettings_example.json
if __name__ == "__main__":
main()
const { SecurityCenter } = require("@azure/arm-security");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Settings about different configurations in Microsoft Defender for Cloud
*
* @summary Settings about different configurations in Microsoft Defender for Cloud
* x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2022-05-01/examples/Settings/GetSettings_example.json
*/
async function getSettingsOfSubscription() {
const subscriptionId =
process.env["SECURITY_SUBSCRIPTION_ID"] || "20ff7fc3-e762-44dd-bd96-b71116dcdc23";
const credential = new DefaultAzureCredential();
const client = new SecurityCenter(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.settings.list()) {
resArray.push(item);
}
console.log(resArray);
}
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/stable/2022-05-01/examples/Settings/GetSettings_example.json
// this example is just showing the usage of "Settings_List" 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 SecuritySettingResource
SecuritySettingCollection collection = subscriptionResource.GetSecuritySettings();
// invoke the operation and iterate over the result
await foreach (SecuritySettingResource item in collection.GetAllAsync())
{
// the variable item 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
SecuritySettingData resourceData = item.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
}
Console.WriteLine($"Succeeded");
Běžná chybová odpověď pro všechna rozhraní API Azure Resource Manageru pro vrácení podrobností o chybě pro neúspěšné operace (To se také řídí formátem odpovědi na chybu OData.)
Běžná chybová odpověď pro všechna rozhraní API Azure Resource Manageru pro vrácení podrobností o chybě pro neúspěšné operace (To se také řídí formátem odpovědi na chybu OData.)