cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MehrdadG
Level: Powered On

Calling Azure Resource Manager API in Flow - "statusCode": 404, "message": "Resource not found"

Hi,

 

I’m using the same principle as described in Create a custom API using Azure Resource Manager in Microsoft Flow to Start/Stop an Azure Resource Manager Virtual Machine via Microsoft Flow.

 

When I register the swagger file as a custom API and create a new flow to use the Start/PowerOff actions,

The VM gets started/stopped properly like expected, but I get also a HTTP 404 error:

 

    "statusCode": 404, "message": "Resource not found"

 

The questions is how can I get more details about what is going wrong here? Or what is the reason behind this HTTP 404 ?

 

Screen capture: shows the 404 error code in the body of the output

Flow output error.jpgError 404 - Resource not found

 

Screen capture: shows that i.e. the PowerOff operation is available on the designer

 

Flow element.jpg

 

Swagger file content - Only a part of swagger file is documented here to maintain the readability:

 

	  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{virtualMachineName}/start": {
      "post": {
			"description": "Starts a given Virtual Machine",
			"summary": "Starts a given Virtual Machine",
			"operationId": "StartRmVM",
			"x-ms-visibility": "important",		
			"parameters": [
				{
				  "name": "api-version",
				  "x-ms-summary": "API version",
				  "in": "query",
				  "description": "API version",
				  "required": true,
				  "type": "string",
				  "default": "2016-03-30"
				},
				{
				  "name": "subscriptionId",
				  "in": "path",
				  "required": true,
				  "type": "string"
				},
				{
				  "name": "resourceGroupName",
				  "in": "path",
				  "required": true,
				  "type": "string"
				},
				{
				  "name": "virtualMachineName",
				  "in": "path",
				  "required": true,
				  "type": "string"
				}			
			],
			"responses": {
			  "200": {
				"description": "OK"
			  },
			  "400": {
				"description": "Bad Request"
			  },
			  "500": {
				"description": "Internal Server Error"
			  },
			  "default": {
				"description": "Operation Failed."
			  }
			}	
		 }
	  }
10 REPLIES 10
Microsoft Employee

Re: Calling Azure Resource Manager API in Flow - "statusCode": 404, "message": &

@MehrdadG Sorry you are seeing issues with this.

 

404 means Flow cannot reach the endpoint you specified. Have you made any changes to the Custom API template prior to uploading it on the Flow web site?

 

Also, can you please share te Flow name/ID? This can be done by editing your Flow on the Flow page and pasting the URL here on this thread.

 

Thanks!

Jade

MehrdadG
Level: Powered On

Re: Calling Azure Resource Manager API in Flow - "statusCode": 404, "message": &

Hi Jaden,

This is the full version of the swagger file I'm using to try it out,

 

Error detail:

OUTPUTS
Headers
{
  "Date": "Wed, 04 Jan 2017 07:15:58 GMT",
  "Server": "Microsoft-HTTPAPI/2.0",
  "Content-Length": "54",
  "Content-Type": "application/json"
}
Body
{
  "statusCode": 404,
  "message": "Resource not found"
}

 

Swagger file I'm using:

{
  "swagger": "2.0",
  "info": {
    "version": "1.0",
    "title": "ARM Sample",
    "description": "Access Azure Resources using this API to turn on/off a ARM Virtual Machine", 
    "contact": {
    "name": "sample",
    "email": "sample@non-existing.com"
    }
  },
  "host": "management.azure.com",
  "basePath": "/",
  "schemes": [
    "https"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "securityDefinitions": {
    "AAD": {
      "type": "oauth2",
      "flow": "implicit",
      "authorizationUrl": "https://login.windows.net/common/oauth2/authorize",
      "scopes": {}
    }
  },
  "paths": {
	  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{virtualMachineName}/start": {
      "post": {
			"description": "Starts a given Virtual Machine",
			"summary": "Starts a given Virtual Machine",
			"operationId": "StartRmVM",
			"x-ms-visibility": "important",		
			"parameters": [
				{
				  "name": "api-version",
				  "x-ms-summary": "API version",
				  "in": "query",
				  "description": "API version",
				  "required": true,
				  "type": "string",
				  "default": "2016-03-30"
				},
				{
				  "name": "subscriptionId",
				  "in": "path",
				  "required": true,
				  "type": "string"
				},
				{
				  "name": "resourceGroupName",
				  "in": "path",
				  "required": true,
				  "type": "string"
				},
				{
				  "name": "virtualMachineName",
				  "in": "path",
				  "required": true,
				  "type": "string"
				}			
			],
			"responses": {
			  "200": {
				"description": "OK"
			  },
			  "400": {
				"description": "Bad Request"
			  },
			  "500": {
				"description": "Internal Server Error"
			  },
			  "default": {
				"description": "Operation Failed."
			  }
			}	
		 }
	  },
	  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{virtualMachineName}/powerOff": {
      "post": {
			"description": "PowerOff a given Virtual Machine",
			"summary": "PowerOff a given Virtual Machine",
			"operationId": "PowerOffRmVM",
			"x-ms-visibility": "important",		
			"parameters": [
				{
				  "name": "api-version",
				  "x-ms-summary": "API version",
				  "in": "query",
				  "description": "API version",
				  "required": true,
				  "type": "string",
				  "default": "2016-03-30"
				},
				{
				  "name": "subscriptionId",
				  "in": "path",
				  "required": true,
				  "type": "string"
				},
				{
				  "name": "resourceGroupName",
				  "in": "path",
				  "required": true,
				  "type": "string"
				},
				{
				  "name": "virtualMachineName",
				  "in": "path",
				  "required": true,
				  "type": "string"
				}			
			],
			"responses": {
			  "200": {
				"description": "OK"
			  },
			  "400": {
				"description": "Bad Request"
			  },
			  "500": {
				"description": "Internal Server Error"
			  },
			  "default": {
				"description": "Operation Failed."
			  }
			}	
		 }
	  }  
  }
}
Community Support Team
Community Support Team

