After Leona Cheng tested positive for coronavirus late last month, she was told to pack for a hospital stay. When the ambulance came to pick her up two days later from her apartment in central Shanghai, no one said otherwise.

So Ms. Cheng was surprised when the car stopped not at a hospital but at a sprawling convention center. Inside, empty hallways had been divided into living spaces with thousands of makeshift beds. And on the partitions of the exhibition stands, purple signs bore numbers delimiting the quarantine zones.

Ms Cheng, who stayed at the center for 13 days, was among the first of hundreds of thousands of Shanghai residents to be sent to government quarantine and isolation facilities, as the city faces an increase in cases of coronavirus for the first time in the pandemic. The facilities are a key part of China’s playbook in tracking, tracing and eliminating the virus, which has met with unusual public resistance in recent weeks.

Footage circulating on Chinese social media on Thursday showed members of a Shanghai community protesting the use of apartment buildings in their compound to isolate people who tested positive for the virus. Police in white hazmat suits could be seen physically beating angry residents, some of whom begged them to stop.

Chinese leaders have said the country, unlike most of the rest of the world, cannot afford to live with the virus because it has a large and vulnerable aging population. But China’s zero-tolerance policy — in which anyone who tests positive is sent to a hospital or isolation center, and close contacts are placed in quarantine hotels — becomes both a logistical challenge and politics as authorities deal with more than 350,000 cases since the current outbreak began in March.

As of April 9, Shanghai had converted more than 100 public places, including public schools and newly built high-rise office buildings, into temporary facilities called “fangcang,” or square cabin, hospitals. They are intended to house more than 160,000 people who have tested positive for the virus, officials said last week.

Thursday’s protests at the Zhangjiang Nashi International apartment complex in Shanghai’s Pudong district erupted after the developer informed 39 households that they would have to move because authorities would turn nine buildings into isolation facilities, said the developer said in a statement.

When Ms Cheng first arrived at the expo center, it seemed vast, cold and empty, she said in a phone interview. Ms Cheng, who is a student in her early 20s, also wrote about her experience on Chinese social media.

The fluorescent lights were dazzling but she tried to rest. She woke up the next morning to find her room suddenly packed with people.

There were no taps for running water or showers, Ms Cheng said, so each day she and others crowded around several fresh water machines, waiting to fill the pink plastic sinks that we had given them. The portable toilets quickly filled with so much human waste that Ms Cheng said she stopped drinking water for several days so she wouldn’t have to use them as frequently.

Even if someone had figured out how to turn off the spotlights, Ms. Cheng said, it would have been hard to sleep at night. This was when people were shouting their complaints and venting.

“A lot of people complained, and some people yelled that it smelled too bad to sleep,” she said.

Worried about upsetting her mother, Ms. Cheng did not tell her that she was in a fangcang. She said instead that she couldn’t make video calls, giving her mother vague answers about everyday life in quarantine. A woman sleeping in a nearby bed took a similar approach when speaking with her daughter. The two women shared a smile when they found out they had the same secret.

Ms Cheng said she struggled to come to terms with a quarantine system that reduced her to a number. If she wanted something, she had to find a nurse or doctor assigned to her area. But the nurses and doctors were so busy it was hard to get help, she said.

Ms Cheng said she once admired the government’s goal of keeping the virus out of China. This meant that for more than two years, she could lead a normal life, even if cities and countries around the world had to shut down.

Now she’s not so sure anymore.

“This time I feel like it’s out of control and it’s not worth controlling cases because it’s not that dangerous or deadly,” she said, referring to the highly contagious variant of Omicron. “It’s not worth sacrificing so many resources and our freedom.”

Joy Dong and Li you contributed to the research.