Justin Trudeau is caught between two economies, and his visit to San Francisco on Thursday showed why.

The Canadian leader zigzagged through the city for a series of tech meetings, hailed the benefits of immigrants to an industry thirsty for talent, had a private chat with Amazon.com Inc.’s Jeff Bezos, pitching Toronto for the retail giant’s second headquarters, and even picked up investments from Salesforce.com Inc. and AppDirect Inc. It’s in keeping with Trudeau’s aspiration to remake Canada as a tech leader—with mixed results so far.

Dogging him, though, were some very immediate problems for Canada’s economy. They include divisions over an oil pipeline and questions about ongoing Nafta talks where the U.S., Canada and Mexico are digging in on distinctly analog industries that feel miles away from Silicon Valley, like manufacturing plants and dairy cows. Trudeau even took a veiled old school shot at Amazon, saying he’d defend brick-and-mortar retail amid calls from his own central bank to rein in powers of “superstar” tech firms.

It all underscores core tension for Trudeau, trying to spur a new economy while defending the one he has from, among other things, Donald Trump’s threats to walk away from Nafta and opponents at home of new resource projects.

“Our focus is very much not just that the economy is good next week, but how could we make sure it’s good a decade from now, for the next generation,” Trudeau said Thursday.

Canada’s economy has been hot, leading the Group of Seven in growth in 2017 though it’s forecast to slip to third place this year as risks mount, including a slowdown in spending by the nation’s highly-indebted consumers and the country’s struggle to build the infrastructure to get its oil to market.

This week, a trade war even broke out between two provinces over a pipeline Trudeau has pledged to get built as he attempts another balancing act—cutting emissions for a greener economy without kneecapping the lucrative oil sector that has driven much of Canadian growth in recent decades.

Another major risk is Nafta, with Trump regularly threatening to walk away if he doesn’t get a bigger deal. Chrystia Freeland, the Canadian minister leading talks on Trudeau’s behalf, told lawmakers in Ottawa on Thursday that significant differences remain. Trudeau said as much himself.

“Any deal has to be a win-win-win and that means that we’re going to have to ensure we’re standing up for Canadian interests as we move forward on a deal that works for everyone,” he said.

Salesforce Pledge

Trudeau nonetheless received fawning praise from Silicon Valley tech leaders, who have clashed with Trump over political differences.

Salesforce.com’s chairman and chief executive officer Marc Benioff hosted Trudeau for a round-table discussion with corporate leaders on the importance of diversity and equality, held at Salesforce’s headquarters, in San Francisco’s tallest building. The company announced a $2 billion investment in Canada, a pledge Trudeau said would yield thousands of jobs.

“You have a real friend in San Francisco,” Benioff said to a smiling Trudeau. “As a city we love you, we connect with you on your values. Like you, we are a city that values diversity, equality, and we also value innovation.”

The panel discussion’s other attendees included Bernard Tyson, chairman and chief executive officer of Kaiser Permanente; Dan Schulman, chief executive officer of PayPal Holdings Inc.; Geisha Williams, chief executive officer of PG&E Corp.; and Diane Greene, senior vice president of Google Cloud.

Trudeau later met with AppDirect co-CEO Daniel Saks, who announced the company would hire 300 more staff in Canada. The investment “will strengthen our economy and further position our country as world leader in tech,” Trudeau said.

Yet, even the tech-friendly Trudeau has his limits when it comes to accommodating the industry. He was asked about a U.S. push for Canada to raise the de minimis threshold, in effect allowing more online shopping to be done tax-free—a move that would help Amazon. He gave little sign he would. “I can reassure Canadians I will always stand up for Canadian interests including small businesses,” he said.