azure_web_app_function resource
Use the azure_web_app_function
InSpec audit resource to test the properties related to an Azure function.
Azure REST API version, endpoint, and HTTP client parameters
This resource interacts with API versions supported by the resource provider.
You can specify the api_version
as a resource parameter to use a specific version of the Azure REST API.
If you don’t specify an API version, this resource uses the latest version available.
For more information about API versioning, see the azure_generic_resource
.
By default, this resource uses the azure_cloud
global endpoint and default HTTP client settings.
You can override these settings if you need to connect to a different Azure environment (such as Azure Government or Azure China).
For more information about configuration options, see the resource pack README.
Syntax
resource_group
and site_name
and function_name
or the resource_id
are required parameters.
describe azure_web_app_function(resource_group: resource_group, site_name: site_name, function_name: function_name) do
it { should exist }
its('name') { should cmp "#{site_name}/#{function_name}" }
its('type') { should cmp 'Microsoft.Web/sites/functions' }
its('properties.name') { should cmp function_name }
its('properties.language') { should cmp 'Javascript' }
end
describe azure_web_app_function(resource_id: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/sites/{siteName}/functions/{functionName}') do
it { should exist }
end
Parameters
resource_group
- Azure resource group where the targeted resource resides.
name
- Name of the Azure function app to test.
FunctionApp
. site_name
- Name of the Azure function app to test (for backward compatibility).
FunctionApp
. function_name
- Name of the Azure function to test
Function
. resource_id
- The unique resource ID.
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/sites/{siteName}/functions/{functionName}
.
Either one of the parameter sets can be provided for a valid query:
resource_id
resource_group
andname
andfunction_name
resource_group
andsite_name
andfunction_name
Properties
config_href
- Config URI.
function_app_id
- Function app ID.
language
- The function language.
isDisabled
- Gets or sets a value indicating whether the function is disabled.
For properties applicable to all resources, such as type
, name
, id
, and properties
, refer to azure_generic_resource
.
Also, see the Azure documentation for other available properties. You can access any attribute in the response with the key names separated by dots (.
).
Examples
describe azure_web_app_function(resource_group: 'RESOURCE_GROUP', site_name: 'functions-http', function_name: 'HttpTrigger1') do
its('properties.language') { should eq 'Javascript' }
end
describe azure_web_app_function(resource_group: 'RESOURCE_GROUP', site_name: 'functions-http', function_name: 'HttpTrigger1') do
its('properties.isDisabled') { should be_false }
end
Matchers
For a full list of available matchers, see our Universal Matchers page.exists
# If a key vault is found, it will exist.
describe azure_web_app_function(resource_group: 'RESOURCE_GROUP', site_name: 'functions-http', function_name: 'HttpTrigger1') do
it { should exist }
end
not_exists
# Key vaults that are not found, will not exist.
describe azure_web_app_function(resource_group: 'RESOURCE_GROUP', site_name: 'functions-http', function_name: 'HttpTrigger1') do
it { should_not exist }
end
Azure permissions
Your Service Principal must be set up with at least a contributor
role on the subscription you wish to test.