获取某个范围的所有管理锁。
GET https://management.azure.com/{scope}/providers/Microsoft.Authorization/locks?api-version=2016-09-01
具有可选参数:
GET https://management.azure.com/{scope}/providers/Microsoft.Authorization/locks?$filter={$filter}&api-version=2016-09-01
URI 参数
名称 |
在 |
必需 |
类型 |
说明 |
scope
|
path |
True
|
string
|
锁的范围。 提供分配范围时,请对订阅使用“/subscriptions/{subscriptionId}”,对资源组使用“/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}”,对资源使用“/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}”。
|
api-version
|
query |
True
|
string
|
要用于操作的 API 版本。
|
$filter
|
query |
|
string
|
要应用于操作的筛选器。
|
响应
安全性
azure_auth
Azure Active Directory OAuth2 流
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
名称 |
说明 |
user_impersonation
|
模拟用户帐户
|
示例
List management locks at scope
示例请求
GET https://management.azure.com/subscriptions/subscriptionId/providers/Microsoft.Authorization/locks?api-version=2016-09-01
import com.azure.core.util.Context;
/** Samples for ManagementLocks ListByScope. */
public final class Main {
/*
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2016-09-01/examples/ManagementLocks_ListAtScope.json
*/
/**
* Sample code: List management locks at scope.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void listManagementLocksAtScope(com.azure.resourcemanager.AzureResourceManager azure) {
azure
.genericResources()
.manager()
.managementLockClient()
.getManagementLocks()
.listByScope("subscriptions/subscriptionId", null, Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.resource import ManagementLockClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-resource
# USAGE
python management_locks_list_at_scope.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 = ManagementLockClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.management_locks.list_by_scope(
scope="subscriptions/subscriptionId",
)
for item in response:
print(item)
# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2016-09-01/examples/ManagementLocks_ListAtScope.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ManagementLockClient } = require("@azure/arm-locks-profile-2020-09-01-hybrid");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Gets all the management locks for a scope.
*
* @summary Gets all the management locks for a scope.
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2016-09-01/examples/ManagementLocks_ListAtScope.json
*/
async function listManagementLocksAtScope() {
const subscriptionId =
process.env["LOCKS_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const scope = "subscriptions/subscriptionId";
const credential = new DefaultAzureCredential();
const client = new ManagementLockClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.managementLocks.listByScope(scope)) {
resArray.push(item);
}
console.log(resArray);
}
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.Resources.Models;
// Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2016-09-01/examples/ManagementLocks_ListAtScope.json
// this example is just showing the usage of "ManagementLocks_ListByScope" 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 ArmResource created on azure
// for more information of creating ArmResource, please refer to the document of ArmResource
// get the collection of this ManagementLockResource
string scope = "subscriptions/subscriptionId";
ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope));
ManagementLockCollection collection = client.GetGenericResource(scopeId).GetManagementLocks();
// invoke the operation and iterate over the result
await foreach (ManagementLockResource 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
ManagementLockData resourceData = item.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
}
Console.WriteLine($"Succeeded");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"value": [
{
"properties": {
"level": "ReadOnly"
},
"id": "/providers/Microsoft.Authorization/locks/testlock",
"type": "Microsoft.Authorization/locks",
"name": "testlock"
}
]
}
定义
LockLevel
锁的级别。 可能的值为:NotSpecified、CanNotDelete、ReadOnly。 CanNotDelete 表示授权用户能够读取和修改资源,但不能删除。 ReadOnly 表示授权用户只能从资源进行读取,但不能修改或删除资源。
名称 |
类型 |
说明 |
CanNotDelete
|
string
|
|
NotSpecified
|
string
|
|
ReadOnly
|
string
|
|
ManagementLockListResult
锁列表。
ManagementLockObject
锁信息。
名称 |
类型 |
说明 |
id
|
string
|
锁的资源 ID。
|
name
|
string
|
锁的名称。
|
properties.level
|
LockLevel
|
锁的级别。 可能的值为:NotSpecified、CanNotDelete、ReadOnly。 CanNotDelete 表示授权用户能够读取和修改资源,但不能删除。 ReadOnly 表示授权用户只能从资源进行读取,但不能修改或删除资源。
|
properties.notes
|
string
|
有关锁的说明。 最多 512 个字符。
|
properties.owners
|
ManagementLockOwner[]
|
锁的所有者。
|
type
|
string
|
锁的资源类型 - Microsoft.Authorization/locks。
|
ManagementLockOwner
锁定所有者属性。
名称 |
类型 |
说明 |
applicationId
|
string
|
锁所有者的应用程序 ID。
|