def METHOD_NAME(redirect_uri, state=None):
    query = {
        'client_id': os.environ.get("AZURE_AD_CLIENT_ID"),
        'response_type': 'code',
        'redirect_uri': redirect_uri,
        'scope': 'openid email profile user.read',
        'response_mode': 'query',
    }
    if state is not None:
        query['state'] = state
    url = os.environ.get("AZURE_AD_ROOT") + \
        "/oauth2/v2.0/authorize?" + urlencode(query)
    return url