Skapa eller uppdatera ett hanteringslås efter omfång.
PUT https://management.azure.com/{scope}/providers/Microsoft.Authorization/locks/{lockName}?api-version=2016-09-01
URI-parametrar
Name |
I |
Obligatorisk |
Typ |
Description |
lockName
|
path |
True
|
string
|
Namnet på låset.
|
scope
|
path |
True
|
string
|
Låsets omfång. När du anger ett omfång för tilldelningen använder du '/subscriptions/{subscriptionId}' för prenumerationer, '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' för resursgrupper och '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' för resurser.
|
api-version
|
query |
True
|
string
|
DEN API-version som ska användas för åtgärden.
|
Begärandetext
Name |
Obligatorisk |
Typ |
Description |
properties.level
|
True
|
LockLevel
|
Låsets nivå. Möjliga värden är: NotSpecified, CanNotDelete, ReadOnly. CanNotDelete innebär att behöriga användare kan läsa och ändra resurserna, men inte ta bort dem. ReadOnly innebär att behöriga användare bara kan läsa från en resurs, men de kan inte ändra eller ta bort den.
|
properties.notes
|
|
string
|
Anteckningar om låset. Högst 512 tecken.
|
properties.owners
|
|
ManagementLockOwner[]
|
Låsets ägare.
|
Svar
Säkerhet
azure_auth
Azure Active Directory OAuth2 Flow
Typ:
oauth2
Flow:
implicit
Auktoriseringswebbadress:
https://login.microsoftonline.com/common/oauth2/authorize
Omfattningar
Name |
Description |
user_impersonation
|
personifiera ditt användarkonto
|
Exempel
Create management lock at scope
Exempelbegäran
PUT https://management.azure.com/subscriptions/subscriptionId/providers/Microsoft.Authorization/locks/testlock?api-version=2016-09-01
{
"properties": {
"level": "ReadOnly"
}
}
import com.azure.core.util.Context;
import com.azure.resourcemanager.resources.fluent.models.ManagementLockObjectInner;
import com.azure.resourcemanager.resources.models.LockLevel;
/** Samples for ManagementLocks CreateOrUpdateByScope. */
public final class Main {
/*
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2016-09-01/examples/ManagementLocks_CreateOrUpdateAtScope.json
*/
/**
* Sample code: Create management lock at scope.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createManagementLockAtScope(com.azure.resourcemanager.AzureResourceManager azure) {
azure
.genericResources()
.manager()
.managementLockClient()
.getManagementLocks()
.createOrUpdateByScopeWithResponse(
"subscriptions/subscriptionId",
"testlock",
new ManagementLockObjectInner().withLevel(LockLevel.READ_ONLY),
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_create_or_update_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.create_or_update_by_scope(
scope="subscriptions/subscriptionId",
lock_name="testlock",
parameters={"properties": {"level": "ReadOnly"}},
)
print(response)
# x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2016-09-01/examples/ManagementLocks_CreateOrUpdateAtScope.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 Create or update a management lock by scope.
*
* @summary Create or update a management lock by scope.
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2016-09-01/examples/ManagementLocks_CreateOrUpdateAtScope.json
*/
async function createManagementLockAtScope() {
const subscriptionId =
process.env["LOCKS_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const scope = "subscriptions/subscriptionId";
const lockName = "testlock";
const parameters = { level: "ReadOnly" };
const credential = new DefaultAzureCredential();
const client = new ManagementLockClient(credential, subscriptionId);
const result = await client.managementLocks.createOrUpdateByScope(scope, lockName, parameters);
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.Resources.Models;
// Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2016-09-01/examples/ManagementLocks_CreateOrUpdateAtScope.json
// this example is just showing the usage of "ManagementLocks_CreateOrUpdateByScope" 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
string lockName = "testlock";
ManagementLockData data = new ManagementLockData(ManagementLockLevel.ReadOnly);
ArmOperation<ManagementLockResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, lockName, data);
ManagementLockResource 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
ManagementLockData 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
Exempelsvar
{
"properties": {
"level": "ReadOnly"
},
"id": "/providers/Microsoft.Authorization/locks/testlock",
"type": "Microsoft.Authorization/locks",
"name": "testlock"
}
{
"properties": {
"level": "ReadOnly"
},
"id": "/providers/Microsoft.Authorization/locks/testlock",
"type": "Microsoft.Authorization/locks",
"name": "testlock"
}
Definitioner
Name |
Description |
LockLevel
|
Låsets nivå. Möjliga värden är: NotSpecified, CanNotDelete, ReadOnly. CanNotDelete innebär att behöriga användare kan läsa och ändra resurserna, men inte ta bort dem. ReadOnly innebär att behöriga användare bara kan läsa från en resurs, men de kan inte ändra eller ta bort den.
|
ManagementLockObject
|
Låsinformationen.
|
ManagementLockOwner
|
Lås ägaregenskaper.
|
LockLevel
Låsets nivå. Möjliga värden är: NotSpecified, CanNotDelete, ReadOnly. CanNotDelete innebär att behöriga användare kan läsa och ändra resurserna, men inte ta bort dem. ReadOnly innebär att behöriga användare bara kan läsa från en resurs, men de kan inte ändra eller ta bort den.
Name |
Typ |
Description |
CanNotDelete
|
string
|
|
NotSpecified
|
string
|
|
ReadOnly
|
string
|
|
ManagementLockObject
Låsinformationen.
Name |
Typ |
Description |
id
|
string
|
Resurs-ID för låset.
|
name
|
string
|
Namnet på låset.
|
properties.level
|
LockLevel
|
Låsets nivå. Möjliga värden är: NotSpecified, CanNotDelete, ReadOnly. CanNotDelete innebär att behöriga användare kan läsa och ändra resurserna, men inte ta bort dem. ReadOnly innebär att behöriga användare bara kan läsa från en resurs, men de kan inte ändra eller ta bort den.
|
properties.notes
|
string
|
Anteckningar om låset. Högst 512 tecken.
|
properties.owners
|
ManagementLockOwner[]
|
Låsets ägare.
|
type
|
string
|
Resurstypen för låset – Microsoft.Authorization/locks.
|
ManagementLockOwner
Lås ägaregenskaper.
Name |
Typ |
Description |
applicationId
|
string
|
Program-ID för låsägaren.
|