Invoke-AzRestMethod
Alleen een HTTP-aanvraag maken en uitvoeren naar het Azure-eindpunt voor resourcebeheer
Syntaxis
Invoke-AzRestMethod
-Path <String>
[-Method <String>]
[-Payload <String>]
[-AsJob]
[-WaitForCompletion]
[-PollFrom <String>]
[-FinalResultFrom <String>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Invoke-AzRestMethod
[-SubscriptionId <String>]
[-ResourceGroupName <String>]
[-ResourceProviderName <String>]
[-ResourceType <String[]>]
[-Name <String[]>]
-ApiVersion <String>
[-Method <String>]
[-Payload <String>]
[-AsJob]
[-WaitForCompletion]
[-PollFrom <String>]
[-FinalResultFrom <String>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Invoke-AzRestMethod
[-Uri] <Uri>
[-ResourceId <Uri>]
[-Method <String>]
[-Payload <String>]
[-AsJob]
[-WaitForCompletion]
[-PollFrom <String>]
[-FinalResultFrom <String>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Alleen een HTTP-aanvraag maken en uitvoeren naar het Azure-eindpunt voor resourcebeheer
Voorbeelden
Voorbeeld 1
Invoke-AzRestMethod -Path "/subscriptions/{subscription}/resourcegroups/{resourcegroup}/providers/microsoft.operationalinsights/workspaces/{workspace}?api-version={API}" -Method GET
Headers : {[Cache-Control, System.String[]], [Pragma, System.String[]], [x-ms-request-id, System.String[]], [Strict-Transport-Security, System.String[]]…}
Version : 1.1
StatusCode : 200
Method : GET
Content : {
"properties": {
"source": "Azure",
"customerId": "{customerId}",
"provisioningState": "Succeeded",
"sku": {
"name": "pergb2018",
"maxCapacityReservationLevel": 3000,
"lastSkuUpdate": "Mon, 25 May 2020 11:10:01 GMT"
},
"retentionInDays": 30,
"features": {
"legacy": 0,
"searchVersion": 1,
"enableLogAccessUsingOnlyResourcePermissions": true
},
"workspaceCapping": {
"dailyQuotaGb": -1.0,
"quotaNextResetTime": "Thu, 18 Jun 2020 05:00:00 GMT",
"dataIngestionStatus": "RespectQuota"
},
"enableFailover": false,
"publicNetworkAccessForIngestion": "Enabled",
"publicNetworkAccessForQuery": "Enabled",
"createdDate": "Mon, 25 May 2020 11:10:01 GMT",
"modifiedDate": "Mon, 25 May 2020 11:10:02 GMT"
},
"id": "/subscriptions/{subscription}/resourcegroups/{resourcegroup}/providers/microsoft.operationalinsights/workspaces/{workspace}",
"name": "{workspace}",
"type": "Microsoft.OperationalInsights/workspaces",
"location": "eastasia",
"tags": {}
}
Haal de Log Analytics-werkruimte op pad op. Het biedt alleen ondersteuning voor de API van het beheervlak en de hostnaam van Azure Resource Manager, afhankelijk van de Azure-omgevingsinstelling.
Voorbeeld 2
Invoke-AzRestMethod https://graph.microsoft.com/v1.0/me
Headers : {[Date, System.String[]], [Cache-Control, System.String[]], [Transfer-Encoding, System.String[]], [Strict-Transport-Security, System.String[]]…}
Version : 1.1
StatusCode : 200
Method : GET
Content : {"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users/$entity","businessPhones":["......}
De huidige aangemelde gebruiker ophalen via MicrosoftGraph API. Dit voorbeeld is gelijk aan Get-AzADUser -SignedIn
.
Voorbeeld 3
$subscriptionId = (Get-AzContext).Subscription.ID
Invoke-AzRestMethod -SubscriptionId $subscriptionId -ResourceGroupName "test-group" -ResourceProviderName Microsoft.AppPlatform -ResourceType Spring,apps -Name "test-spring-service" -ApiVersion 2020-07-01 -Method GET
Headers : {[Cache-Control, System.String[]], [Pragma, System.String[]], [Vary, System.String[]], [x-ms-request-id,
System.String[]]…}
Version : 1.1
StatusCode : 200
Method : GET
Content : {"value":[{"properties":{"public":true,"url":"https://test-spring-service-demo.azuremicroservices.io","provisioni
ngState":"Succeeded","activeDeploymentName":"default","fqdn":"test-spring-service.azuremicroservices.io","httpsOn
ly":false,"createdTime":"2022-06-22T02:57:13.272Z","temporaryDisk":{"sizeInGB":5,"mountPath":"/tmp"},"pers
istentDisk":{"sizeInGB":0,"mountPath":"/persistent"}},"type":"Microsoft.AppPlatform/Spring/apps","identity
":null,"location":"eastus","id":"/subscriptions/$subscriptionId/resourceGroups/test-group/providers/Microsoft.AppPlatform/Spring/test-spring-service/apps/demo","name":"demo"},{"properties":{"publ
ic":false,"provisioningState":"Succeeded","activeDeploymentName":"deploy01","fqdn":"test-spring-service.azuremicr
oservices.io","httpsOnly":false,"createdTime":"2022-06-22T07:46:54.9Z","temporaryDisk":{"sizeInGB":5,"moun
tPath":"/tmp"},"persistentDisk":{"sizeInGB":0,"mountPath":"/persistent"}},"type":"Microsoft.AppPlatform/Sp
ring/apps","identity":null,"location":"eastus","id":"/subscriptions/$subscriptionId/r
esourceGroups/test-group/providers/Microsoft.AppPlatform/Spring/test-spring-service/apps/pwsh01","name":"pwsh0
1"}]}
Apps vermelden onder springservice 'test-spring-service'
Voorbeeld 4
$subscriptionId = (Get-AzContext).Subscription.ID
Invoke-AzRestMethod -SubscriptionId $subscriptionId -ResourceGroupName "test-group" -ResourceProviderName Microsoft.AppPlatform -ResourceType Spring -Name "test-spring-service","demo" -ApiVersion 2020-07-01 -Method GET
Headers : {[Cache-Control, System.String[]], [Pragma, System.String[]], [Vary, System.String[]], [x-ms-request-id,
System.String[]]…}
Version : 1.1
StatusCode : 200
Method : GET
Content : {"properties":{"public":true,"url":"https://test-spring-service-demo.azuremicroservices.io","provisioningState":"
Succeeded","activeDeploymentName":"default","fqdn":"test-spring-service.azuremicroservices.io","httpsOnly":false,
"createdTime":"2022-06-22T02:57:13.272Z","temporaryDisk":{"sizeInGB":5,"mountPath":"/tmp"},"persistentDisk
":{"sizeInGB":0,"mountPath":"/persistent"}},"type":"Microsoft.AppPlatform/Spring/apps","identity":null,"lo
cation":"eastus","id":"/subscriptions/$subscriptionId/resourceGroups/test-group/pr
oviders/Microsoft.AppPlatform/Spring/test-spring-service/apps/demo","name":"demo"}
App -demo ophalen onder Spring-cloudservice 'test-spring-service'
Voorbeeld 5
# 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
Roep Microsoft Graph API aan om app-rol toe te wijzen door een hashtabel te maken, te converteren naar een JSON-tekenreeks en de nettolading door te geven aan Invoke-AzRestMethod
.
Voorbeeld 5
# 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
Verzendt een langlopende PUT-aanvraag om een beheerde HSM-resource in Azure te maken of bij te werken, en pollt totdat de bewerking is voltooid. In dit voorbeeld worden tijdelijke aanduidingen ({subscription-id}, {resource-group}, {hsm-name}, {tenant-id} en {admin-object-id}) gebruikt die de gebruiker moet vervangen door hun specifieke waarden.
Parameters
-ApiVersion
Api-versie
Type: | String |
Position: | Named |
Default value: | None |
Vereist: | True |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
-AsJob
Cmdlet op de achtergrond uitvoeren
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Vereist: | False |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
-Confirm
U wordt gevraagd om bevestiging voordat u de cmdlet uitvoert.
Type: | SwitchParameter |
Aliassen: | cf |
Position: | Named |
Default value: | None |
Vereist: | False |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
-DefaultProfile
De referenties, accounts, tenants en abonnementen die worden gebruikt voor communicatie met Azure.
Type: | IAzureContextContainer |
Aliassen: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Vereist: | False |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
-FinalResultFrom
Hiermee geeft u de header voor het uiteindelijke GET-resultaat nadat de langlopende bewerking is voltooid.
Type: | String |
Geaccepteerde waarden: | FinalStateVia, Location, OriginalUri, Operation-Location |
Position: | Named |
Default value: | None |
Vereist: | False |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
-Method
Http-methode
Type: | String |
Geaccepteerde waarden: | GET, POST, PUT, PATCH, DELETE |
Position: | Named |
Default value: | None |
Vereist: | False |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
-Name
lijst met doelresourcenaam
Type: | String[] |
Position: | Named |
Default value: | None |
Vereist: | False |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
-Path
Pad van de doelresource-URL. De hostnaam van Resource Manager mag niet worden toegevoegd.
Type: | String |
Position: | Named |
Default value: | None |
Vereist: | True |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
-Payload
JSON-indeling nettolading
Type: | String |
Position: | Named |
Default value: | None |
Vereist: | False |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
-PollFrom
Hiermee geeft u de polling-header (uit te halen) voor langlopende bewerkingsstatus.
Type: | String |
Geaccepteerde waarden: | AzureAsyncLocation, Location, OriginalUri, Operation-Location |
Position: | Named |
Default value: | None |
Vereist: | False |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
-ResourceGroupName
Naam van doelresourcegroep
Type: | String |
Position: | Named |
Default value: | None |
Vereist: | False |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
-ResourceId
Id-URI die is opgegeven door de REST API die u aanroept. Dit mag niet de resource-id van Azure Resource Manager zijn.
Type: | Uri |
Position: | Named |
Default value: | None |
Vereist: | False |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
-ResourceProviderName
Naam van doelresourceprovider
Type: | String |
Position: | Named |
Default value: | None |
Vereist: | False |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
-ResourceType
Lijst met doelresourcetype
Type: | String[] |
Position: | Named |
Default value: | None |
Vereist: | False |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
-SubscriptionId
Doelabonnements-id
Type: | String |
Position: | Named |
Default value: | None |
Vereist: | False |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
-Uri
Uniform Resource Identifier van de Azure-resources. De doelresource moet Ondersteuning bieden voor Azure AD-verificatie en het toegangstoken wordt afgeleid op basis van de resource-id. Als de resource-id niet is ingesteld, wordt de waarde ervan afgeleid op basis van ingebouwde serviceachtervoegsels in de huidige Azure-omgeving.
Type: | Uri |
Position: | 1 |
Default value: | None |
Vereist: | True |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
-WaitForCompletion
Wacht totdat de langlopende bewerking is voltooid voordat het resultaat wordt geretourneerd.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Vereist: | False |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
-WhatIf
Toont wat er zou gebeuren als de cmdlet wordt uitgevoerd. De cmdlet wordt niet uitgevoerd.
Type: | SwitchParameter |
Aliassen: | wi |
Position: | Named |
Default value: | None |
Vereist: | False |
Pijplijninvoer accepteren: | False |
Jokertekens accepteren: | False |
Invoerwaarden
System.string
Uitvoerwaarden
Azure PowerShell