Congress included stiff trade sanctions against Japan in its massive funding bill yesterday, barring Japanese firms from federally funded construction contracts in retaliation for Japanese barriers against foreign participation in its public works projects.

The sanctions -- which experts call the first retaliation initiated by Congress against a major U.S. trading partner -- signaled growing congressional anger with Japan's trading practices. They also reflect congressional resentment over the Reagan administration's reluctance to take strong action against what many legislators regard as unfair Japanese trading practices.

There was little opposition to the measure in the House or Senate. In the House, where it passed 399 to 17 on Dec. 3, no member spoke against it.

Surprisingly, the Reagan administration made no effort to block the legislation before signing it, although officials had hoped to avoid a new trade controversy with Japan until after the visit to Washington next month of its new prime minister, Noboru Takeshita.

Koichi Haraguchi, spokesman for the Japanese Embassy here, said it was "disappointing and regrettable that Congress passed retaliatory provisions against Japan. In our view, those approaches are not a constructive way to deal with the current issues."

At issue is some $60 billion in Japanese public works projects planned for the next decade. Under pressure from its politically powerful construction industry, which heavily supported Takeshita for prime minister, Japan has barred any major participation by U.S. and other foreign construction and engineering firms in government-funded public works projects.

At the same time, however, Japanese companies have become increasingly active in the United States. Although the bulk of the $2 billion in construction contracts they have won in the United States in recent years involves work for private Japanese firms here, the list also covers $120 million in federally funded projects, including a $20 million piece of the Metro's Red Line here.

The construction issue has emerged as a major U.S.-Japan trade dispute at a time of increasing congressional anger at Japan and impatience with the Reagan administration's response. There is a growing feeling in Congress that Japan only opens its market when faced with overwhelming retaliatory acts, such as sanctions ordered by President Reagan on semiconductors and the Senate vote against the sale of Toshiba products.

"This action will send a clear signal that the United States does not intend to let foreign construction firms compete freely in our marketplace while they deny market access to one of America's most competitive service industries," said Rep. Jack Brooks (D-Tex.), who insisted that Japan be targeted by name in the legislation, which also covers discriminatory actions by any other country. He sponsored the measure along with Sen. Frank Murkowski (R-Alaska).

Earlier this month, Congress passed legislation backed by Murkowski that would keep foreign companies from bidding on $30 billion worth of airport construction over the next five years if their countries do not give American firms a fair chance at their airport construction contracts. That five-year authorization measure still requires Reagan's signature.

In the legislation signed yesterday, Congress also took action against Japanese and Norwegian companies that sold computer-controlled milling machines to the Soviet Union.

The Pentagon said the equipment dramatically improved the ability of Soviet submarines to avoid detection by U.S. submarine chasers.

One provision of the massive funding measure bars the Defense Department from buying products made by Toshiba Corp. and a state-owned Norwegian arms company, Kongsberg Vappenfabrikk, because of the sale.

This could cost Toshiba as much as $150 million in sales of laptop computers to the Air Force and $25 million to $50 million in sales of Toshiba consumer electronic products in military post exchange stores. Kongsberg sells missiles to the Navy.