Description
Description
Starting Azure Container Instance container group with combination of Invoke-AzResourceAction and -ApiVersion "2021-09-01" causes an error.
Invoke-AzResourceAction -ResourceGroupName myResourceGroup -ResourceName mycontainer -ResourceType Microsoft.ContainerInstance/containerGroups -Action Start -Force -ApiVersion "2021-09-01" -debug -verbose
Invoke-AzResourceAction : {"message":"No HTTP resource was found that matches the request URI 'https://provider-westus.console.azure.com/providers/api/subscriptions/xxxxxxxxxx/resourceGroups/myResourceGroup/pro
viders/Microsoft.ContainerInstance/containerGroups/mycontainer/Start?api-version=2021-09-01'."}
Using older -ApiVersion "2019-12-01" can avoid the error.
Invoke-AzResourceAction -ResourceGroupName myResourceGroup -ResourceName mycontainer -ResourceType Microsoft.ContainerInstance/containerGroups -Action Start -Force -ApiVersion "2019-12-01" -debug -verbose
Debug output shows that -ApiVersion "2021-09-01" sends unnecessary GET request , that causes the error.
Issue script & Debug output
> Invoke-AzResourceAction -ResourceGroupName myResourceGroup -ResourceName mycontainer -ResourceType Microsoft.ContainerInstance/containerGroups -Action Start -Force -ApiVersion "2021-09-01" -debug -verbose
============================ HTTP REQUEST ============================
HTTP Method:
POST
Absolute Uri:
https://management.azure.com/subscriptions/*************/resourceGroups/myResourceGroup/providers/Microsoft.ContainerInstance/containerGroups/mycontainer/Start?api-version=2021-09-01
Headers:
User-Agent : Az.Resources/5.3.0,AzurePowershell/v0.0.0,PSVersion/v5.1.22000.282,Az.Accounts/2.7.2
ParameterSetName : BySubscriptionLevel
CommandName : Invoke-AzResourceAction
Body:
============================ HTTP RESPONSE ============================
Status Code:
Accepted
Headers:
Pragma : no-cache
Azure-AsyncOperation : https://management.azure.com/subscriptions/*************/providers/Microsoft.ContainerInstance/locations/westus/operations/30b19ba8-98bd-40f5-9569-abdda7bf2b89?api-version=2018-06-01
x-ms-request-id : westus:30b19ba8-98bd-40f5-9569-abdda7bf2b89
x-ms-ratelimit-remaining-subscription-writes: 1199
x-ms-correlation-request-id : 63cc6417-f98b-4225-b7c1-939204f09d56
x-ms-routing-request-id : JAPANEAST:20220209T060045Z:63cc6417-f98b-4225-b7c1-939204f09d56
Strict-Transport-Security : max-age=31536000; includeSubDomains
X-Content-Type-Options : nosniff
Cache-Control : no-cache
Date : Wed, 09 Feb 2022 06:00:45 GMT
Body:
// POST method is called first and starting a container group is successful.
============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/*************/resourceGroups/myResourceGroup/providers/Microsoft.ContainerInstance/containerGroups/mycontainer/Start?api-version=2021-09-01
Headers:
User-Agent : Az.Resources/5.3.0,AzurePowershell/v0.0.0,PSVersion/v5.1.22000.282,Az.Accounts/2.7.2
ParameterSetName : BySubscriptionLevel
CommandName : Invoke-AzResourceAction
Body:
============================ HTTP RESPONSE ============================
Status Code:
NotFound
Headers:
Pragma : no-cache
x-ms-request-id : westus:e01460dd-51e3-45bc-84f7-41d8e4996461
x-ms-ratelimit-remaining-subscription-reads: 11998
x-ms-correlation-request-id : fb5e5c90-c42d-4690-ac49-183beb247ec1
x-ms-routing-request-id : JAPANEAST:20220209T060046Z:fb5e5c90-c42d-4690-ac49-183beb247ec1
Strict-Transport-Security : max-age=31536000; includeSubDomains
X-Content-Type-Options : nosniff
Cache-Control : no-cache
Date : Wed, 09 Feb 2022 06:00:45 GMT
Body:
{
"message": "No HTTP resource was found that matches the request URI 'https://provider-westus.console.azure.com/providers/api/subscriptions/*************/resourceGroups/myResourceGroup/providers/Microsoft.ContainerInstance/containerGroups/mycontainer/Start?api-version=2021-09-01'."
}
//GET request is sent after starting container group, which does not correct REST API form and that leads to the error.
//-ApiVersion "2019-12-01" does not send this unnecessary GET request
Environment data
Name Value
---- -----
PSVersion 5.1.22000.282
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22000.282
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Module versions
Get-Module Az*
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 2.7.2 Az.Accounts {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount...}
Script 5.3.0 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment...}
Error output
Message : {"message":"No HTTP resource was found that matches the request URI 'https://provider-westus.console.azure.com/providers/api/subscriptions/03ad2cfa-ada0-40f8-a002-4586577f8d72/resourceGroups/myResourceGroup/providers/Mi
crosoft.ContainerInstance/containerGroups/mycontainer/Start?api-version=2021-09-01'."}
CorrelationId: fb5e5c90-c42d-4690-ac49-183beb247ec1
StackTrace : 場所 Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.HandleException(ExceptionDispatchInfo capturedException)
場所 Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.ResourceManagerCmdletBase.ExecuteCmdlet()
場所 Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.ErrorResponses.ErrorResponseMessageException
InvocationInfo : {Invoke-AzResourceAction}
Line : Invoke-AzResourceAction -ResourceGroupName myResourceGroup -ResourceName mycontainer -ResourceType Microsoft.ContainerInstance/containerGroups -Action Start -Force -ApiVersion "2021-09-01" -debug -verbose