Invoke-AzRestMethod -Path "/subscriptions/{subscription}/resourcegroups/{resourcegroup}/providers/microsoft.operationalinsights/workspaces/{workspace}?api-version={API}" -Method GET
# Replace *** with real values
$payload = @{principalId="***"; resourceId="***"; appRoleId="***"} | ConvertTo-Json -Depth 3
Invoke-AzRestMethod -Method POST -Uri https://graph.microsoft.com/v1.0/servicePrincipals/***/appRoleAssignedTo -Payload $payload
通过构造哈希表、转换为 JSON 字符串并将有效负载 Invoke-AzRestMethod传递给 来调用 Microsoft 图形 API 来分配应用角色。
示例 6
# This example demonstrates creating or updating a resource with a long-running PUT request.
Invoke-AzRestMethod -Method PUT -Uri "https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.KeyVault/managedHSMs/{hsm-name}?api-version=2023-07-01" `
-Payload (@{
location = "eastus";
properties = @{
softDeleteRetentionDays = 7;
tenantId = "{tenant-id}";
initialAdminObjectIds = @("{admin-object-id}")
};
sku = @{
name = "Standard_B1";
family = "B"
}
} | ConvertTo-Json -Depth 10) `
-WaitForCompletion
StatusCode : 200
Content : {
"sku": {
"family": "B",
"name": "Standard_B1"
},
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.KeyVault/managedHSMs/{hsm-name}",
"name": "{hsm-name}",
"type": "Microsoft.KeyVault/managedHSMs",
"location": "{region}",
"tags": {},
"systemData": {
"createdBy": "{user-email}",
"createdByType": "User",
"createdAt": "2024-10-29T05:05:49.229Z",
"lastModifiedBy": "{user-email}",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-10-29T05:05:49.229Z"
},
"properties": {
"tenantId": "{tenant-id}",
"hsmUri": "https://{hsm-name}.managedhsm.azure.net/",
"initialAdminObjectIds": [
"{admin-object-id}"
],
"enableSoftDelete": true,
"softDeleteRetentionInDays": 90,
"enablePurgeProtection": false,
"provisioningState": "Succeeded",
"statusMessage": "The Managed HSM is provisioned and ready to use.",
"networkAcls": {
"bypass": "AzureServices",
"defaultAction": "Allow",
"ipRules": [],
"virtualNetworkRules": []
},
"publicNetworkAccess": "Enabled",
"regions": [],
"securityDomainProperties": {
"activationStatus": "NotActivated",
"activationStatusMessage": "Your HSM has been provisioned, but cannot be used for cryptographic operations until it is activated. To activate the HSM, download the security domain."
}
}
}
Headers : {
"Cache-Control": "no-cache",
"Pragma": "no-cache",
"x-ms-client-request-id": "{client-request-id}",
"x-ms-keyvault-service-version": "1.5.1361.0",
"x-ms-request-id": "{request-id}",
"x-ms-ratelimit-remaining-subscription-reads": "249",
"x-ms-ratelimit-remaining-subscription-global-reads": "3749",
"x-ms-correlation-request-id": "{correlation-request-id}",
"x-ms-routing-request-id": "{routing-request-id}",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"Date": "Tue, 29 Oct 2024 05:18:44 GMT"
}
Method : GET
RequestUri : https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.KeyVault/managedHSMs/{hsm-name}?api-version=2023-07-01
Version : 1.1
发送长时间运行的 PUT 请求以在 Azure 中创建或更新托管 HSM 资源,在作需要完成之前轮询。
此示例使用用户应替换为其特定值的占位符({subscription-id}、{resource-group}、{hsm-name}、{tenant-id}和 {admin-object-id})。
示例 7
# This example shows how to use server-side pagination to get results from a paginated GET endpoint by following nextLink references in the response.
Invoke-AzRest -SubscriptionId $subscriptionId -ResourceProviderName "Microsoft.Compute" -ResourceType "virtualMachines" -ApiVersion "2024-11-01" -Method "GET" -Paginate