Operace zapůjčení sdílené složky vytvoří a spravuje zámek sdílené složky pro operace odstranění. Doba trvání zámku může být 15 až 60 sekund nebo může být nekonečná.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease?api-version=2023-01-01
Parametry identifikátoru URI
Name |
V |
Vyžadováno |
Typ |
Description |
accountName
|
path |
True
|
string
|
Název účtu úložiště v rámci zadané skupiny prostředků. Názvy účtů úložiště musí mít délku 3 až 24 znaků a musí používat jenom číslice a malá písmena.
Regex pattern: ^[a-z0-9]+$
|
resourceGroupName
|
path |
True
|
string
|
Název skupiny prostředků v rámci předplatného uživatele. V názvu se rozlišují malá a velká písmena.
Regex pattern: ^[-\w\._\(\)]+$
|
shareName
|
path |
True
|
string
|
Název sdílené složky v rámci zadaného účtu úložiště. Názvy sdílených složek musí mít délku 3 až 63 znaků a musí obsahovat pouze číslice, malá písmena a pomlčky (-). Každá pomlčka (-) musí bezprostředně předcházet písmenu nebo číslici.
|
subscriptionId
|
path |
True
|
string
|
ID cílového předplatného.
|
api-version
|
query |
True
|
string
|
Verze rozhraní API, která se má použít pro tuto operaci.
|
Name |
Vyžadováno |
Typ |
Description |
x-ms-snapshot
|
|
string
|
Nepovinný parametr. Zadejte čas snímku pro zapůjčení snímku.
|
Text požadavku
Name |
Vyžadováno |
Typ |
Description |
action
|
True
|
LeaseShareAction
|
Určuje akci zapůjčení. Může to být jedna z dostupných akcí.
|
breakPeriod
|
|
integer
|
Nepovinný parametr. V případě akce přerušení by mělo zapůjčení v rozsahu 0 až 60 sekund pokračovat, než se přeruší.
|
leaseDuration
|
|
integer
|
Vyžaduje se pro získání. Určuje dobu zapůjčení v sekundách nebo zápornou dobu (-1) pro zapůjčení, jehož platnost nikdy nevyprší.
|
leaseId
|
|
string
|
Identifikuje zapůjčení. Lze zadat v libovolném platném formátu řetězce GUID.
|
proposedLeaseId
|
|
string
|
Volitelné pro získání, vyžadováno pro změnu. Navrhované ID zapůjčení ve formátu řetězce GUID
|
Odpovědi
Name |
Typ |
Description |
200 OK
|
LeaseShareResponse
|
OK – Operace zapůjčení sdílené složky se úspěšně dokončila.
Headers
ETag: string
|
Other Status Codes
|
CloudError
|
Chybová odpověď popisující, proč operace selhala.
|
Zabezpečení
azure_auth
Tok Azure Active Directory OAuth2
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name |
Description |
user_impersonation
|
zosobnění uživatelského účtu
|
Příklady
Acquire a lease on a share
Sample Request
POST https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/res3376/providers/Microsoft.Storage/storageAccounts/sto328/fileServices/default/shares/share124/lease?api-version=2023-01-01
{
"action": "Acquire",
"leaseId": null,
"breakPeriod": null,
"leaseDuration": -1,
"proposedLeaseId": null
}
import com.azure.resourcemanager.storage.models.LeaseShareAction;
import com.azure.resourcemanager.storage.models.LeaseShareRequest;
/** Samples for FileShares Lease. */
public final class Main {
/*
* x-ms-original-file:
* specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileSharesLease_Acquire.json
*/
/**
* Sample code: Acquire a lease on a share.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void acquireALeaseOnAShare(com.azure.resourcemanager.AzureResourceManager azure) {
azure.storageAccounts().manager().serviceClient().getFileShares().leaseWithResponse("res3376", "sto328",
"share124", null, new LeaseShareRequest().withAction(LeaseShareAction.ACQUIRE).withLeaseDuration(-1),
com.azure.core.util.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.storage import StorageManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-storage
# USAGE
python file_shares_lease_acquire.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 = StorageManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.file_shares.lease(
resource_group_name="res3376",
account_name="sto328",
share_name="share124",
)
print(response)
# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileSharesLease_Acquire.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
package armstorage_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/storage/armstorage"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0baf811c3c76c87b3c127d098519bd97141222dd/specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileSharesLease_Acquire.json
func ExampleFileSharesClient_Lease_acquireALeaseOnAShare() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armstorage.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewFileSharesClient().Lease(ctx, "res3376", "sto328", "share124", &armstorage.FileSharesClientLeaseOptions{XMSSnapshot: nil,
Parameters: &armstorage.LeaseShareRequest{
Action: to.Ptr(armstorage.LeaseShareActionAcquire),
LeaseDuration: to.Ptr[int32](-1),
},
})
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.LeaseShareResponse = armstorage.LeaseShareResponse{
// LeaseID: to.Ptr("8698f513-fa75-44a1-b8eb-30ba336af27d"),
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { StorageManagementClient } = require("@azure/arm-storage");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite.
*
* @summary The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite.
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileSharesLease_Acquire.json
*/
async function acquireALeaseOnAShare() {
const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res3376";
const accountName = "sto328";
const shareName = "share124";
const parameters = {
action: "Acquire",
breakPeriod: undefined,
leaseDuration: -1,
leaseId: undefined,
proposedLeaseId: undefined,
};
const options = { parameters };
const credential = new DefaultAzureCredential();
const client = new StorageManagementClient(credential, subscriptionId);
const result = await client.fileShares.lease(resourceGroupName, accountName, shareName, options);
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
Sample Response
{
"leaseId": "8698f513-fa75-44a1-b8eb-30ba336af27d"
}
Break a lease on a share
Sample Request
POST https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/res3376/providers/Microsoft.Storage/storageAccounts/sto328/fileServices/default/shares/share12/lease?api-version=2023-01-01
{
"action": "Break",
"leaseId": "8698f513-fa75-44a1-b8eb-30ba336af27d",
"breakPeriod": null,
"leaseDuration": null,
"proposedLeaseId": null
}
import com.azure.resourcemanager.storage.models.LeaseShareAction;
import com.azure.resourcemanager.storage.models.LeaseShareRequest;
/** Samples for FileShares Lease. */
public final class Main {
/*
* x-ms-original-file:
* specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileSharesLease_Break.json
*/
/**
* Sample code: Break a lease on a share.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void breakALeaseOnAShare(com.azure.resourcemanager.AzureResourceManager azure) {
azure.storageAccounts().manager().serviceClient().getFileShares()
.leaseWithResponse("res3376", "sto328", "share12", null, new LeaseShareRequest()
.withAction(LeaseShareAction.BREAK).withLeaseId("8698f513-fa75-44a1-b8eb-30ba336af27d"),
com.azure.core.util.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.storage import StorageManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-storage
# USAGE
python file_shares_lease_break.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 = StorageManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)
response = client.file_shares.lease(
resource_group_name="res3376",
account_name="sto328",
share_name="share12",
)
print(response)
# x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileSharesLease_Break.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
package armstorage_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/storage/armstorage"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0baf811c3c76c87b3c127d098519bd97141222dd/specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileSharesLease_Break.json
func ExampleFileSharesClient_Lease_breakALeaseOnAShare() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armstorage.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewFileSharesClient().Lease(ctx, "res3376", "sto328", "share12", &armstorage.FileSharesClientLeaseOptions{XMSSnapshot: nil,
Parameters: &armstorage.LeaseShareRequest{
Action: to.Ptr(armstorage.LeaseShareActionBreak),
LeaseID: to.Ptr("8698f513-fa75-44a1-b8eb-30ba336af27d"),
},
})
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.LeaseShareResponse = armstorage.LeaseShareResponse{
// LeaseTimeSeconds: to.Ptr("0"),
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { StorageManagementClient } = require("@azure/arm-storage");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite.
*
* @summary The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite.
* x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2023-01-01/examples/FileSharesLease_Break.json
*/
async function breakALeaseOnAShare() {
const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res3376";
const accountName = "sto328";
const shareName = "share12";
const parameters = {
action: "Break",
breakPeriod: undefined,
leaseDuration: undefined,
leaseId: "8698f513-fa75-44a1-b8eb-30ba336af27d",
proposedLeaseId: undefined,
};
const options = { parameters };
const credential = new DefaultAzureCredential();
const client = new StorageManagementClient(credential, subscriptionId);
const result = await client.fileShares.lease(resourceGroupName, accountName, shareName, options);
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
Sample Response
{
"leaseTimeSeconds": "0"
}
Definice
CloudError
Chybová odpověď ze služby Storage.
Name |
Typ |
Description |
error
|
CloudErrorBody
|
Chybová odpověď ze služby Storage.
|
CloudErrorBody
Chybová odpověď ze služby Storage.
Name |
Typ |
Description |
code
|
string
|
Identifikátor chyby. Kódy jsou neutrální a mají být využívány programově.
|
details
|
CloudErrorBody[]
|
Seznam dalších podrobností o chybě
|
message
|
string
|
Zpráva popisující chybu, která má být vhodná k zobrazení v uživatelském rozhraní.
|
target
|
string
|
Cíl konkrétní chyby. Například název vlastnosti v chybě.
|
LeaseShareAction
Určuje akci zapůjčení. Může to být jedna z dostupných akcí.
Name |
Typ |
Description |
Acquire
|
string
|
|
Break
|
string
|
|
Change
|
string
|
|
Release
|
string
|
|
Renew
|
string
|
|
LeaseShareRequest
Schéma žádosti o zapůjčení sdílené složky.
Name |
Typ |
Description |
action
|
LeaseShareAction
|
Určuje akci zapůjčení. Může to být jedna z dostupných akcí.
|
breakPeriod
|
integer
|
Nepovinný parametr. V případě akce přerušení by mělo zapůjčení v rozsahu 0 až 60 sekund pokračovat, než se přeruší.
|
leaseDuration
|
integer
|
Vyžaduje se pro získání. Určuje dobu zapůjčení v sekundách nebo zápornou dobu (-1) pro zapůjčení, jehož platnost nikdy nevyprší.
|
leaseId
|
string
|
Identifikuje zapůjčení. Lze zadat v libovolném platném formátu řetězce GUID.
|
proposedLeaseId
|
string
|
Volitelné pro získání, vyžadováno pro změnu. Navrhované ID zapůjčení ve formátu řetězce GUID
|
LeaseShareResponse
Schéma odezvy sdílené složky zapůjčení.
Name |
Typ |
Description |
leaseId
|
string
|
Vrátilo se jedinečné ID zapůjčení, které musí být součástí žádosti o odstranění sdílené složky nebo prodloužení, změnu nebo uvolnění zapůjčení.
|
leaseTimeSeconds
|
string
|
Přibližný zbývající čas v období zapůjčení (v sekundách).
|