PARALLAX

azure_rm_adapplication

Manage Azure Active Directory application

Collection: azure.azcollection

Full Name: azure.azcollection.azure_rm_adapplication

Synopsis

Manage Azure Active Directory application

Parameters

NameTypeRequiredDefaultDescription
ad_userstringActive Directory username. Use when authenticating with an Active Directory user rather than service principal.
adfs_authority_urlstringAzure AD authority url. Use when authenticating with Username/password, and has your own ADFS authority.
allow_guests_sign_inboolA property on the application to indicate if the application accepts other IDPs or not or partially accepts.
api_profilestringlatestSelects an API profile to use when communicating with Azure services. Default value of C(latest) is appropriate for public clouds; future values will allow use with Azure Stack.
app_idstringApplication ID.
app_roleslistDeclare the roles you want to associate with your application.
auth_sourcestringautoControls the source of the credentials to use for authentication.
Can also be set via the C(ANSIBLE_AZURE_AUTH_SOURCE) environment variable.
When set to C(auto) (the default) the precedence is module parameters -> C(env) -> C(credential_file) -> C(cli).
When set to C(env), the credentials will be read from the environment variables.
When set to C(credential_file), it will read the profile from C(~/.azure/credentials).
When set to C(cli), the credentials will be sources from the Azure CLI profile. C(subscription_id) or the environment variable C(AZURE_SUBSCRIPTION_ID) can be used to identify the subscription ID if more than one is present otherwise the default az cli subscription is used.
When set to C(msi), the host machine must be an azure resource with an enabled MSI extension. C(subscription_id) or the environment variable C(AZURE_SUBSCRIPTION_ID) can be used to identify the subscription ID if the resource is granted access to more than one subscription, otherwise the first subscription is chosen.
The C(msi) was added in Ansible 2.6.
cert_validation_modestringControls the certificate validation behavior for Azure endpoints. By default, all modules will validate the server certificate, but when an HTTPS proxy is in use, or against Azure Stack, it may be necessary to disable this behavior by passing C(ignore). Can also be set via credential file profile or the C(AZURE_CERT_VALIDATION) environment variable.
client_idstringAzure client ID. Use when authenticating with a Service Principal or Managed Identity (msi).
Can also be set via the C(AZURE_CLIENT_ID) environment variable.
cloud_environmentstringAzureCloudFor cloud environments other than the US public cloud, the environment name (as defined by Azure Python SDK, eg, C(AzureChinaCloud), C(AzureUSGovernment)), or a metadata discovery endpoint URL (required for Azure Stack). Can also be set via credential file profile or the C(AZURE_CLOUD_ENVIRONMENT) environment variable.
credential_descriptionstringThe description of the password.
disable_instance_discoveryboolfalseDetermines whether or not instance discovery is performed when attempting to authenticate. Setting this to true will completely disable both instance discovery and authority validation. This functionality is intended for use in scenarios where the metadata endpoint cannot be reached such as in private clouds or Azure Stack. The process of instance discovery entails retrieving authority metadata from https://login.microsoft.com/ to validate the authority. By setting this to True, the validation of the authority is disabled. As a result, it is crucial to ensure that the configured authority host is valid and trustworthy.
Set via credential file profile or the C(AZURE_DISABLE_INSTANCE_DISCOVERY) environment variable.
display_namestringyesThe display name of the application.
end_datestringDate or datetime after which credentials expire(e.g. ‘2017-12-31’).
Default value is one year after current time.
homepagestringThe url where users can sign in and use your app.
identifier_urislistSpace-separated unique URIs that Azure AD can use for this app.
key_display_namestringName for the certificate credential created on the new application.
Used together with C(key_value).
key_typestringAsymmetricX509CertThe type of the key credentials associated with the application.
key_usagestringVerifyThe usage of the key credentials associated with the application.
key_valuestringThe value for the key credentials associated with the application.
log_modestringParent argument.
log_pathstringParent argument.
native_appboolAn application which can be installed on a user’s device or computer.
notesstringNotes relevant for the management of the application.
oauth2_allow_implicit_flowboolWhether to allow implicit grant flow for OAuth2.
oidc_tokenstringDirect OpenID Connect (OIDC) token (JWT) used for workload identity authentication.
This token is exchanged with Azure AD using OIDC federated identity.
Useful in CI systems (for example GitHub Actions, Azure DevOps) where an OIDC token is provided directly by the platform.
Can also be set via the C(AZURE_FEDERATED_TOKEN) environment variable.
oidc_token_file_pathstringPath to a file containing an OpenID Connect (OIDC) token (JWT) used for workload identity authentication.
The file must contain only raw token.
This method is commonly used in platforms that materialize OIDC tokens as files
Can also be set via the C(AZURE_FEDERATED_TOKEN_FILE) environment variable.
optional_claimsdictDeclare the optional claims for the application.
passwordstring(Deprecated). Microsoft Graph generates client secrets server-side and rejects client-supplied values.
When set, the supplied value is ignored and a server-generated secret is created instead.
Prefer C(request_password=true) with C(password_display_name). The generated secret appears in the registered result under C(generated_password_credentials[0].secret_text).
For ongoing rotation/management of secrets, use I(azure.azcollection.azure_rm_adpassword).
password_display_namestringName for the client secret created on the new application.
Used together with C(request_password=true) (or legacy C(password)).
profilestringSecurity profile found in ~/.azure/credentials file.
public_client_reply_urlslistThe public client redirect urls.
Space-separated URIs to which Azure AD will redirect in response to an OAuth 2.0 request.
The value does not need to be a physical endpoint, but must be a valid URI.
request_passwordboolfalseWhen C(true), ask Microsoft Graph to generate a client secret for the new application.
The generated secret is returned in C(generated_password_credentials[0].secret_text) and is only retrievable from that response; there is no way to fetch it later.
Mutually exclusive with C(key_value).
Has no effect when C(state=absent) or C(native_app=true).
On an update, this parameter is ignored with a warning. Microsoft Graph does not allow adding password credentials via PATCH /applications. For ongoing secret rotation, use I(azure.azcollection.azure_rm_adpassword).
required_resource_accesseslistResource scopes and roles the application requires access to.
Should be in manifest json format.
secretstringAzure client secret. Use when authenticating with a Service Principal.
sign_in_audiencestringThe application can be used from any Azure AD tenants.
Microsoft Graph SDK deprecate I(available_to_other_tenants), replace by I(sign_in_audience).
Refer to link U(https://learn.microsoft.com/en-us/graph/migrate-azure-ad-graph-property-differences#application-property-differences)
spa_reply_urlslistThe spa redirect urls.
Space-separated URIs to which Azure AD will redirect in response to an OAuth 2.0 request.
The value does not need to be a physical endpoint, but must be a valid URI.
start_datestringDate or datetime at which credentials become valid, such as ‘2017-01-01’.
Default value is current time.
statestringpresentAssert the state of Active Dirctory service principal.
Use C(present) to create or update a Password and use C(absent) to delete.
subscription_idstringYour Azure subscription Id.
tenantstringAzure tenant ID. Use when authenticating with a Service Principal.
thumbprintstringThe thumbprint of the private key specified in I(x509_certificate_path).
Use when authenticating with a Service Principal.
Required if I(x509_certificate_path) is defined.
web_reply_urlslistThe web redirect urls.
Space-separated URIs to which Azure AD will redirect in response to an OAuth 2.0 request.
The value does not need to be a physical endpoint, but must be a valid URI.
x509_certificate_pathstringPath to the X509 certificate used to create the service principal in PEM format.
The certificate must be appended to the private key.
Use when authenticating with a Service Principal.

Example

yaml
- name: Create ad application
  azure.azcollection.azure_rm_adapplication:
    display_name: "{{ display_name }}"

- name: Create ad application with multi redirect urls
  azure.azcollection.azure_rm_adapplication:
    display_name: "{{ display_name }}"
    web_reply_urls:
      - https://web01.com
    spa_reply_urls:
      - https://spa01.com
      - https://spa02.com
    public_client_reply_urls:
      - https://public01.com
      - https://public02.com

- name: Create application with more parameter
  azure.azcollection.azure_rm_adapplication:
    display_name: "{{ display_name }}"
    sign_in_audience: AzureADandPersonalMicrosoftAccount
    credential_description: "for test"
    end_date: 2021-10-01
    start_date: 2021-05-18
    identifier_uris: fredtest02.com

- name: delete ad application
  azure.azcollection.azure_rm_adapplication:
    app_id: "{{ app_id }}"
    state: absent

- name: Add certificate credential when creating ad application
  azure.azcollection.azure_rm_adapplication:
    display_name: "{{ display_name }}"
    key_type: AsymmetricX509Cert
    key_usage: Verify
    key_value: "{{ cert_file.content }}" # slurp gives base64 of the file; module normalizes to DER bytes
    tenant: "{{ tenant_id }}"
    subscription_id: "{{ subscription_id }}"

- name: Create ad application and request a server-generated client secret
  azure.azcollection.azure_rm_adapplication:
    display_name: "{{ display_name }}"
    request_password: true
    password_display_name: "ansible-managed-secret"
  register: app
  no_log: true

- name: Show the generated secret (only available on this create response)
  ansible.builtin.debug:
    msg: "{{ app.generated_password_credentials[0].secret_text }}"
  no_log: true
Search
    ↑ ↓ move↵ openesc close