This paper considers the long-term network resource allocation problem subject to queue stability. The dynamic problem is first reformulated as a static stochastic programming. To tackle the resultant static programming, we study its dual problem which contains finite number of variables in oppose to the primal problem that has infinite dimension. A novel online framework is developed by formulating the dual stochastic optimization as empirical risk minimization. We first propose an offline scheme for batch training which linearly converges to the optimal dual argument in expectation. The offline approach is further extended to the online setting which successfully converges to the statistical accuracy of the adaptive training set with high probability. It is both theoretically and numerically established that the novel approach can significantly improve delay and convergence of existing network optimization schemes.