aws:executeAzureApi – Call and run Azure API operations
The aws:executeAzureApi action calls and runs a Microsoft Azure
API operation on the resources that a Cloud Connector reaches. Automation calls the
operation with the Azure SDK for Python and returns the response as a JSON
object, so you can select values from it the same way as for aws:executeAwsApi – Call and run AWS API operations.
The aws:executeAzureApi action is available in the AWS Regions where
Cloud Connector is available.
Input
You provide Service, Api, Package,
CloudConnector, and SubscriptionId. You pass the request body,
if the operation has one, in Body. Any other inputs are passed to the
Azure API operation as its parameters.
- Service
-
The module name that follows
azure.mgmt.in the Azure SDK for Python. For example, specifycomputefor virtual machines (azure.mgmt.compute). For a library that has its client in a submodule, include the submodule, for exampleresource.resourcesfor resource groups. For more information about the services that the action doesn't support, see Limitations.Type: String
Required: Yes
- Api
-
The name of the API operation that you want to run, in the form
OperationGroup.Method. Use the operation group and operation name from the Azure REST API reference. For example, to get a virtual machine, specifyVirtualMachines.Get. You can also use the SDK's snake_case form, for examplevirtual_machines.get. For how to build the name from the REST reference, see Naming rules. A long-running operation returns as soon as Azure accepts the request, without waiting for it to finish. For more information, see Lists and long-running operations.Type: String
Required: Yes
- Package
-
The name of the published Azure SDK package that provides the operation. For more information about the available packages and the libraries in each, see Azure and Google Cloud SDK packages.
Type: String
Required: Yes
- CloudConnector
-
The ID of the Cloud Connector that reaches your Azure resources. Automation uses the connector to sign in to Azure. For example,
a1b2c3d4-5678-90ab-cdef-111122223333.Type: String
Required: Yes
- SubscriptionId
-
The ID of the Azure subscription that contains the resource. Automation checks this input when the step runs. If the input is missing, the step fails with
Missing required parameter 'SubscriptionId' for Azure API action.If the Cloud Connector targets specific subscriptions and this subscription isn't one of them, the step fails withThe Azure subscription 'subscription-id' is not in the list of allowed subscriptions for this Cloud Connector.Type: String
Required: Yes
- API operation parameters
-
Any other inputs that you add to the step are passed to the Azure API operation as its path and query parameters. Use the parameter names from the Azure REST API reference. For example,
VirtualMachines.GettakesresourceGroupNameandvmName. Names aren't case-sensitive, and underscores are ignored. The following exceptions apply:-
Omit the leading
$from OData query parameters. For example, specifyfilter,top, andexpandinstead of$filter,$top, and$expand. -
Don't specify
api-version. The package sets the API version. -
Header parameters, such as
If-Match,If-None-Match, andx-ms-*headers, aren't supported.
For more information, see Pass parameters and a request body.
Type: Determined by the chosen API operation
Required: Determined by the chosen API operation
-
- Body
-
The request body of the API operation, as a JSON object in the shape that the Azure REST API reference shows. For example, for
AvailabilitySets.CreateOrUpdate,{"location": "eastus", "tags": {"environment": "test"}}. Use this input only for an operation that takes a request body. Pass request-body properties inBodyrather than as separate step inputs.Type: StringMap (a JSON object; values can be nested objects and lists)
Required: Determined by the chosen API operation
- NextLink
-
Use this input to get the next page of a list operation. Give it the
nextLinkvalue from the previous response. The step returns the next page. The URL must start withhttps://management.azure.com/subscriptions/followed by the step'sSubscriptionId. You can't get further pages of a list that isn't scoped to a subscription.Type: String
Required: No
Outputs
You specify outputs based on the response from the chosen API operation.
- Name
-
A name for the output.
Type: String
Required: Yes
- Selector
-
The JSONPath to a specific attribute in the response object. Automation returns the Azure response as a JSON object. For example, for
VirtualMachines.Get, the selector$.locationreturns the resource's region, and$.properties.provisioningStatereturns its provisioning state. The response uses the property names from the Azure REST API reference. A list operation returns one page. For more information about the JSONPath that you can use, see Select values from the response.Type: String
Required: Yes
- Type
-
The data type for the response element. Valid values:
String,Integer,Boolean,StringList,StringMap,MapList.Type: String
Required: Yes
Response size limit
The Azure response can be at most 358,400 characters, before
Automation applies selectors. A larger response fails the step with Step output
size of . To stay under the limit with a list operation, request a smaller
page or a narrower scope.size exceeds size limit of 358400
characters
Credentials and permissions
Automation signs in to Azure with the Cloud Connector. If the
automation has an AutomationAssumeRole, Automation uses that role to
assume the connector's federation role. Otherwise, it uses the credentials of the user
who started the automation. For more information about the permissions that each role needs, see Permissions for automations that use a Cloud Connector.
Find an operation
To find the operations and parameters of a service, see the Azure REST API
reference
Naming rules
To build the Api value from a page in the Azure REST API
reference, take the operation group and the operation from the page title and remove
the spaces. For example, Virtual Machines - Instance View becomes
VirtualMachines.InstanceView. You can also use the SDK's snake_case
names, such as virtual_machines.instance_view. The following exceptions
apply:
-
In an operation group name, write an acronym that follows other words with only its first letter capitalized. For example, specify
VirtualMachineScaleSetVms.Get, notVirtualMachineScaleSetVMs.Get. Or use the snake_case form, such asvirtual_machine_scale_set_vms.get. -
If the Azure SDK for Python renames an operation, use the SDK name. For example, for the REST operation Databases - Import, specify
Databases.ImportMethod. -
Don't write the operation group in lowercase without underscores.
virtualmachines.getisn't accepted. UseVirtualMachines.Getorvirtual_machines.get.
Limitations
The following limitations apply to aws:executeAzureApi,
aws:assertAzureResourceProperty, and
aws:waitForAzureResourceProperty.
-
Operations that aren't in an operation group, such as
CheckDnsNameAvailabilityinnetworkandCheckNameAvailabilityinweb, aren't supported. -
The package sets the API version of each service. The Azure REST API reference can show a newer version, with parameters or properties that the package's version doesn't have.
-
Each call to Azure must finish within 30 seconds. Otherwise, the step fails with
Provider API dispatch timed out.
To call a service or operation that isn't supported, use a Python script in
aws:executeScript with the same package. For more information, see aws:executeScript – Run a script.
Example – Get a virtual machine
The following step gets a virtual machine and returns its name and region.
The following YAML and JSON examples show a step that creates an availability set with a tag, and returns its name.
If Azure returns an error, for example because the connector's
Azure application doesn't have permission or the resource doesn't exist, the
step fails with an error that starts with Azure error
( or code)Azure client error
( and includes Azure's message.
For an Azure server error, the message starts with status)Unexpected Azure
error. To let the automation continue after a failure, set
onFailure on the step. For common errors, see Troubleshooting automations that use a Cloud Connector.