Re: Calling Azure Resource Manager API in Flow - "statusCode": 404, "message": &

Hi MehrdadG,

 

Thanks for the full version of the Swagger file. Could you also please provide your Flow Name and your Flow ID for a further investigation?

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Microsoft Employee

Re: Calling Azure Resource Manager API in Flow - "statusCode": 404, "message": &

 

From the looks of it this probably means the params specified (e.g. resourceGroupName, subscriptionId, etc.) are leading to an invalid URL thus the 404 error.

 

The only way we can confirm this issue for you is if we have some identifiers for the Flow (e.g. Flow ID) itself so we can investigate on our end.

 

Thank you,

Jade

MehrdadG
Level: Powered On

Re: Calling Azure Resource Manager API in Flow - "statusCode": 404, "message": &

Hi,

 

Sorry about the long delay in between.

 

Here is the Url to the flow editor:

 

https://flow.microsoft.com/manage/environments/201481f5-c2da-4d1a-8f87-4c5ca33bca80/flows/aa698f76-8...

 

Hope this helps for further follow-up as the issue is still the same.

 

Please let me know if you need any additional details

..Thanks!

 

Kind regards,

MehrdadG

Highlighted
MehrdadG
Level: Powered On

Re: Calling Azure Resource Manager API in Flow - "statusCode": 404, "message": &

Any update on this subject?

 

Was the provided information sufficient? Is there anything more visible from backend logging why the HTTP 404 is occuring?

 

Kind regards,

MehrdadG

Power Automate Staff Sunay
Power Automate Staff

Re: Calling Azure Resource Manager API in Flow - "statusCode": 404, "message": &

Hi @MehrdadG seems like the error is coming from the ARM APIs themselves. What you can do though is, inspect the request being made through the Flow using the "Test" Tab on the Custom API expereince.

 

More information on how to test your custom API is in this blog post : https://ms.flow.microsoft.com/en-us/blog/new-updates-custom-api/

 

Please let me know if this works for you, if not - I can try to debug this on our side.

 

Thanks,

Sunay

 

Power Automate Staff Pawel
Power Automate Staff

Re: Calling Azure Resource Manager API in Flow - "statusCode": 404, "message": &

@MehrdadG Also in the swagger of your Custom API try specifying apiVersion as "2016-04-30-preview", according to the docs that's the latest version: https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/virtualmachines-start 

asifip
Level: Powered On

Re: Calling Azure Resource Manager API in Flow - "statusCode": 404, "message": &

Hi MehrdadG,

 

Can you check your link, it seems there is an error that indicates unavailability. It would be a great help if you could fix this.

 

ref - https://flow.microsoft.com/manage/environments/201481f5-c2da-4d1a-8f87-4c5ca33bca80/flows/aa698f76-8...

 

 

THanks

Asif

weskroesbergen
Level: Power Up

Re: Calling Azure Resource Manager API in Flow - "statusCode": 404, "message": &

Hi folks,

 

I too am having this issue. What's weird is that I can see the calls to ARM actually succeed in the Azure activity logs. I also built a custom connector and added actions for start/stopping resources. These calls return a 202 in the Flow Connector Test tab, but a 404 when actually called by a flow (though again, the action actually succeeds and the resource starts / stops in Azure as requested).

 

I also tried adding handling for 404 and 202 response codes, and they do not seem to fire.

 

Edit: I am also using 2016-04-30-preview as my API version.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (7,331)