Invoke-AzRestMethod
Yalnızca Azure kaynak yönetimi uç noktasına HTTP isteği oluşturma ve gerçekleştirme
Syntax
Invoke-AzRestMethod
-Path <String>
[-Method <String>]
[-Payload <String>]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Invoke-AzRestMethod
[-SubscriptionId <String>]
[-ResourceGroupName <String>]
[-ResourceProviderName <String>]
[-ResourceType <String[]>]
[-Name <String[]>]
-ApiVersion <String>
[-Method <String>]
[-Payload <String>]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Invoke-AzRestMethod
[-Uri] <Uri>
[-ResourceId <Uri>]
[-Method <String>]
[-Payload <String>]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Yalnızca Azure kaynak yönetimi uç noktasına HTTP isteği oluşturma ve gerçekleştirme
Örnekler
Örnek 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": {}
}
Log Analytics çalışma alanını yola göre alın. Yalnızca yönetim düzlemi API'sini destekler ve Azure Resource Manager'ın Konak adı Azure ortam ayarına göre eklenir.
Örnek 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":["......}
MicrosoftGraph API'sini kullanarak geçerli oturum açmış kullanıcıyı alın. Bu örnek ile Get-AzADUser -SignedIn
eşdeğerdir.
Örnek 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"}]}
Spring service "test-spring-service" altında uygulamaları listeleme
Örnek 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"}
Spring bulut hizmeti "test-spring-service" altında uygulama "demo" alın
Örnek 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
Bir karma tablo oluşturarak, JSON dizesine dönüştürerek ve yükü öğesine geçirerek Uygulama Rolü atamak için Microsoft Graph API'sini Invoke-AzRestMethod
çağırın.
Parametreler
-ApiVersion
API Sürümü
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-AsJob
Cmdlet'i arka planda çalıştırma
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Confirm
Cmdlet'i çalıştırmadan önce sizden onay ister.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DefaultProfile
Azure ile iletişim için kullanılan kimlik bilgileri, hesap, kiracı ve abonelik.
Type: | IAzureContextContainer |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Method
Http Yöntemi
Type: | String |
Accepted values: | GET, POST, PUT, PATCH, DELETE |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Name
Hedef Kaynak Adı listesi
Type: | String[] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Path
Hedef kaynak URL'sinin yolu. Resource Manager ana bilgisayar adı eklenmemelidir.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Payload
JSON biçim yükü
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ResourceGroupName
Hedef Kaynak Grubu Adı
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ResourceId
Çağırdığınız REST API tarafından belirtilen tanımlayıcı URI'sini seçin. Azure Resource Manager'ın kaynak kimliği olmamalıdır.
Type: | Uri |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ResourceProviderName
Hedef Kaynak Sağlayıcısı Adı
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ResourceType
Hedef Kaynak Türü Listesi
Type: | String[] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-SubscriptionId
Hedef Abonelik Kimliği
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Uri
Azure kaynaklarının Tekdüzen Kaynak Tanımlayıcısı. Hedef kaynağın Azure AD kimlik doğrulamasını desteklemesi gerekir ve erişim belirteci kaynak kimliğine göre türetilir. Kaynak kimliği ayarlanmamışsa, değeri geçerli Azure Ortamındaki yerleşik hizmet son eklerine göre türetilir.
Type: | Uri |
Position: | 1 |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIf
Cmdlet çalıştırılıyorsa ne olacağını gösterir. Cmdlet çalıştırılmaz.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Girişler
System.string
Çıkışlar
Azure PowerShell
Geri Bildirim
https://aka.ms/ContentUserFeedback.
Çok yakında: 2024 boyunca, içerik için geri bildirim mekanizması olarak GitHub Sorunları’nı kullanımdan kaldıracak ve yeni bir geri bildirim sistemiyle değiştireceğiz. Daha fazla bilgi için bkz.Gönderin ve geri bildirimi görüntüleyin