plugins/out_azure_blob/azure_blob.c
static int ensure_container(struct flb_azure_blob *ctx)
{
    int ret;
    int status;
    size_t b_sent;
    flb_sds_t uri;
    struct flb_http_client *c;
    struct flb_upstream_conn *u_conn;

    uri = azb_uri_ensure_or_create_container(ctx);
    if (!uri) {
        return FLB_FALSE;
    }

    /* Get upstream connection */
    u_conn = flb_upstream_conn_get(ctx->u);
    if (!u_conn) {
        flb_plg_error(ctx->ins,
                      "cannot create upstream connection for container check");
        flb_sds_destroy(uri);
        return FLB_FALSE;
    }

    /* Create HTTP client context */
    c = flb_http_client(u_conn, FLB_HTTP_GET,
                        uri,
                        NULL, 0, NULL, 0, NULL, 0);
    if (!c) {
        flb_plg_error(ctx->ins, "cannot create HTTP client context");
        flb_upstream_conn_release(u_conn);
        return FLB_FALSE;
    }
    flb_http_strip_port_from_host(c);

    /* Prepare headers and authentication */
    azb_http_client_setup(ctx, c, -1, FLB_FALSE, FLB_FALSE);

    /* Send HTTP request */
    ret = flb_http_do(c, &b_sent);
    flb_sds_destroy(uri);

    if (ret == -1) {
        flb_plg_error(ctx->ins, "error requesting container properties");
        flb_upstream_conn_release(u_conn);
        return FLB_FALSE;
    }

    status = c->resp.status;
    flb_http_client_destroy(c);

    /* Release connection */
    flb_upstream_conn_release(u_conn);

    /* Request was successful, validate HTTP status code */
    if (status == 404) {
        /* The container was not found, try to create it */
        flb_plg_info(ctx->ins, "container '%s' not found, trying to create it",
                     ctx->container_name);
        ret = create_container(ctx, ctx->container_name);
        return ret;
    }
    else if (status == 200) {
        return FLB_TRUE;
    }

    return FLB_FALSE;
}
/*
 * Check that the container exists, if it doesn't and the configuration property
 * auto_create_container is enabled, it will send a request to create it. If it
 * could not be created or auto_create_container is disabled, it returns FLB_FALSE.
 */
Check that the container exists, if it doesn't and the configuration property
auto_create_container is enabled, it will send a request to create it. If it
could not be created or auto_create_container is disabled, it returns FLB_FALSE.
Check that the container exists if it doesn ' t and the configuration property auto_create_container is enabled it will send a request to create it . If it could not be created or auto_create_container is disabled it returns FLB_FALSE .
static int ensure_container(struct flb_azure_blob *ctx)
{
    int ret;
    int status;
    size_t b_sent;
    flb_sds_t uri;
    struct flb_http_client *c;
    struct flb_upstream_conn *u_conn;
    uri = azb_uri_ensure_or_create_container(ctx);
    if (!uri) {
        return FLB_FALSE;
    }
    u_conn = flb_upstream_conn_get(ctx->u);
    if (!u_conn) {
        flb_plg_error(ctx->ins,
                      "cannot create upstream connection for container check");
        flb_sds_destroy(uri);
        return FLB_FALSE;
    }
    c = flb_http_client(u_conn, FLB_HTTP_GET,
                        uri,
                        NULL, 0, NULL, 0, NULL, 0);
    if (!c) {
        flb_plg_error(ctx->ins, "cannot create HTTP client context");
        flb_upstream_conn_release(u_conn);
        return FLB_FALSE;
    }
    flb_http_strip_port_from_host(c);
    azb_http_client_setup(ctx, c, -1, FLB_FALSE, FLB_FALSE);
    ret = flb_http_do(c, &b_sent);
    flb_sds_destroy(uri);
    if (ret == -1) {
        flb_plg_error(ctx->ins, "error requesting container properties");
        flb_upstream_conn_release(u_conn);
        return FLB_FALSE;
    }
    status = c->resp.status;
    flb_http_client_destroy(c);
    flb_upstream_conn_release(u_conn);
    if (status == 404) {
        flb_plg_info(ctx->ins, "container '%s' not found, trying to create it",
                     ctx->container_name);
        ret = create_container(ctx, ctx->container_name);
        return ret;
    }
    else if (status == 200) {
        return FLB_TRUE;
    }
    return FLB_FALSE;
}
static int ensure_container ( struct flb_azure_blob * ctx ) { int ret ; int status ; size_t b_sent ; flb_sds_t uri ; struct flb_http_client * c ; struct flb_upstream_conn * u_conn ; uri = azb_uri_ensure_or_create_container ( ctx ) ; if ( ! uri ) { return FLB_FALSE ; } u_conn = flb_upstream_conn_get ( ctx -> u ) ; if ( ! u_conn ) { flb_plg_error ( ctx -> ins , " " ) ; flb_sds_destroy ( uri ) ; return FLB_FALSE ; } c = flb_http_client ( u_conn , FLB_HTTP_GET , uri , NULL , 0 , NULL , 0 , NULL , 0 ) ; if ( ! c ) { flb_plg_error ( ctx -> ins , " " ) ; flb_upstream_conn_release ( u_conn ) ; return FLB_FALSE ; } flb_http_strip_port_from_host ( c ) ; azb_http_client_setup ( ctx , c , -1 , FLB_FALSE , FLB_FALSE ) ; ret = flb_http_do ( c , & b_sent ) ; flb_sds_destroy ( uri ) ; if ( ret == -1 ) { flb_plg_error ( ctx -> ins , " " ) ; flb_upstream_conn_release ( u_conn ) ; return FLB_FALSE ; } status = c -> resp . status ; flb_http_client_destroy ( c ) ; flb_upstream_conn_release ( u_conn ) ; if ( status == 404 ) { flb_plg_info ( ctx -> ins , " " , ctx -> container_name ) ; ret = create_container ( ctx , ctx -> container_name ) ; return ret ; } else if ( status == 200 ) { return FLB_TRUE ; } return FLB_FALSE ; }
Check that the container exists, if it doesn't and the configuration property
 auto_create_container is enabled, it will send a request to create it.
Check that the container exists if it doesn ' t and the configuration property auto_create_container is enabled it will send a request to create it .
/* Get upstream connection */ /* Create HTTP client context */ /* Prepare headers and authentication */ /* Send HTTP request */ /* Release connection */ /* Request was successful, validate HTTP status code */ /* The container was not found, try to create it */